Passed
Push — master ( 59160c...9fabf9 )
by Kiran
10:03 queued 05:25
created
widgets/getpaid.php 1 patch
Indentation   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -36,36 +36,36 @@  discard block
 block discarded – undo
36 36
                     'desc_tip' => true,
37 37
                     'default'  => '',
38 38
                     'advanced' => false,
39
-				),
39
+                ),
40 40
 
41 41
                 'form'   => array(
42
-	                'title'       => __( 'Form', 'invoicing' ),
43
-	                'desc'        => __( 'Enter a form id in case you want to display a specific payment form', 'invoicing' ),
44
-	                'type'        => 'text',
45
-	                'desc_tip'    => true,
46
-	                'default'     => '',
47
-	                'placeholder' => __( '1', 'invoicing' ),
48
-	                'advanced'    => false,
49
-				),
50
-
51
-				'item'   => array(
52
-	                'title'       => __( 'Items', 'invoicing' ),
53
-	                'desc'        => __( 'Enter comma separated list of invoicing item id and quantity (item_id|quantity). Ex. 101|2. This will be ignored in case you specify a form above. Enter 0 as the quantity to let users select their own quantities', 'invoicing' ),
54
-	                'type'        => 'text',
55
-	                'desc_tip'    => true,
56
-	                'default'     => '',
57
-	                'placeholder' => __( '1', 'invoicing' ),
58
-	                'advanced'    => false,
59
-				),
42
+                    'title'       => __( 'Form', 'invoicing' ),
43
+                    'desc'        => __( 'Enter a form id in case you want to display a specific payment form', 'invoicing' ),
44
+                    'type'        => 'text',
45
+                    'desc_tip'    => true,
46
+                    'default'     => '',
47
+                    'placeholder' => __( '1', 'invoicing' ),
48
+                    'advanced'    => false,
49
+                ),
50
+
51
+                'item'   => array(
52
+                    'title'       => __( 'Items', 'invoicing' ),
53
+                    'desc'        => __( 'Enter comma separated list of invoicing item id and quantity (item_id|quantity). Ex. 101|2. This will be ignored in case you specify a form above. Enter 0 as the quantity to let users select their own quantities', 'invoicing' ),
54
+                    'type'        => 'text',
55
+                    'desc_tip'    => true,
56
+                    'default'     => '',
57
+                    'placeholder' => __( '1', 'invoicing' ),
58
+                    'advanced'    => false,
59
+                ),
60 60
 
61 61
                 'button' => array(
62
-	                'title'    => __( 'Button', 'invoicing' ),
63
-	                'desc'     => __( 'Enter button label in case you would like to display the forms in a popup.', 'invoicing' ),
64
-	                'type'     => 'text',
65
-	                'desc_tip' => true,
66
-	                'default'  => '',
67
-	                'advanced' => false,
68
-				),
62
+                    'title'    => __( 'Button', 'invoicing' ),
63
+                    'desc'     => __( 'Enter button label in case you would like to display the forms in a popup.', 'invoicing' ),
64
+                    'type'     => 'text',
65
+                    'desc_tip' => true,
66
+                    'default'  => '',
67
+                    'advanced' => false,
68
+                ),
69 69
 
70 70
             ),
71 71
 
@@ -74,96 +74,96 @@  discard block
 block discarded – undo
74 74
         parent::__construct( $options );
75 75
     }
76 76
 
77
-	/**
78
-	 * The Super block output function.
79
-	 *
80
-	 * @param array $args
81
-	 * @param array $widget_args
82
-	 * @param string $content
83
-	 *
84
-	 * @return string
85
-	 */
77
+    /**
78
+     * The Super block output function.
79
+     *
80
+     * @param array $args
81
+     * @param array $widget_args
82
+     * @param string $content
83
+     *
84
+     * @return string
85
+     */
86 86
     public function output( $args = array(), $widget_args = array(), $content = '' ) {
87 87
 
88
-	    // Is the shortcode set up correctly?
89
-		if ( empty( $args['form'] ) && empty( $args['item'] ) ) {
90
-			return aui()->alert(
91
-				array(
92
-					'type'    => 'warning',
93
-					'content' => __( 'No payment form or item selected', 'invoicing' ),
94
-				)
95
-			);
96
-		}
97
-
98
-		// Payment form or button?
99
-		if ( ! empty( $args['form'] ) ) {
100
-			return $this->handle_payment_form( $args );
101
-		} else {
102
-			return $this->handle_buy_item( $args );
103
-		}
104
-
105
-	}
106
-
107
-	/**
108
-	 * Displaying a payment form
109
-	 *
110
-	 * @return string
111
-	 */
88
+        // Is the shortcode set up correctly?
89
+        if ( empty( $args['form'] ) && empty( $args['item'] ) ) {
90
+            return aui()->alert(
91
+                array(
92
+                    'type'    => 'warning',
93
+                    'content' => __( 'No payment form or item selected', 'invoicing' ),
94
+                )
95
+            );
96
+        }
97
+
98
+        // Payment form or button?
99
+        if ( ! empty( $args['form'] ) ) {
100
+            return $this->handle_payment_form( $args );
101
+        } else {
102
+            return $this->handle_buy_item( $args );
103
+        }
104
+
105
+    }
106
+
107
+    /**
108
+     * Displaying a payment form
109
+     *
110
+     * @return string
111
+     */
112 112
     protected function handle_payment_form( $args = array() ) {
113 113
 
114
-		if ( empty( $args['button'] ) ) {
115
-			ob_start();
116
-			getpaid_display_payment_form( $args['form'] );
117
-			return ob_get_clean();
118
-		}
114
+        if ( empty( $args['button'] ) ) {
115
+            ob_start();
116
+            getpaid_display_payment_form( $args['form'] );
117
+            return ob_get_clean();
118
+        }
119 119
 
120
-		return $this->payment_form_button( $args['form'], $args['button'] );
121
-	}
120
+        return $this->payment_form_button( $args['form'], $args['button'] );
121
+    }
122 122
 
123
-	/**
124
-	 * Displays a payment form button.
125
-	 *
126
-	 * @return string
127
-	 */
123
+    /**
124
+     * Displays a payment form button.
125
+     *
126
+     * @return string
127
+     */
128 128
     protected function payment_form_button( $form, $button ) {
129
-		return getpaid_get_payment_button( $button, $form );
130
-	}
131
-
132
-	/**
133
-	 * Selling an item
134
-	 *
135
-	 * @return string
136
-	 */
129
+        return getpaid_get_payment_button( $button, $form );
130
+    }
131
+
132
+    /**
133
+     * Selling an item
134
+     *
135
+     * @return string
136
+     */
137 137
     protected function handle_buy_item( $args = array() ) {
138 138
 
139
-		if ( empty( $args['button'] ) ) {
140
-			return $this->buy_item_form( $args['item'] );
141
-		}
139
+        if ( empty( $args['button'] ) ) {
140
+            return $this->buy_item_form( $args['item'] );
141
+        }
142 142
 
143
-		return $this->buy_item_button( $args['item'], $args['button'] );
143
+        return $this->buy_item_button( $args['item'], $args['button'] );
144 144
 
145
-	}
145
+    }
146 146
 
147
-	/**
148
-	 * Displays a buy item form.
149
-	 *
150
-	 * @return string
151
-	 */
147
+    /**
148
+     * Displays a buy item form.
149
+     *
150
+     * @return string
151
+     */
152 152
     protected function buy_item_form( $item ) {
153
-		$items = getpaid_convert_items_to_array( $item );
154
-		ob_start();
155
-		getpaid_display_item_payment_form( $items );
156
-		return ob_get_clean();
157
-	}
158
-
159
-	/**
160
-	 * Displays a buy item button.
161
-	 *
162
-	 * @return string
163
-	 */
153
+        $items = getpaid_convert_items_to_array( $item );
154
+        ob_start();
155
+        getpaid_display_item_payment_form( $items );
156
+        return ob_get_clean();
157
+    }
158
+
159
+    /**
160
+     * Displays a buy item button.
161
+     *
162
+     * @return string
163
+     */
164 164
     protected function buy_item_button( $item, $button ) {
165
-		$button = getpaid_get_payment_button( $button, null, $item );
166
-		return apply_filters( 'getpaid_buy_item_button_widget', $button, $item );
165
+        $button = getpaid_get_payment_button( $button, null, $item );
166
+        return apply_filters( 'getpaid_buy_item_button_widget', $button, $item );
167 167
     }
168 168
 
169 169
 }
Please login to merge, or discard this patch.
templates/invoice/line-items.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -33,12 +33,12 @@
 block discarded – undo
33 33
 
34 34
             // Display the item totals.
35 35
             foreach ( $invoice->get_items() as $item ) {
36
-			wpinv_get_template( 'invoice/line-item.php', compact( 'invoice', 'item', 'columns' ) );
36
+            wpinv_get_template( 'invoice/line-item.php', compact( 'invoice', 'item', 'columns' ) );
37 37
             }
38 38
 
39 39
             // Display the fee totals.
40 40
             foreach ( $invoice->get_fees() as $fee ) {
41
-			wpinv_get_template( 'invoice/fee-item.php', compact( 'invoice', 'fee', 'columns' ) );
41
+            wpinv_get_template( 'invoice/fee-item.php', compact( 'invoice', 'fee', 'columns' ) );
42 42
             }
43 43
 
44 44
             // Display the cart totals.
Please login to merge, or discard this patch.
templates/wpinv-invalid-access.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -40,19 +40,19 @@
 block discarded – undo
40 40
         <?php
41 41
 
42 42
             if ( ! $invoice->exists() || $invoice->is_draft() ) {
43
-			$error = __( 'This invoice was deleted or is not visible.', 'invoicing' );
43
+            $error = __( 'This invoice was deleted or is not visible.', 'invoicing' );
44 44
             } else {
45 45
 
46
-			$user_id = get_current_user_id();
47
-			if ( wpinv_require_login_to_checkout() && empty( $user_id ) ) {
48
-				$error  = __( 'You must be logged in to view this invoice.', 'invoicing' );
49
-				$error .= sprintf(
50
-					' <a href="%s">%s</a>',
51
-					wp_login_url( $invoice->get_view_url() ),
52
-					__( 'Login.', 'invoicing' )
53
-				);
54
-			} else {
55
-				$error = __( 'This invoice is only viewable by clicking on the invoice link that was sent to you via email.', 'invoicing' );
46
+            $user_id = get_current_user_id();
47
+            if ( wpinv_require_login_to_checkout() && empty( $user_id ) ) {
48
+                $error  = __( 'You must be logged in to view this invoice.', 'invoicing' );
49
+                $error .= sprintf(
50
+                    ' <a href="%s">%s</a>',
51
+                    wp_login_url( $invoice->get_view_url() ),
52
+                    __( 'Login.', 'invoicing' )
53
+                );
54
+            } else {
55
+                $error = __( 'This invoice is only viewable by clicking on the invoice link that was sent to you via email.', 'invoicing' );
56 56
                 }
57 57
 }
58 58
 
Please login to merge, or discard this patch.
templates/payment-forms/elements/file_upload.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -21,20 +21,20 @@
 block discarded – undo
21 21
 
22 22
 foreach ( $file_types as $file_type ) {
23 23
 
24
-	if ( isset( $all_types[ $file_type ] ) ) {
25
-		$types[]   = $all_types[ $file_type ];
26
-		$file_type = explode( '|', $file_type );
27
-
28
-		foreach ( $file_type as $type ) {
29
-			$type     = trim( $type );
30
-			$types[]  = ".$type";
31
-			$_types[] = $type;
32
-		}
24
+    if ( isset( $all_types[ $file_type ] ) ) {
25
+        $types[]   = $all_types[ $file_type ];
26
+        $file_type = explode( '|', $file_type );
27
+
28
+        foreach ( $file_type as $type ) {
29
+            $type     = trim( $type );
30
+            $types[]  = ".$type";
31
+            $_types[] = $type;
32
+        }
33 33
 }
34 34
 }
35 35
 
36 36
 if ( ! empty( $required ) ) {
37
-	$label .= "<span class='text-danger'> *</span>";
37
+    $label .= "<span class='text-danger'> *</span>";
38 38
 }
39 39
 
40 40
 ?>
Please login to merge, or discard this patch.
templates/payment-forms/cart.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@
 block discarded – undo
44 44
 
45 45
             // Display the item totals.
46 46
             foreach ( $form->get_items() as $item ) {
47
-			wpinv_get_template( 'payment-forms/cart-item.php', compact( 'form', 'item', 'columns' ) );
47
+            wpinv_get_template( 'payment-forms/cart-item.php', compact( 'form', 'item', 'columns' ) );
48 48
             }
49 49
 
50 50
             // Display the cart totals.
Please login to merge, or discard this patch.
templates/emails/invoice-items.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -44,12 +44,12 @@
 block discarded – undo
44 44
 
45 45
                 // Display the item totals.
46 46
                 foreach ( $invoice->get_items() as $item ) {
47
-				wpinv_get_template( 'emails/invoice-item.php', compact( 'invoice', 'item', 'columns' ) );
47
+                wpinv_get_template( 'emails/invoice-item.php', compact( 'invoice', 'item', 'columns' ) );
48 48
                 }
49 49
 
50 50
                 // Display the fee totals.
51 51
                 foreach ( $invoice->get_fees() as $fee ) {
52
-				wpinv_get_template( 'emails/fee-item.php', compact( 'invoice', 'fee', 'columns' ) );
52
+                wpinv_get_template( 'emails/fee-item.php', compact( 'invoice', 'fee', 'columns' ) );
53 53
                 }
54 54
 
55 55
             ?>
Please login to merge, or discard this patch.
templates/emails/wpinv-email-billing-details.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
 <a href="<?php echo esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), self_admin_url( 'user-edit.php' ) ) ); ?>"><?php echo esc_html( $invoice->get_user_full_name() ); ?></a>
21 21
                     <?php
22 22
 } else {
23
-					echo esc_html( $invoice->get_user_full_name() ); }
23
+                    echo esc_html( $invoice->get_user_full_name() ); }
24 24
 ?>
25 25
 </td>
26 26
             </tr>
Please login to merge, or discard this patch.
includes/class-getpaid-post-types.php 1 patch
Indentation   +295 added lines, -295 removed lines patch added patch discarded remove patch
@@ -15,321 +15,321 @@
 block discarded – undo
15 15
 class GetPaid_Post_Types {
16 16
 
17 17
     /**
18
-	 * Hook in methods.
19
-	 */
20
-	public function __construct() {
21
-		add_action( 'init', array( __CLASS__, 'register_post_types' ), 1 );
22
-		add_action( 'init', array( __CLASS__, 'register_post_status' ), 4 );
23
-		add_action( 'getpaid_flush_rewrite_rules', array( __CLASS__, 'flush_rewrite_rules' ) );
24
-		add_action( 'getpaid_after_register_post_types', array( __CLASS__, 'maybe_flush_rewrite_rules' ) );
25
-	}
18
+     * Hook in methods.
19
+     */
20
+    public function __construct() {
21
+        add_action( 'init', array( __CLASS__, 'register_post_types' ), 1 );
22
+        add_action( 'init', array( __CLASS__, 'register_post_status' ), 4 );
23
+        add_action( 'getpaid_flush_rewrite_rules', array( __CLASS__, 'flush_rewrite_rules' ) );
24
+        add_action( 'getpaid_after_register_post_types', array( __CLASS__, 'maybe_flush_rewrite_rules' ) );
25
+    }
26 26
 
27
-	/**
28
-	 * Register core post types.
29
-	 */
30
-	public static function register_post_types() {
27
+    /**
28
+     * Register core post types.
29
+     */
30
+    public static function register_post_types() {
31 31
 
32
-		if ( ! is_blog_installed() || post_type_exists( 'wpi_item' ) ) {
33
-			return;
34
-		}
32
+        if ( ! is_blog_installed() || post_type_exists( 'wpi_item' ) ) {
33
+            return;
34
+        }
35 35
 
36
-		$capabilities = wpinv_current_user_can_manage_invoicing();
36
+        $capabilities = wpinv_current_user_can_manage_invoicing();
37 37
 
38
-		// Fires before registering post types.
39
-		do_action( 'getpaid_register_post_types' );
38
+        // Fires before registering post types.
39
+        do_action( 'getpaid_register_post_types' );
40 40
 
41
-		// Register item post type.
42
-		register_post_type(
43
-			'wpi_item',
44
-			apply_filters(
45
-				'wpinv_register_post_type_invoice_item',
46
-				array(
47
-					'labels'            => array(
48
-						'name'               => _x( 'Items', 'post type general name', 'invoicing' ),
49
-						'singular_name'      => _x( 'Item', 'post type singular name', 'invoicing' ),
50
-						'menu_name'          => _x( 'Items', 'admin menu', 'invoicing' ),
51
-						'name_admin_bar'     => _x( 'Item', 'add new on admin bar', 'invoicing' ),
52
-						'add_new'            => _x( 'Add New', 'Item', 'invoicing' ),
53
-						'add_new_item'       => __( 'Add New Item', 'invoicing' ),
54
-						'new_item'           => __( 'New Item', 'invoicing' ),
55
-						'edit_item'          => __( 'Edit Item', 'invoicing' ),
56
-						'view_item'          => __( 'View Item', 'invoicing' ),
57
-						'all_items'          => __( 'Items', 'invoicing' ),
58
-						'search_items'       => __( 'Search items', 'invoicing' ),
59
-						'parent_item_colon'  => __( 'Parent item:', 'invoicing' ),
60
-						'not_found'          => __( 'No items found.', 'invoicing' ),
61
-						'not_found_in_trash' => __( 'No items found in trash.', 'invoicing' ),
62
-					),
63
-					'description'       => __( 'This is where you can add new invoice items.', 'invoicing' ),
64
-					'public'            => false,
65
-					'has_archive'       => false,
66
-					'_builtin'          => false,
67
-					'show_ui'           => true,
68
-					'show_in_menu'      => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false,
69
-					'show_in_nav_menus' => false,
70
-					'supports'          => array( 'title', 'excerpt', 'thumbnail' ),
71
-					'rewrite'           => false,
72
-					'query_var'         => false,
73
-					'map_meta_cap'      => true,
74
-					'show_in_admin_bar' => true,
75
-					'can_export'        => true,
76
-				)
77
-			)
78
-		);
41
+        // Register item post type.
42
+        register_post_type(
43
+            'wpi_item',
44
+            apply_filters(
45
+                'wpinv_register_post_type_invoice_item',
46
+                array(
47
+                    'labels'            => array(
48
+                        'name'               => _x( 'Items', 'post type general name', 'invoicing' ),
49
+                        'singular_name'      => _x( 'Item', 'post type singular name', 'invoicing' ),
50
+                        'menu_name'          => _x( 'Items', 'admin menu', 'invoicing' ),
51
+                        'name_admin_bar'     => _x( 'Item', 'add new on admin bar', 'invoicing' ),
52
+                        'add_new'            => _x( 'Add New', 'Item', 'invoicing' ),
53
+                        'add_new_item'       => __( 'Add New Item', 'invoicing' ),
54
+                        'new_item'           => __( 'New Item', 'invoicing' ),
55
+                        'edit_item'          => __( 'Edit Item', 'invoicing' ),
56
+                        'view_item'          => __( 'View Item', 'invoicing' ),
57
+                        'all_items'          => __( 'Items', 'invoicing' ),
58
+                        'search_items'       => __( 'Search items', 'invoicing' ),
59
+                        'parent_item_colon'  => __( 'Parent item:', 'invoicing' ),
60
+                        'not_found'          => __( 'No items found.', 'invoicing' ),
61
+                        'not_found_in_trash' => __( 'No items found in trash.', 'invoicing' ),
62
+                    ),
63
+                    'description'       => __( 'This is where you can add new invoice items.', 'invoicing' ),
64
+                    'public'            => false,
65
+                    'has_archive'       => false,
66
+                    '_builtin'          => false,
67
+                    'show_ui'           => true,
68
+                    'show_in_menu'      => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false,
69
+                    'show_in_nav_menus' => false,
70
+                    'supports'          => array( 'title', 'excerpt', 'thumbnail' ),
71
+                    'rewrite'           => false,
72
+                    'query_var'         => false,
73
+                    'map_meta_cap'      => true,
74
+                    'show_in_admin_bar' => true,
75
+                    'can_export'        => true,
76
+                )
77
+            )
78
+        );
79 79
 
80
-		// Register payment form post type.
81
-		register_post_type(
82
-			'wpi_payment_form',
83
-			apply_filters(
84
-				'wpinv_register_post_type_payment_form',
85
-				array(
86
-					'labels'            => array(
87
-						'name'               => _x( 'Payment Forms', 'post type general name', 'invoicing' ),
88
-						'singular_name'      => _x( 'Payment Form', 'post type singular name', 'invoicing' ),
89
-						'menu_name'          => _x( 'Payment Forms', 'admin menu', 'invoicing' ),
90
-						'name_admin_bar'     => _x( 'Payment Form', 'add new on admin bar', 'invoicing' ),
91
-						'add_new'            => _x( 'Add New', 'Payment Form', 'invoicing' ),
92
-						'add_new_item'       => __( 'Add New Payment Form', 'invoicing' ),
93
-						'new_item'           => __( 'New Payment Form', 'invoicing' ),
94
-						'edit_item'          => __( 'Edit Payment Form', 'invoicing' ),
95
-						'view_item'          => __( 'View Payment Form', 'invoicing' ),
96
-						'all_items'          => __( 'Payment Forms', 'invoicing' ),
97
-						'search_items'       => __( 'Search Payment Forms', 'invoicing' ),
98
-						'parent_item_colon'  => __( 'Parent Payment Forms:', 'invoicing' ),
99
-						'not_found'          => __( 'No payment forms found.', 'invoicing' ),
100
-						'not_found_in_trash' => __( 'No payment forms found in trash.', 'invoicing' ),
101
-					),
102
-					'description'       => __( 'Add new payment forms.', 'invoicing' ),
103
-					'public'            => false,
104
-					'show_ui'           => true,
105
-					'show_in_menu'      => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false,
106
-					'show_in_nav_menus' => false,
107
-					'query_var'         => false,
108
-					'rewrite'           => true,
109
-					'map_meta_cap'      => true,
110
-					'has_archive'       => false,
111
-					'hierarchical'      => false,
112
-					'menu_position'     => null,
113
-					'supports'          => array( 'title' ),
114
-					'menu_icon'         => 'dashicons-media-form',
115
-				)
116
-			)
117
-		);
80
+        // Register payment form post type.
81
+        register_post_type(
82
+            'wpi_payment_form',
83
+            apply_filters(
84
+                'wpinv_register_post_type_payment_form',
85
+                array(
86
+                    'labels'            => array(
87
+                        'name'               => _x( 'Payment Forms', 'post type general name', 'invoicing' ),
88
+                        'singular_name'      => _x( 'Payment Form', 'post type singular name', 'invoicing' ),
89
+                        'menu_name'          => _x( 'Payment Forms', 'admin menu', 'invoicing' ),
90
+                        'name_admin_bar'     => _x( 'Payment Form', 'add new on admin bar', 'invoicing' ),
91
+                        'add_new'            => _x( 'Add New', 'Payment Form', 'invoicing' ),
92
+                        'add_new_item'       => __( 'Add New Payment Form', 'invoicing' ),
93
+                        'new_item'           => __( 'New Payment Form', 'invoicing' ),
94
+                        'edit_item'          => __( 'Edit Payment Form', 'invoicing' ),
95
+                        'view_item'          => __( 'View Payment Form', 'invoicing' ),
96
+                        'all_items'          => __( 'Payment Forms', 'invoicing' ),
97
+                        'search_items'       => __( 'Search Payment Forms', 'invoicing' ),
98
+                        'parent_item_colon'  => __( 'Parent Payment Forms:', 'invoicing' ),
99
+                        'not_found'          => __( 'No payment forms found.', 'invoicing' ),
100
+                        'not_found_in_trash' => __( 'No payment forms found in trash.', 'invoicing' ),
101
+                    ),
102
+                    'description'       => __( 'Add new payment forms.', 'invoicing' ),
103
+                    'public'            => false,
104
+                    'show_ui'           => true,
105
+                    'show_in_menu'      => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false,
106
+                    'show_in_nav_menus' => false,
107
+                    'query_var'         => false,
108
+                    'rewrite'           => true,
109
+                    'map_meta_cap'      => true,
110
+                    'has_archive'       => false,
111
+                    'hierarchical'      => false,
112
+                    'menu_position'     => null,
113
+                    'supports'          => array( 'title' ),
114
+                    'menu_icon'         => 'dashicons-media-form',
115
+                )
116
+            )
117
+        );
118 118
 
119
-		// Register invoice post type.
120
-		register_post_type(
121
-			'wpi_invoice',
122
-			apply_filters(
123
-				'wpinv_register_post_type_invoice',
124
-				array(
125
-					'labels'              => array(
126
-						'name'                  => __( 'Invoices', 'invoicing' ),
127
-						'singular_name'         => __( 'Invoice', 'invoicing' ),
128
-						'all_items'             => __( 'Invoices', 'invoicing' ),
129
-						'menu_name'             => _x( 'Invoices', 'Admin menu name', 'invoicing' ),
130
-						'add_new'               => __( 'Add New', 'invoicing' ),
131
-						'add_new_item'          => __( 'Add new invoice', 'invoicing' ),
132
-						'edit'                  => __( 'Edit', 'invoicing' ),
133
-						'edit_item'             => __( 'Edit invoice', 'invoicing' ),
134
-						'new_item'              => __( 'New invoice', 'invoicing' ),
135
-						'view_item'             => __( 'View invoice', 'invoicing' ),
136
-						'view_items'            => __( 'View Invoices', 'invoicing' ),
137
-						'search_items'          => __( 'Search invoices', 'invoicing' ),
138
-						'not_found'             => __( 'No invoices found', 'invoicing' ),
139
-						'not_found_in_trash'    => __( 'No invoices found in trash', 'invoicing' ),
140
-						'parent'                => __( 'Parent invoice', 'invoicing' ),
141
-						'featured_image'        => __( 'Invoice image', 'invoicing' ),
142
-						'set_featured_image'    => __( 'Set invoice image', 'invoicing' ),
143
-						'remove_featured_image' => __( 'Remove invoice image', 'invoicing' ),
144
-						'use_featured_image'    => __( 'Use as invoice image', 'invoicing' ),
145
-						'insert_into_item'      => __( 'Insert into invoice', 'invoicing' ),
146
-						'uploaded_to_this_item' => __( 'Uploaded to this invoice', 'invoicing' ),
147
-						'filter_items_list'     => __( 'Filter invoices', 'invoicing' ),
148
-						'items_list_navigation' => __( 'Invoices navigation', 'invoicing' ),
149
-						'items_list'            => __( 'Invoices list', 'invoicing' ),
150
-					),
151
-					'description'         => __( 'This is where invoices are stored.', 'invoicing' ),
152
-					'public'              => true,
153
-					'has_archive'         => false,
154
-					'publicly_queryable'  => true,
155
-        			'exclude_from_search' => true,
156
-        			'show_ui'             => true,
157
-					'show_in_menu'        => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false,
158
-					'show_in_nav_menus'   => false,
159
-					'supports'            => array( 'title', 'author', 'excerpt' ),
160
-					'rewrite'             => array(
161
-						'slug'       => 'invoice',
162
-						'with_front' => false,
163
-					),
164
-					'query_var'           => false,
165
-					'map_meta_cap'        => true,
166
-					'show_in_admin_bar'   => true,
167
-					'can_export'          => true,
168
-					'hierarchical'        => false,
169
-					'menu_position'       => null,
170
-					'menu_icon'           => 'dashicons-media-spreadsheet',
171
-				)
172
-			)
173
-		);
119
+        // Register invoice post type.
120
+        register_post_type(
121
+            'wpi_invoice',
122
+            apply_filters(
123
+                'wpinv_register_post_type_invoice',
124
+                array(
125
+                    'labels'              => array(
126
+                        'name'                  => __( 'Invoices', 'invoicing' ),
127
+                        'singular_name'         => __( 'Invoice', 'invoicing' ),
128
+                        'all_items'             => __( 'Invoices', 'invoicing' ),
129
+                        'menu_name'             => _x( 'Invoices', 'Admin menu name', 'invoicing' ),
130
+                        'add_new'               => __( 'Add New', 'invoicing' ),
131
+                        'add_new_item'          => __( 'Add new invoice', 'invoicing' ),
132
+                        'edit'                  => __( 'Edit', 'invoicing' ),
133
+                        'edit_item'             => __( 'Edit invoice', 'invoicing' ),
134
+                        'new_item'              => __( 'New invoice', 'invoicing' ),
135
+                        'view_item'             => __( 'View invoice', 'invoicing' ),
136
+                        'view_items'            => __( 'View Invoices', 'invoicing' ),
137
+                        'search_items'          => __( 'Search invoices', 'invoicing' ),
138
+                        'not_found'             => __( 'No invoices found', 'invoicing' ),
139
+                        'not_found_in_trash'    => __( 'No invoices found in trash', 'invoicing' ),
140
+                        'parent'                => __( 'Parent invoice', 'invoicing' ),
141
+                        'featured_image'        => __( 'Invoice image', 'invoicing' ),
142
+                        'set_featured_image'    => __( 'Set invoice image', 'invoicing' ),
143
+                        'remove_featured_image' => __( 'Remove invoice image', 'invoicing' ),
144
+                        'use_featured_image'    => __( 'Use as invoice image', 'invoicing' ),
145
+                        'insert_into_item'      => __( 'Insert into invoice', 'invoicing' ),
146
+                        'uploaded_to_this_item' => __( 'Uploaded to this invoice', 'invoicing' ),
147
+                        'filter_items_list'     => __( 'Filter invoices', 'invoicing' ),
148
+                        'items_list_navigation' => __( 'Invoices navigation', 'invoicing' ),
149
+                        'items_list'            => __( 'Invoices list', 'invoicing' ),
150
+                    ),
151
+                    'description'         => __( 'This is where invoices are stored.', 'invoicing' ),
152
+                    'public'              => true,
153
+                    'has_archive'         => false,
154
+                    'publicly_queryable'  => true,
155
+                    'exclude_from_search' => true,
156
+                    'show_ui'             => true,
157
+                    'show_in_menu'        => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false,
158
+                    'show_in_nav_menus'   => false,
159
+                    'supports'            => array( 'title', 'author', 'excerpt' ),
160
+                    'rewrite'             => array(
161
+                        'slug'       => 'invoice',
162
+                        'with_front' => false,
163
+                    ),
164
+                    'query_var'           => false,
165
+                    'map_meta_cap'        => true,
166
+                    'show_in_admin_bar'   => true,
167
+                    'can_export'          => true,
168
+                    'hierarchical'        => false,
169
+                    'menu_position'       => null,
170
+                    'menu_icon'           => 'dashicons-media-spreadsheet',
171
+                )
172
+            )
173
+        );
174 174
 
175
-		// Register discount post type.
176
-		register_post_type(
177
-			'wpi_discount',
178
-			apply_filters(
179
-				'wpinv_register_post_type_discount',
180
-				array(
181
-					'labels'              => array(
182
-						'name'                  => __( 'Discounts', 'invoicing' ),
183
-						'singular_name'         => __( 'Discount', 'invoicing' ),
184
-						'all_items'             => __( 'Discounts', 'invoicing' ),
185
-						'menu_name'             => _x( 'Discounts', 'Admin menu name', 'invoicing' ),
186
-						'add_new'               => __( 'Add New', 'invoicing' ),
187
-						'add_new_item'          => __( 'Add new discount', 'invoicing' ),
188
-						'edit'                  => __( 'Edit', 'invoicing' ),
189
-						'edit_item'             => __( 'Edit discount', 'invoicing' ),
190
-						'new_item'              => __( 'New discount', 'invoicing' ),
191
-						'view_item'             => __( 'View discount', 'invoicing' ),
192
-						'view_items'            => __( 'View Discounts', 'invoicing' ),
193
-						'search_items'          => __( 'Search discounts', 'invoicing' ),
194
-						'not_found'             => __( 'No discounts found', 'invoicing' ),
195
-						'not_found_in_trash'    => __( 'No discounts found in trash', 'invoicing' ),
196
-						'parent'                => __( 'Parent discount', 'invoicing' ),
197
-						'featured_image'        => __( 'Discount image', 'invoicing' ),
198
-						'set_featured_image'    => __( 'Set discount image', 'invoicing' ),
199
-						'remove_featured_image' => __( 'Remove discount image', 'invoicing' ),
200
-						'use_featured_image'    => __( 'Use as discount image', 'invoicing' ),
201
-						'insert_into_item'      => __( 'Insert into discount', 'invoicing' ),
202
-						'uploaded_to_this_item' => __( 'Uploaded to this discount', 'invoicing' ),
203
-						'filter_items_list'     => __( 'Filter discounts', 'invoicing' ),
204
-						'items_list_navigation' => __( 'Discount navigation', 'invoicing' ),
205
-						'items_list'            => __( 'Discounts list', 'invoicing' ),
206
-					),
207
-					'description'         => __( 'This is where you can add new discounts that users can use in invoices.', 'invoicing' ),
208
-					'public'              => false,
209
-					'can_export'          => true,
210
-					'_builtin'            => false,
211
-					'publicly_queryable'  => false,
212
-					'exclude_from_search' => true,
213
-					'show_ui'             => true,
214
-					'show_in_menu'        => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false,
215
-					'query_var'           => false,
216
-					'rewrite'             => false,
217
-					'map_meta_cap'        => true,
218
-					'has_archive'         => false,
219
-					'hierarchical'        => false,
220
-					'supports'            => array( 'title', 'excerpt' ),
221
-					'show_in_nav_menus'   => false,
222
-					'show_in_admin_bar'   => true,
223
-					'menu_position'       => null,
224
-				)
225
-			)
226
-		);
175
+        // Register discount post type.
176
+        register_post_type(
177
+            'wpi_discount',
178
+            apply_filters(
179
+                'wpinv_register_post_type_discount',
180
+                array(
181
+                    'labels'              => array(
182
+                        'name'                  => __( 'Discounts', 'invoicing' ),
183
+                        'singular_name'         => __( 'Discount', 'invoicing' ),
184
+                        'all_items'             => __( 'Discounts', 'invoicing' ),
185
+                        'menu_name'             => _x( 'Discounts', 'Admin menu name', 'invoicing' ),
186
+                        'add_new'               => __( 'Add New', 'invoicing' ),
187
+                        'add_new_item'          => __( 'Add new discount', 'invoicing' ),
188
+                        'edit'                  => __( 'Edit', 'invoicing' ),
189
+                        'edit_item'             => __( 'Edit discount', 'invoicing' ),
190
+                        'new_item'              => __( 'New discount', 'invoicing' ),
191
+                        'view_item'             => __( 'View discount', 'invoicing' ),
192
+                        'view_items'            => __( 'View Discounts', 'invoicing' ),
193
+                        'search_items'          => __( 'Search discounts', 'invoicing' ),
194
+                        'not_found'             => __( 'No discounts found', 'invoicing' ),
195
+                        'not_found_in_trash'    => __( 'No discounts found in trash', 'invoicing' ),
196
+                        'parent'                => __( 'Parent discount', 'invoicing' ),
197
+                        'featured_image'        => __( 'Discount image', 'invoicing' ),
198
+                        'set_featured_image'    => __( 'Set discount image', 'invoicing' ),
199
+                        'remove_featured_image' => __( 'Remove discount image', 'invoicing' ),
200
+                        'use_featured_image'    => __( 'Use as discount image', 'invoicing' ),
201
+                        'insert_into_item'      => __( 'Insert into discount', 'invoicing' ),
202
+                        'uploaded_to_this_item' => __( 'Uploaded to this discount', 'invoicing' ),
203
+                        'filter_items_list'     => __( 'Filter discounts', 'invoicing' ),
204
+                        'items_list_navigation' => __( 'Discount navigation', 'invoicing' ),
205
+                        'items_list'            => __( 'Discounts list', 'invoicing' ),
206
+                    ),
207
+                    'description'         => __( 'This is where you can add new discounts that users can use in invoices.', 'invoicing' ),
208
+                    'public'              => false,
209
+                    'can_export'          => true,
210
+                    '_builtin'            => false,
211
+                    'publicly_queryable'  => false,
212
+                    'exclude_from_search' => true,
213
+                    'show_ui'             => true,
214
+                    'show_in_menu'        => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false,
215
+                    'query_var'           => false,
216
+                    'rewrite'             => false,
217
+                    'map_meta_cap'        => true,
218
+                    'has_archive'         => false,
219
+                    'hierarchical'        => false,
220
+                    'supports'            => array( 'title', 'excerpt' ),
221
+                    'show_in_nav_menus'   => false,
222
+                    'show_in_admin_bar'   => true,
223
+                    'menu_position'       => null,
224
+                )
225
+            )
226
+        );
227 227
 
228
-		do_action( 'getpaid_after_register_post_types' );
229
-	}
228
+        do_action( 'getpaid_after_register_post_types' );
229
+    }
230 230
 
231
-	/**
232
-	 * Register our custom post statuses.
233
-	 */
234
-	public static function register_post_status() {
231
+    /**
232
+     * Register our custom post statuses.
233
+     */
234
+    public static function register_post_status() {
235 235
 
236
-		$invoice_statuses = apply_filters(
237
-			'getpaid_register_invoice_post_statuses',
238
-			array(
236
+        $invoice_statuses = apply_filters(
237
+            'getpaid_register_invoice_post_statuses',
238
+            array(
239 239
 
240
-				'wpi-pending'    => array(
241
-					'label'                     => _x( 'Pending Payment', 'Invoice status', 'invoicing' ),
242
-        			'public'                    => true,
243
-        			'exclude_from_search'       => true,
244
-        			'show_in_admin_all_list'    => true,
245
-					'show_in_admin_status_list' => true,
246
-					/* translators: %s: number of invoices */
247
-        			'label_count'               => _n_noop( 'Pending Payment <span class="count">(%s)</span>', 'Pending Payment <span class="count">(%s)</span>', 'invoicing' ),
248
-				),
240
+                'wpi-pending'    => array(
241
+                    'label'                     => _x( 'Pending Payment', 'Invoice status', 'invoicing' ),
242
+                    'public'                    => true,
243
+                    'exclude_from_search'       => true,
244
+                    'show_in_admin_all_list'    => true,
245
+                    'show_in_admin_status_list' => true,
246
+                    /* translators: %s: number of invoices */
247
+                    'label_count'               => _n_noop( 'Pending Payment <span class="count">(%s)</span>', 'Pending Payment <span class="count">(%s)</span>', 'invoicing' ),
248
+                ),
249 249
 
250
-				'wpi-processing' => array(
251
-					'label'                     => _x( 'Processing', 'Invoice status', 'invoicing' ),
252
-        			'public'                    => true,
253
-        			'exclude_from_search'       => true,
254
-        			'show_in_admin_all_list'    => true,
255
-					'show_in_admin_status_list' => true,
256
-					/* translators: %s: number of invoices */
257
-        			'label_count'               => _n_noop( 'Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'invoicing' ),
258
-				),
250
+                'wpi-processing' => array(
251
+                    'label'                     => _x( 'Processing', 'Invoice status', 'invoicing' ),
252
+                    'public'                    => true,
253
+                    'exclude_from_search'       => true,
254
+                    'show_in_admin_all_list'    => true,
255
+                    'show_in_admin_status_list' => true,
256
+                    /* translators: %s: number of invoices */
257
+                    'label_count'               => _n_noop( 'Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'invoicing' ),
258
+                ),
259 259
 
260
-				'wpi-onhold'     => array(
261
-					'label'                     => _x( 'On Hold', 'Invoice status', 'invoicing' ),
262
-        			'public'                    => true,
263
-        			'exclude_from_search'       => true,
264
-        			'show_in_admin_all_list'    => true,
265
-					'show_in_admin_status_list' => true,
266
-					/* translators: %s: number of invoices */
267
-        			'label_count'               => _n_noop( 'On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'invoicing' ),
268
-				),
260
+                'wpi-onhold'     => array(
261
+                    'label'                     => _x( 'On Hold', 'Invoice status', 'invoicing' ),
262
+                    'public'                    => true,
263
+                    'exclude_from_search'       => true,
264
+                    'show_in_admin_all_list'    => true,
265
+                    'show_in_admin_status_list' => true,
266
+                    /* translators: %s: number of invoices */
267
+                    'label_count'               => _n_noop( 'On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'invoicing' ),
268
+                ),
269 269
 
270
-				'wpi-cancelled'  => array(
271
-					'label'                     => _x( 'Cancelled', 'Invoice status', 'invoicing' ),
272
-        			'public'                    => true,
273
-        			'exclude_from_search'       => true,
274
-        			'show_in_admin_all_list'    => true,
275
-					'show_in_admin_status_list' => true,
276
-					/* translators: %s: number of invoices */
277
-        			'label_count'               => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'invoicing' ),
278
-				),
270
+                'wpi-cancelled'  => array(
271
+                    'label'                     => _x( 'Cancelled', 'Invoice status', 'invoicing' ),
272
+                    'public'                    => true,
273
+                    'exclude_from_search'       => true,
274
+                    'show_in_admin_all_list'    => true,
275
+                    'show_in_admin_status_list' => true,
276
+                    /* translators: %s: number of invoices */
277
+                    'label_count'               => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'invoicing' ),
278
+                ),
279 279
 
280
-				'wpi-refunded'   => array(
281
-					'label'                     => _x( 'Refunded', 'Invoice status', 'invoicing' ),
282
-        			'public'                    => true,
283
-        			'exclude_from_search'       => true,
284
-        			'show_in_admin_all_list'    => true,
285
-					'show_in_admin_status_list' => true,
286
-					/* translators: %s: number of invoices */
287
-        			'label_count'               => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'invoicing' ),
288
-				),
280
+                'wpi-refunded'   => array(
281
+                    'label'                     => _x( 'Refunded', 'Invoice status', 'invoicing' ),
282
+                    'public'                    => true,
283
+                    'exclude_from_search'       => true,
284
+                    'show_in_admin_all_list'    => true,
285
+                    'show_in_admin_status_list' => true,
286
+                    /* translators: %s: number of invoices */
287
+                    'label_count'               => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'invoicing' ),
288
+                ),
289 289
 
290
-				'wpi-failed'     => array(
291
-					'label'                     => _x( 'Failed', 'Invoice status', 'invoicing' ),
292
-        			'public'                    => true,
293
-        			'exclude_from_search'       => true,
294
-        			'show_in_admin_all_list'    => true,
295
-					'show_in_admin_status_list' => true,
296
-					/* translators: %s: number of invoices */
297
-        			'label_count'               => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'invoicing' ),
298
-				),
290
+                'wpi-failed'     => array(
291
+                    'label'                     => _x( 'Failed', 'Invoice status', 'invoicing' ),
292
+                    'public'                    => true,
293
+                    'exclude_from_search'       => true,
294
+                    'show_in_admin_all_list'    => true,
295
+                    'show_in_admin_status_list' => true,
296
+                    /* translators: %s: number of invoices */
297
+                    'label_count'               => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'invoicing' ),
298
+                ),
299 299
 
300
-				'wpi-renewal'    => array(
301
-					'label'                     => _x( 'Renewal', 'Invoice status', 'invoicing' ),
302
-        			'public'                    => true,
303
-        			'exclude_from_search'       => true,
304
-        			'show_in_admin_all_list'    => true,
305
-					'show_in_admin_status_list' => true,
306
-					/* translators: %s: number of invoices */
307
-        			'label_count'               => _n_noop( 'Renewal <span class="count">(%s)</span>', 'Renewal <span class="count">(%s)</span>', 'invoicing' ),
308
-				),
309
-			)
310
-		);
300
+                'wpi-renewal'    => array(
301
+                    'label'                     => _x( 'Renewal', 'Invoice status', 'invoicing' ),
302
+                    'public'                    => true,
303
+                    'exclude_from_search'       => true,
304
+                    'show_in_admin_all_list'    => true,
305
+                    'show_in_admin_status_list' => true,
306
+                    /* translators: %s: number of invoices */
307
+                    'label_count'               => _n_noop( 'Renewal <span class="count">(%s)</span>', 'Renewal <span class="count">(%s)</span>', 'invoicing' ),
308
+                ),
309
+            )
310
+        );
311 311
 
312
-		foreach ( $invoice_statuses as $invoice_statuse => $args ) {
313
-			register_post_status( $invoice_statuse, $args );
314
-		}
315
-	}
312
+        foreach ( $invoice_statuses as $invoice_statuse => $args ) {
313
+            register_post_status( $invoice_statuse, $args );
314
+        }
315
+    }
316 316
 
317
-	/**
318
-	 * Flush rewrite rules.
319
-	 */
320
-	public static function flush_rewrite_rules() {
321
-		flush_rewrite_rules();
322
-	}
317
+    /**
318
+     * Flush rewrite rules.
319
+     */
320
+    public static function flush_rewrite_rules() {
321
+        flush_rewrite_rules();
322
+    }
323 323
 
324
-	/**
325
-	 * Flush rules to prevent 404.
326
-	 *
327
-	 */
328
-	public static function maybe_flush_rewrite_rules() {
329
-		if ( ! get_option( 'getpaid_flushed_rewrite_rules' ) ) {
330
-			update_option( 'getpaid_flushed_rewrite_rules', '1' );
331
-			self::flush_rewrite_rules();
332
-		}
333
-	}
324
+    /**
325
+     * Flush rules to prevent 404.
326
+     *
327
+     */
328
+    public static function maybe_flush_rewrite_rules() {
329
+        if ( ! get_option( 'getpaid_flushed_rewrite_rules' ) ) {
330
+            update_option( 'getpaid_flushed_rewrite_rules', '1' );
331
+            self::flush_rewrite_rules();
332
+        }
333
+    }
334 334
 
335 335
 }
Please login to merge, or discard this patch.
includes/data-stores/class-getpaid-payment-form-data-store.php 1 patch
Indentation   +169 added lines, -169 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 if ( ! defined( 'ABSPATH' ) ) {
7
-	exit;
7
+    exit;
8 8
 }
9 9
 
10 10
 /**
@@ -14,179 +14,179 @@  discard block
 block discarded – undo
14 14
  */
15 15
 class GetPaid_Payment_Form_Data_Store extends GetPaid_Data_Store_WP {
16 16
 
17
-	/**
18
-	 * Data stored in meta keys, but not considered "meta" for a form.
19
-	 *
20
-	 * @since 1.0.19
21
-	 * @var array
22
-	 */
23
-	protected $internal_meta_keys = array(
24
-		'wpinv_form_elements',
25
-		'wpinv_form_items',
26
-		'wpinv_form_earned',
27
-		'wpinv_form_refunded',
28
-		'wpinv_form_cancelled',
29
-		'wpinv_form_failed',
30
-	);
31
-
32
-	/**
33
-	 * A map of meta keys to data props.
34
-	 *
35
-	 * @since 1.0.19
36
-	 *
37
-	 * @var array
38
-	 */
39
-	protected $meta_key_to_props = array(
40
-		'wpinv_form_elements'  => 'elements',
41
-		'wpinv_form_items'     => 'items',
42
-		'wpinv_form_earned'    => 'earned',
43
-		'wpinv_form_refunded'  => 'refunded',
44
-		'wpinv_form_cancelled' => 'cancelled',
45
-		'wpinv_form_failed'    => 'failed',
46
-	);
47
-
48
-	/*
17
+    /**
18
+     * Data stored in meta keys, but not considered "meta" for a form.
19
+     *
20
+     * @since 1.0.19
21
+     * @var array
22
+     */
23
+    protected $internal_meta_keys = array(
24
+        'wpinv_form_elements',
25
+        'wpinv_form_items',
26
+        'wpinv_form_earned',
27
+        'wpinv_form_refunded',
28
+        'wpinv_form_cancelled',
29
+        'wpinv_form_failed',
30
+    );
31
+
32
+    /**
33
+     * A map of meta keys to data props.
34
+     *
35
+     * @since 1.0.19
36
+     *
37
+     * @var array
38
+     */
39
+    protected $meta_key_to_props = array(
40
+        'wpinv_form_elements'  => 'elements',
41
+        'wpinv_form_items'     => 'items',
42
+        'wpinv_form_earned'    => 'earned',
43
+        'wpinv_form_refunded'  => 'refunded',
44
+        'wpinv_form_cancelled' => 'cancelled',
45
+        'wpinv_form_failed'    => 'failed',
46
+    );
47
+
48
+    /*
49 49
 	|--------------------------------------------------------------------------
50 50
 	| CRUD Methods
51 51
 	|--------------------------------------------------------------------------
52 52
 	*/
53 53
 
54
-	/**
55
-	 * Method to create a new form in the database.
56
-	 *
57
-	 * @param GetPaid_Payment_Form $form Form object.
58
-	 */
59
-	public function create( &$form ) {
60
-		$form->set_version( WPINV_VERSION );
61
-		$form->set_date_created( current_time( 'mysql' ) );
62
-
63
-		// Create a new post.
64
-		$id = wp_insert_post(
65
-			apply_filters(
66
-				'getpaid_new_payment_form_data',
67
-				array(
68
-					'post_date'   => $form->get_date_created( 'edit' ),
69
-					'post_type'   => 'wpi_payment_form',
70
-					'post_status' => $this->get_post_status( $form ),
71
-					'ping_status' => 'closed',
72
-					'post_author' => $form->get_author( 'edit' ),
73
-					'post_title'  => $form->get_name( 'edit' ),
74
-				)
75
-			),
76
-			true
77
-		);
78
-
79
-		if ( $id && ! is_wp_error( $id ) ) {
80
-			$form->set_id( $id );
81
-			$this->update_post_meta( $form );
82
-			$form->save_meta_data();
83
-			$form->apply_changes();
84
-			$this->clear_caches( $form );
85
-			do_action( 'getpaid_create_payment_form', $form );
86
-			return true;
87
-		}
88
-
89
-		if ( is_wp_error( $id ) ) {
90
-			$form->last_error = $id->get_error_message();
91
-		}
92
-
93
-		return false;
94
-	}
95
-
96
-	/**
97
-	 * Method to read a form from the database.
98
-	 *
99
-	 * @param GetPaid_Payment_Form $form Form object.
100
-	 *
101
-	 */
102
-	public function read( &$form ) {
103
-
104
-		$form->set_defaults();
105
-		$form_object = get_post( $form->get_id() );
106
-
107
-		if ( ! $form->get_id() || ! $form_object || $form_object->post_type != 'wpi_payment_form' ) {
108
-			$form->last_error = __( 'Invalid form.', 'invoicing' );
109
-			$form->set_id( 0 );
110
-			return false;
111
-		}
112
-
113
-		$form->set_props(
114
-			array(
115
-				'date_created'  => 0 < $form_object->post_date ? $form_object->post_date : null,
116
-				'date_modified' => 0 < $form_object->post_modified ? $form_object->post_modified : null,
117
-				'status'        => $form_object->post_status,
118
-				'name'          => $form_object->post_title,
119
-				'author'        => $form_object->post_author,
120
-			)
121
-		);
122
-
123
-		$this->read_object_data( $form, $form_object );
124
-		$form->read_meta_data();
125
-		$form->set_object_read( true );
126
-		do_action( 'getpaid_read_payment_form', $form );
127
-
128
-	}
129
-
130
-	/**
131
-	 * Method to update a form in the database.
132
-	 *
133
-	 * @param GetPaid_Payment_Form $form Form object.
134
-	 */
135
-	public function update( &$form ) {
136
-		$form->save_meta_data();
137
-		$form->set_version( WPINV_VERSION );
138
-
139
-		if ( null === $form->get_date_created( 'edit' ) ) {
140
-			$form->set_date_created( current_time( 'mysql' ) );
141
-		}
142
-
143
-		// Grab the current status so we can compare.
144
-		$previous_status = get_post_status( $form->get_id() );
145
-
146
-		$changes = $form->get_changes();
147
-
148
-		// Only update the post when the post data changes.
149
-		if ( array_intersect( array( 'date_created', 'date_modified', 'status', 'name', 'author' ), array_keys( $changes ) ) ) {
150
-			$post_data = array(
151
-				'post_date'     => $form->get_date_created( 'edit' ),
152
-				'post_status'   => $form->get_status( 'edit' ),
153
-				'post_title'    => $form->get_name( 'edit' ),
154
-				'post_author'   => $form->get_author( 'edit' ),
155
-				'post_modified' => $form->get_date_modified( 'edit' ),
156
-			);
157
-
158
-			/**
159
-			 * When updating this object, to prevent infinite loops, use $wpdb
160
-			 * to update data, since wp_update_post spawns more calls to the
161
-			 * save_post action.
162
-			 *
163
-			 * This ensures hooks are fired by either WP itself (admin screen save),
164
-			 * or an update purely from CRUD.
165
-			 */
166
-			if ( doing_action( 'save_post' ) ) {
167
-				$GLOBALS['wpdb']->update( $GLOBALS['wpdb']->posts, $post_data, array( 'ID' => $form->get_id() ) );
168
-				clean_post_cache( $form->get_id() );
169
-			} else {
170
-				wp_update_post( array_merge( array( 'ID' => $form->get_id() ), $post_data ) );
171
-			}
172
-			$form->read_meta_data( true ); // Refresh internal meta data, in case things were hooked into `save_post` or another WP hook.
173
-		}
174
-		$this->update_post_meta( $form );
175
-		$form->apply_changes();
176
-		$this->clear_caches( $form );
177
-
178
-		// Fire a hook depending on the status - this should be considered a creation if it was previously draft status.
179
-		$new_status = $form->get_status( 'edit' );
180
-
181
-		if ( $new_status !== $previous_status && in_array( $previous_status, array( 'new', 'auto-draft', 'draft' ), true ) ) {
182
-			do_action( 'getpaid_new_payment_form', $form );
183
-		} else {
184
-			do_action( 'getpaid_update_payment_form', $form );
185
-		}
186
-
187
-	}
188
-
189
-	/*
54
+    /**
55
+     * Method to create a new form in the database.
56
+     *
57
+     * @param GetPaid_Payment_Form $form Form object.
58
+     */
59
+    public function create( &$form ) {
60
+        $form->set_version( WPINV_VERSION );
61
+        $form->set_date_created( current_time( 'mysql' ) );
62
+
63
+        // Create a new post.
64
+        $id = wp_insert_post(
65
+            apply_filters(
66
+                'getpaid_new_payment_form_data',
67
+                array(
68
+                    'post_date'   => $form->get_date_created( 'edit' ),
69
+                    'post_type'   => 'wpi_payment_form',
70
+                    'post_status' => $this->get_post_status( $form ),
71
+                    'ping_status' => 'closed',
72
+                    'post_author' => $form->get_author( 'edit' ),
73
+                    'post_title'  => $form->get_name( 'edit' ),
74
+                )
75
+            ),
76
+            true
77
+        );
78
+
79
+        if ( $id && ! is_wp_error( $id ) ) {
80
+            $form->set_id( $id );
81
+            $this->update_post_meta( $form );
82
+            $form->save_meta_data();
83
+            $form->apply_changes();
84
+            $this->clear_caches( $form );
85
+            do_action( 'getpaid_create_payment_form', $form );
86
+            return true;
87
+        }
88
+
89
+        if ( is_wp_error( $id ) ) {
90
+            $form->last_error = $id->get_error_message();
91
+        }
92
+
93
+        return false;
94
+    }
95
+
96
+    /**
97
+     * Method to read a form from the database.
98
+     *
99
+     * @param GetPaid_Payment_Form $form Form object.
100
+     *
101
+     */
102
+    public function read( &$form ) {
103
+
104
+        $form->set_defaults();
105
+        $form_object = get_post( $form->get_id() );
106
+
107
+        if ( ! $form->get_id() || ! $form_object || $form_object->post_type != 'wpi_payment_form' ) {
108
+            $form->last_error = __( 'Invalid form.', 'invoicing' );
109
+            $form->set_id( 0 );
110
+            return false;
111
+        }
112
+
113
+        $form->set_props(
114
+            array(
115
+                'date_created'  => 0 < $form_object->post_date ? $form_object->post_date : null,
116
+                'date_modified' => 0 < $form_object->post_modified ? $form_object->post_modified : null,
117
+                'status'        => $form_object->post_status,
118
+                'name'          => $form_object->post_title,
119
+                'author'        => $form_object->post_author,
120
+            )
121
+        );
122
+
123
+        $this->read_object_data( $form, $form_object );
124
+        $form->read_meta_data();
125
+        $form->set_object_read( true );
126
+        do_action( 'getpaid_read_payment_form', $form );
127
+
128
+    }
129
+
130
+    /**
131
+     * Method to update a form in the database.
132
+     *
133
+     * @param GetPaid_Payment_Form $form Form object.
134
+     */
135
+    public function update( &$form ) {
136
+        $form->save_meta_data();
137
+        $form->set_version( WPINV_VERSION );
138
+
139
+        if ( null === $form->get_date_created( 'edit' ) ) {
140
+            $form->set_date_created( current_time( 'mysql' ) );
141
+        }
142
+
143
+        // Grab the current status so we can compare.
144
+        $previous_status = get_post_status( $form->get_id() );
145
+
146
+        $changes = $form->get_changes();
147
+
148
+        // Only update the post when the post data changes.
149
+        if ( array_intersect( array( 'date_created', 'date_modified', 'status', 'name', 'author' ), array_keys( $changes ) ) ) {
150
+            $post_data = array(
151
+                'post_date'     => $form->get_date_created( 'edit' ),
152
+                'post_status'   => $form->get_status( 'edit' ),
153
+                'post_title'    => $form->get_name( 'edit' ),
154
+                'post_author'   => $form->get_author( 'edit' ),
155
+                'post_modified' => $form->get_date_modified( 'edit' ),
156
+            );
157
+
158
+            /**
159
+             * When updating this object, to prevent infinite loops, use $wpdb
160
+             * to update data, since wp_update_post spawns more calls to the
161
+             * save_post action.
162
+             *
163
+             * This ensures hooks are fired by either WP itself (admin screen save),
164
+             * or an update purely from CRUD.
165
+             */
166
+            if ( doing_action( 'save_post' ) ) {
167
+                $GLOBALS['wpdb']->update( $GLOBALS['wpdb']->posts, $post_data, array( 'ID' => $form->get_id() ) );
168
+                clean_post_cache( $form->get_id() );
169
+            } else {
170
+                wp_update_post( array_merge( array( 'ID' => $form->get_id() ), $post_data ) );
171
+            }
172
+            $form->read_meta_data( true ); // Refresh internal meta data, in case things were hooked into `save_post` or another WP hook.
173
+        }
174
+        $this->update_post_meta( $form );
175
+        $form->apply_changes();
176
+        $this->clear_caches( $form );
177
+
178
+        // Fire a hook depending on the status - this should be considered a creation if it was previously draft status.
179
+        $new_status = $form->get_status( 'edit' );
180
+
181
+        if ( $new_status !== $previous_status && in_array( $previous_status, array( 'new', 'auto-draft', 'draft' ), true ) ) {
182
+            do_action( 'getpaid_new_payment_form', $form );
183
+        } else {
184
+            do_action( 'getpaid_update_payment_form', $form );
185
+        }
186
+
187
+    }
188
+
189
+    /*
190 190
 	|--------------------------------------------------------------------------
191 191
 	| Additional Methods
192 192
 	|--------------------------------------------------------------------------
Please login to merge, or discard this patch.