Passed
Pull Request — master (#375)
by Brian
87:27
created
includes/data-stores/class-getpaid-data-store.php 2 patches
Indentation   +178 added lines, -178 removed lines patch added patch discarded remove patch
@@ -11,183 +11,183 @@
 block discarded – undo
11 11
  */
12 12
 class GetPaid_Data_Store {
13 13
 
14
-	/**
15
-	 * Contains an instance of the data store class that we are working with.
16
-	 *
17
-	 * @var GetPaid_Data_Store
18
-	 */
19
-	private $instance = null;
20
-
21
-	/**
22
-	 * Contains an array of default supported data stores.
23
-	 * Format of object name => class name.
24
-	 * Example: 'item' => 'GetPaid_Item_Data_Store'
25
-	 * You can also pass something like item-<type> for item stores and
26
-	 * that type will be used first when available, if a store is requested like
27
-	 * this and doesn't exist, then the store would fall back to 'item'.
28
-	 * Ran through `getpaid_data_stores`.
29
-	 *
30
-	 * @var array
31
-	 */
32
-	private $stores = array(
33
-		'item'         => 'GetPaid_Item_Data_Store',
34
-		'payment_form' => 'GetPaid_Payment_Form_Data_Store',
35
-	);
36
-
37
-	/**
38
-	 * Contains the name of the current data store's class name.
39
-	 *
40
-	 * @var string
41
-	 */
42
-	private $current_class_name = '';
43
-
44
-	/**
45
-	 * The object type this store works with.
46
-	 *
47
-	 * @var string
48
-	 */
49
-	private $object_type = '';
50
-
51
-	/**
52
-	 * Tells GetPaid_Data_Store which object
53
-	 * store we want to work with.
54
-	 *
55
-	 * @param string $object_type Name of object.
56
-	 */
57
-	public function __construct( $object_type ) {
58
-		$this->object_type = $object_type;
59
-		$this->stores      = apply_filters( 'getpaid_data_stores', $this->stores );
60
-
61
-		// If this object type can't be found, check to see if we can load one
62
-		// level up (so if item-type isn't found, we try item).
63
-		if ( ! array_key_exists( $object_type, $this->stores ) ) {
64
-			$pieces      = explode( '-', $object_type );
65
-			$object_type = $pieces[0];
66
-		}
67
-
68
-		if ( array_key_exists( $object_type, $this->stores ) ) {
69
-			$store = apply_filters( 'getpaid_' . $object_type . '_data_store', $this->stores[ $object_type ] );
70
-			if ( is_object( $store ) ) {
71
-				$this->current_class_name = get_class( $store );
72
-				$this->instance           = $store;
73
-			} else {
74
-				if ( ! class_exists( $store ) ) {
75
-					throw new Exception( __( 'Data store class does not exist.', 'invoicing' ) );
76
-				}
77
-				$this->current_class_name = $store;
78
-				$this->instance           = new $store();
79
-			}
80
-		} else {
81
-			throw new Exception( __( 'Invalid data store.', 'invoicing' ) );
82
-		}
83
-	}
84
-
85
-	/**
86
-	 * Only store the object type to avoid serializing the data store instance.
87
-	 *
88
-	 * @return array
89
-	 */
90
-	public function __sleep() {
91
-		return array( 'object_type' );
92
-	}
93
-
94
-	/**
95
-	 * Re-run the constructor with the object type.
96
-	 *
97
-	 * @throws Exception When validation fails.
98
-	 */
99
-	public function __wakeup() {
100
-		$this->__construct( $this->object_type );
101
-	}
102
-
103
-	/**
104
-	 * Loads a data store.
105
-	 *
106
-	 * @param string $object_type Name of object.
107
-	 *
108
-	 * @since 1.0.19
109
-	 * @throws Exception When validation fails.
110
-	 * @return GetPaid_Data_Store
111
-	 */
112
-	public static function load( $object_type ) {
113
-		return new GetPaid_Data_Store( $object_type );
114
-	}
115
-
116
-	/**
117
-	 * Returns the class name of the current data store.
118
-	 *
119
-	 * @since 1.0.19
120
-	 * @return string
121
-	 */
122
-	public function get_current_class_name() {
123
-		return $this->current_class_name;
124
-	}
125
-
126
-	/**
127
-	 * Returns the object type of the current data store.
128
-	 *
129
-	 * @since 1.0.19
130
-	 * @return string
131
-	 */
132
-	public function get_object_type() {
133
-		return $this->object_type;
134
-	}
135
-
136
-	/**
137
-	 * Reads an object from the data store.
138
-	 *
139
-	 * @since 1.0.19
140
-	 * @param GetPaid_Data $data GetPaid data instance.
141
-	 */
142
-	public function read( &$data ) {
143
-		$this->instance->read( $data );
144
-	}
145
-
146
-	/**
147
-	 * Create an object in the data store.
148
-	 *
149
-	 * @since 1.0.19
150
-	 * @param GetPaid_Data $data GetPaid data instance.
151
-	 */
152
-	public function create( &$data ) {
153
-		$this->instance->create( $data );
154
-	}
155
-
156
-	/**
157
-	 * Update an object in the data store.
158
-	 *
159
-	 * @since 1.0.19
160
-	 * @param GetPaid_Data $data GetPaid data instance.
161
-	 */
162
-	public function update( &$data ) {
163
-		$this->instance->update( $data );
164
-	}
165
-
166
-	/**
167
-	 * Delete an object from the data store.
168
-	 *
169
-	 * @since 1.0.19
170
-	 * @param GetPaid_Data $data GetPaid data instance.
171
-	 * @param array   $args Array of args to pass to the delete method.
172
-	 */
173
-	public function delete( &$data, $args = array() ) {
174
-		$this->instance->delete( $data, $args );
175
-	}
176
-
177
-	/**
178
-	 * Data stores can define additional function. This passes
179
-	 * through to the instance if that function exists.
180
-	 *
181
-	 * @since 1.0.19
182
-	 * @param string $method     Method.
183
-	 * @return mixed
184
-	 */
185
-	public function __call( $method, $parameters ) {
186
-		if ( is_callable( array( $this->instance, $method ) ) ) {
187
-			$object     = array_shift( $parameters );
188
-			$parameters = array_merge( array( &$object ), $parameters );
189
-			return call_user_func_array( array( $this->instance, $method ), $parameters );
190
-		}
191
-	}
14
+    /**
15
+     * Contains an instance of the data store class that we are working with.
16
+     *
17
+     * @var GetPaid_Data_Store
18
+     */
19
+    private $instance = null;
20
+
21
+    /**
22
+     * Contains an array of default supported data stores.
23
+     * Format of object name => class name.
24
+     * Example: 'item' => 'GetPaid_Item_Data_Store'
25
+     * You can also pass something like item-<type> for item stores and
26
+     * that type will be used first when available, if a store is requested like
27
+     * this and doesn't exist, then the store would fall back to 'item'.
28
+     * Ran through `getpaid_data_stores`.
29
+     *
30
+     * @var array
31
+     */
32
+    private $stores = array(
33
+        'item'         => 'GetPaid_Item_Data_Store',
34
+        'payment_form' => 'GetPaid_Payment_Form_Data_Store',
35
+    );
36
+
37
+    /**
38
+     * Contains the name of the current data store's class name.
39
+     *
40
+     * @var string
41
+     */
42
+    private $current_class_name = '';
43
+
44
+    /**
45
+     * The object type this store works with.
46
+     *
47
+     * @var string
48
+     */
49
+    private $object_type = '';
50
+
51
+    /**
52
+     * Tells GetPaid_Data_Store which object
53
+     * store we want to work with.
54
+     *
55
+     * @param string $object_type Name of object.
56
+     */
57
+    public function __construct( $object_type ) {
58
+        $this->object_type = $object_type;
59
+        $this->stores      = apply_filters( 'getpaid_data_stores', $this->stores );
60
+
61
+        // If this object type can't be found, check to see if we can load one
62
+        // level up (so if item-type isn't found, we try item).
63
+        if ( ! array_key_exists( $object_type, $this->stores ) ) {
64
+            $pieces      = explode( '-', $object_type );
65
+            $object_type = $pieces[0];
66
+        }
67
+
68
+        if ( array_key_exists( $object_type, $this->stores ) ) {
69
+            $store = apply_filters( 'getpaid_' . $object_type . '_data_store', $this->stores[ $object_type ] );
70
+            if ( is_object( $store ) ) {
71
+                $this->current_class_name = get_class( $store );
72
+                $this->instance           = $store;
73
+            } else {
74
+                if ( ! class_exists( $store ) ) {
75
+                    throw new Exception( __( 'Data store class does not exist.', 'invoicing' ) );
76
+                }
77
+                $this->current_class_name = $store;
78
+                $this->instance           = new $store();
79
+            }
80
+        } else {
81
+            throw new Exception( __( 'Invalid data store.', 'invoicing' ) );
82
+        }
83
+    }
84
+
85
+    /**
86
+     * Only store the object type to avoid serializing the data store instance.
87
+     *
88
+     * @return array
89
+     */
90
+    public function __sleep() {
91
+        return array( 'object_type' );
92
+    }
93
+
94
+    /**
95
+     * Re-run the constructor with the object type.
96
+     *
97
+     * @throws Exception When validation fails.
98
+     */
99
+    public function __wakeup() {
100
+        $this->__construct( $this->object_type );
101
+    }
102
+
103
+    /**
104
+     * Loads a data store.
105
+     *
106
+     * @param string $object_type Name of object.
107
+     *
108
+     * @since 1.0.19
109
+     * @throws Exception When validation fails.
110
+     * @return GetPaid_Data_Store
111
+     */
112
+    public static function load( $object_type ) {
113
+        return new GetPaid_Data_Store( $object_type );
114
+    }
115
+
116
+    /**
117
+     * Returns the class name of the current data store.
118
+     *
119
+     * @since 1.0.19
120
+     * @return string
121
+     */
122
+    public function get_current_class_name() {
123
+        return $this->current_class_name;
124
+    }
125
+
126
+    /**
127
+     * Returns the object type of the current data store.
128
+     *
129
+     * @since 1.0.19
130
+     * @return string
131
+     */
132
+    public function get_object_type() {
133
+        return $this->object_type;
134
+    }
135
+
136
+    /**
137
+     * Reads an object from the data store.
138
+     *
139
+     * @since 1.0.19
140
+     * @param GetPaid_Data $data GetPaid data instance.
141
+     */
142
+    public function read( &$data ) {
143
+        $this->instance->read( $data );
144
+    }
145
+
146
+    /**
147
+     * Create an object in the data store.
148
+     *
149
+     * @since 1.0.19
150
+     * @param GetPaid_Data $data GetPaid data instance.
151
+     */
152
+    public function create( &$data ) {
153
+        $this->instance->create( $data );
154
+    }
155
+
156
+    /**
157
+     * Update an object in the data store.
158
+     *
159
+     * @since 1.0.19
160
+     * @param GetPaid_Data $data GetPaid data instance.
161
+     */
162
+    public function update( &$data ) {
163
+        $this->instance->update( $data );
164
+    }
165
+
166
+    /**
167
+     * Delete an object from the data store.
168
+     *
169
+     * @since 1.0.19
170
+     * @param GetPaid_Data $data GetPaid data instance.
171
+     * @param array   $args Array of args to pass to the delete method.
172
+     */
173
+    public function delete( &$data, $args = array() ) {
174
+        $this->instance->delete( $data, $args );
175
+    }
176
+
177
+    /**
178
+     * Data stores can define additional function. This passes
179
+     * through to the instance if that function exists.
180
+     *
181
+     * @since 1.0.19
182
+     * @param string $method     Method.
183
+     * @return mixed
184
+     */
185
+    public function __call( $method, $parameters ) {
186
+        if ( is_callable( array( $this->instance, $method ) ) ) {
187
+            $object     = array_shift( $parameters );
188
+            $parameters = array_merge( array( &$object ), $parameters );
189
+            return call_user_func_array( array( $this->instance, $method ), $parameters );
190
+        }
191
+    }
192 192
 
193 193
 }
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Data store class.
@@ -54,31 +54,31 @@  discard block
 block discarded – undo
54 54
 	 *
55 55
 	 * @param string $object_type Name of object.
56 56
 	 */
57
-	public function __construct( $object_type ) {
57
+	public function __construct($object_type) {
58 58
 		$this->object_type = $object_type;
59
-		$this->stores      = apply_filters( 'getpaid_data_stores', $this->stores );
59
+		$this->stores      = apply_filters('getpaid_data_stores', $this->stores);
60 60
 
61 61
 		// If this object type can't be found, check to see if we can load one
62 62
 		// level up (so if item-type isn't found, we try item).
63
-		if ( ! array_key_exists( $object_type, $this->stores ) ) {
64
-			$pieces      = explode( '-', $object_type );
63
+		if (!array_key_exists($object_type, $this->stores)) {
64
+			$pieces      = explode('-', $object_type);
65 65
 			$object_type = $pieces[0];
66 66
 		}
67 67
 
68
-		if ( array_key_exists( $object_type, $this->stores ) ) {
69
-			$store = apply_filters( 'getpaid_' . $object_type . '_data_store', $this->stores[ $object_type ] );
70
-			if ( is_object( $store ) ) {
71
-				$this->current_class_name = get_class( $store );
68
+		if (array_key_exists($object_type, $this->stores)) {
69
+			$store = apply_filters('getpaid_' . $object_type . '_data_store', $this->stores[$object_type]);
70
+			if (is_object($store)) {
71
+				$this->current_class_name = get_class($store);
72 72
 				$this->instance           = $store;
73 73
 			} else {
74
-				if ( ! class_exists( $store ) ) {
75
-					throw new Exception( __( 'Data store class does not exist.', 'invoicing' ) );
74
+				if (!class_exists($store)) {
75
+					throw new Exception(__('Data store class does not exist.', 'invoicing'));
76 76
 				}
77 77
 				$this->current_class_name = $store;
78 78
 				$this->instance           = new $store();
79 79
 			}
80 80
 		} else {
81
-			throw new Exception( __( 'Invalid data store.', 'invoicing' ) );
81
+			throw new Exception(__('Invalid data store.', 'invoicing'));
82 82
 		}
83 83
 	}
84 84
 
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 	 * @return array
89 89
 	 */
90 90
 	public function __sleep() {
91
-		return array( 'object_type' );
91
+		return array('object_type');
92 92
 	}
93 93
 
94 94
 	/**
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 	 * @throws Exception When validation fails.
98 98
 	 */
99 99
 	public function __wakeup() {
100
-		$this->__construct( $this->object_type );
100
+		$this->__construct($this->object_type);
101 101
 	}
102 102
 
103 103
 	/**
@@ -109,8 +109,8 @@  discard block
 block discarded – undo
109 109
 	 * @throws Exception When validation fails.
110 110
 	 * @return GetPaid_Data_Store
111 111
 	 */
112
-	public static function load( $object_type ) {
113
-		return new GetPaid_Data_Store( $object_type );
112
+	public static function load($object_type) {
113
+		return new GetPaid_Data_Store($object_type);
114 114
 	}
115 115
 
116 116
 	/**
@@ -139,8 +139,8 @@  discard block
 block discarded – undo
139 139
 	 * @since 1.0.19
140 140
 	 * @param GetPaid_Data $data GetPaid data instance.
141 141
 	 */
142
-	public function read( &$data ) {
143
-		$this->instance->read( $data );
142
+	public function read(&$data) {
143
+		$this->instance->read($data);
144 144
 	}
145 145
 
146 146
 	/**
@@ -149,8 +149,8 @@  discard block
 block discarded – undo
149 149
 	 * @since 1.0.19
150 150
 	 * @param GetPaid_Data $data GetPaid data instance.
151 151
 	 */
152
-	public function create( &$data ) {
153
-		$this->instance->create( $data );
152
+	public function create(&$data) {
153
+		$this->instance->create($data);
154 154
 	}
155 155
 
156 156
 	/**
@@ -159,8 +159,8 @@  discard block
 block discarded – undo
159 159
 	 * @since 1.0.19
160 160
 	 * @param GetPaid_Data $data GetPaid data instance.
161 161
 	 */
162
-	public function update( &$data ) {
163
-		$this->instance->update( $data );
162
+	public function update(&$data) {
163
+		$this->instance->update($data);
164 164
 	}
165 165
 
166 166
 	/**
@@ -170,8 +170,8 @@  discard block
 block discarded – undo
170 170
 	 * @param GetPaid_Data $data GetPaid data instance.
171 171
 	 * @param array   $args Array of args to pass to the delete method.
172 172
 	 */
173
-	public function delete( &$data, $args = array() ) {
174
-		$this->instance->delete( $data, $args );
173
+	public function delete(&$data, $args = array()) {
174
+		$this->instance->delete($data, $args);
175 175
 	}
176 176
 
177 177
 	/**
@@ -182,11 +182,11 @@  discard block
 block discarded – undo
182 182
 	 * @param string $method     Method.
183 183
 	 * @return mixed
184 184
 	 */
185
-	public function __call( $method, $parameters ) {
186
-		if ( is_callable( array( $this->instance, $method ) ) ) {
187
-			$object     = array_shift( $parameters );
188
-			$parameters = array_merge( array( &$object ), $parameters );
189
-			return call_user_func_array( array( $this->instance, $method ), $parameters );
185
+	public function __call($method, $parameters) {
186
+		if (is_callable(array($this->instance, $method))) {
187
+			$object     = array_shift($parameters);
188
+			$parameters = array_merge(array(&$object), $parameters);
189
+			return call_user_func_array(array($this->instance, $method), $parameters);
190 190
 		}
191 191
 	}
192 192
 
Please login to merge, or discard this patch.
includes/class-getpaid-payment-form.php 2 patches
Indentation   +357 added lines, -357 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined( 'ABSPATH' ) ) {
3
-	exit;
3
+    exit;
4 4
 }
5 5
 
6 6
 /**
@@ -10,48 +10,48 @@  discard block
 block discarded – undo
10 10
 class GetPaid_Payment_Form  extends GetPaid_Data {
11 11
 
12 12
     /**
13
-	 * Which data store to load.
14
-	 *
15
-	 * @var string
16
-	 */
13
+     * Which data store to load.
14
+     *
15
+     * @var string
16
+     */
17 17
     protected $data_store_name = 'payment_form';
18 18
 
19 19
     /**
20
-	 * This is the name of this object type.
21
-	 *
22
-	 * @var string
23
-	 */
24
-	protected $object_type = 'payment_form';
20
+     * This is the name of this object type.
21
+     *
22
+     * @var string
23
+     */
24
+    protected $object_type = 'payment_form';
25 25
 
26 26
     /**
27
-	 * Form Data array. This is the core form data exposed in APIs.
28
-	 *
29
-	 * @since 1.0.19
30
-	 * @var array
31
-	 */
32
-	protected $data = array(
33
-		'status'               => 'draft',
34
-		'version'              => '',
35
-		'date_created'         => null,
27
+     * Form Data array. This is the core form data exposed in APIs.
28
+     *
29
+     * @since 1.0.19
30
+     * @var array
31
+     */
32
+    protected $data = array(
33
+        'status'               => 'draft',
34
+        'version'              => '',
35
+        'date_created'         => null,
36 36
         'date_modified'        => null,
37 37
         'name'                 => '',
38 38
         'author'               => 1,
39 39
         'elements'             => null,
40
-		'items'                => null,
41
-		'earned'               => 0,
42
-		'refunded'             => 0,
43
-		'cancelled'            => 0,
44
-		'failed'               => 0,
45
-	);
40
+        'items'                => null,
41
+        'earned'               => 0,
42
+        'refunded'             => 0,
43
+        'cancelled'            => 0,
44
+        'failed'               => 0,
45
+    );
46 46
 
47 47
     /**
48
-	 * Stores meta in cache for future reads.
49
-	 *
50
-	 * A group must be set to to enable caching.
51
-	 *
52
-	 * @var string
53
-	 */
54
-	protected $cache_group = 'getpaid_forms';
48
+     * Stores meta in cache for future reads.
49
+     *
50
+     * A group must be set to to enable caching.
51
+     *
52
+     * @var string
53
+     */
54
+    protected $cache_group = 'getpaid_forms';
55 55
 
56 56
     /**
57 57
      * Stores a reference to the original WP_Post object
@@ -61,32 +61,32 @@  discard block
 block discarded – undo
61 61
     protected $post = null;
62 62
 
63 63
     /**
64
-	 * Get the item if ID is passed, otherwise the item is new and empty.
65
-	 *
66
-	 * @param  int|object|WPInv_Item|WP_Post $item Item to read.
67
-	 */
68
-	public function __construct( $item = 0 ) {
69
-		parent::__construct( $item );
70
-
71
-		if ( is_numeric( $item ) && $item > 0 ) {
72
-			$this->set_id( $item );
73
-		} elseif ( $item instanceof self ) {
74
-			$this->set_id( $item->get_id() );
75
-		} elseif ( ! empty( $item->ID ) ) {
76
-			$this->set_id( $item->ID );
77
-		} else {
78
-			$this->set_object_read( true );
79
-		}
64
+     * Get the item if ID is passed, otherwise the item is new and empty.
65
+     *
66
+     * @param  int|object|WPInv_Item|WP_Post $item Item to read.
67
+     */
68
+    public function __construct( $item = 0 ) {
69
+        parent::__construct( $item );
70
+
71
+        if ( is_numeric( $item ) && $item > 0 ) {
72
+            $this->set_id( $item );
73
+        } elseif ( $item instanceof self ) {
74
+            $this->set_id( $item->get_id() );
75
+        } elseif ( ! empty( $item->ID ) ) {
76
+            $this->set_id( $item->ID );
77
+        } else {
78
+            $this->set_object_read( true );
79
+        }
80 80
 
81 81
         // Load the datastore.
82
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
82
+        $this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
83 83
 
84
-		if ( $this->get_id() > 0 ) {
84
+        if ( $this->get_id() > 0 ) {
85 85
             $this->post = get_post( $this->get_id() );
86
-			$this->data_store->read( $this );
86
+            $this->data_store->read( $this );
87 87
         }
88 88
 
89
-	}
89
+    }
90 90
 
91 91
     /*
92 92
 	|--------------------------------------------------------------------------
@@ -104,223 +104,223 @@  discard block
 block discarded – undo
104 104
     */
105 105
 
106 106
     /**
107
-	 * Get plugin version when the form was created.
108
-	 *
109
-	 * @since 1.0.19
110
-	 * @param  string $context View or edit context.
111
-	 * @return string
112
-	 */
113
-	public function get_version( $context = 'view' ) {
114
-		return $this->get_prop( 'version', $context );
107
+     * Get plugin version when the form was created.
108
+     *
109
+     * @since 1.0.19
110
+     * @param  string $context View or edit context.
111
+     * @return string
112
+     */
113
+    public function get_version( $context = 'view' ) {
114
+        return $this->get_prop( 'version', $context );
115 115
     }
116 116
 
117 117
     /**
118
-	 * Get date when the form was created.
119
-	 *
120
-	 * @since 1.0.19
121
-	 * @param  string $context View or edit context.
122
-	 * @return string
123
-	 */
124
-	public function get_date_created( $context = 'view' ) {
125
-		return $this->get_prop( 'date_created', $context );
118
+     * Get date when the form was created.
119
+     *
120
+     * @since 1.0.19
121
+     * @param  string $context View or edit context.
122
+     * @return string
123
+     */
124
+    public function get_date_created( $context = 'view' ) {
125
+        return $this->get_prop( 'date_created', $context );
126 126
     }
127 127
 
128 128
     /**
129
-	 * Get GMT date when the form was created.
130
-	 *
131
-	 * @since 1.0.19
132
-	 * @param  string $context View or edit context.
133
-	 * @return string
134
-	 */
135
-	public function get_date_created_gmt( $context = 'view' ) {
129
+     * Get GMT date when the form was created.
130
+     *
131
+     * @since 1.0.19
132
+     * @param  string $context View or edit context.
133
+     * @return string
134
+     */
135
+    public function get_date_created_gmt( $context = 'view' ) {
136 136
         $date = $this->get_date_created( $context );
137 137
 
138 138
         if ( $date ) {
139 139
             $date = get_gmt_from_date( $date );
140 140
         }
141
-		return $date;
141
+        return $date;
142 142
     }
143 143
 
144 144
     /**
145
-	 * Get date when the form was last modified.
146
-	 *
147
-	 * @since 1.0.19
148
-	 * @param  string $context View or edit context.
149
-	 * @return string
150
-	 */
151
-	public function get_date_modified( $context = 'view' ) {
152
-		return $this->get_prop( 'date_modified', $context );
145
+     * Get date when the form was last modified.
146
+     *
147
+     * @since 1.0.19
148
+     * @param  string $context View or edit context.
149
+     * @return string
150
+     */
151
+    public function get_date_modified( $context = 'view' ) {
152
+        return $this->get_prop( 'date_modified', $context );
153 153
     }
154 154
 
155 155
     /**
156
-	 * Get GMT date when the form was last modified.
157
-	 *
158
-	 * @since 1.0.19
159
-	 * @param  string $context View or edit context.
160
-	 * @return string
161
-	 */
162
-	public function get_date_modified_gmt( $context = 'view' ) {
156
+     * Get GMT date when the form was last modified.
157
+     *
158
+     * @since 1.0.19
159
+     * @param  string $context View or edit context.
160
+     * @return string
161
+     */
162
+    public function get_date_modified_gmt( $context = 'view' ) {
163 163
         $date = $this->get_date_modified( $context );
164 164
 
165 165
         if ( $date ) {
166 166
             $date = get_gmt_from_date( $date );
167 167
         }
168
-		return $date;
168
+        return $date;
169 169
     }
170 170
 
171 171
     /**
172
-	 * Get the form name.
173
-	 *
174
-	 * @since 1.0.19
175
-	 * @param  string $context View or edit context.
176
-	 * @return string
177
-	 */
178
-	public function get_name( $context = 'view' ) {
179
-		return $this->get_prop( 'name', $context );
172
+     * Get the form name.
173
+     *
174
+     * @since 1.0.19
175
+     * @param  string $context View or edit context.
176
+     * @return string
177
+     */
178
+    public function get_name( $context = 'view' ) {
179
+        return $this->get_prop( 'name', $context );
180
+    }
181
+
182
+    /**
183
+     * Alias of self::get_name().
184
+     *
185
+     * @since 1.0.19
186
+     * @param  string $context View or edit context.
187
+     * @return string
188
+     */
189
+    public function get_title( $context = 'view' ) {
190
+        return $this->get_name( $context );
180 191
     }
181 192
 
182 193
     /**
183
-	 * Alias of self::get_name().
184
-	 *
185
-	 * @since 1.0.19
186
-	 * @param  string $context View or edit context.
187
-	 * @return string
188
-	 */
189
-	public function get_title( $context = 'view' ) {
190
-		return $this->get_name( $context );
191
-	}
192
-
193
-    /**
194
-	 * Get the owner of the form.
195
-	 *
196
-	 * @since 1.0.19
197
-	 * @param  string $context View or edit context.
198
-	 * @return int
199
-	 */
200
-	public function get_author( $context = 'view' ) {
201
-		return (int) $this->get_prop( 'author', $context );
194
+     * Get the owner of the form.
195
+     *
196
+     * @since 1.0.19
197
+     * @param  string $context View or edit context.
198
+     * @return int
199
+     */
200
+    public function get_author( $context = 'view' ) {
201
+        return (int) $this->get_prop( 'author', $context );
202 202
     }
203 203
 
204 204
     /**
205
-	 * Get the elements that make up the form.
206
-	 *
207
-	 * @since 1.0.19
208
-	 * @param  string $context View or edit context.
209
-	 * @return array
210
-	 */
211
-	public function get_elements( $context = 'view' ) {
212
-		$elements = $this->get_prop( 'elements', $context );
205
+     * Get the elements that make up the form.
206
+     *
207
+     * @since 1.0.19
208
+     * @param  string $context View or edit context.
209
+     * @return array
210
+     */
211
+    public function get_elements( $context = 'view' ) {
212
+        $elements = $this->get_prop( 'elements', $context );
213 213
 
214
-		if ( empty( $elements ) || ! is_array( $elements ) ) {
214
+        if ( empty( $elements ) || ! is_array( $elements ) ) {
215 215
             return wpinv_get_data( 'sample-payment-form' );
216 216
         }
217 217
         return $elements;
218
-	}
219
-
220
-	/**
221
-	 * Get the items sold via the form.
222
-	 *
223
-	 * @since 1.0.19
224
-	 * @param  string $context View or edit context.
225
-	 * @return GetPaid_Form_Item[]
226
-	 */
227
-	public function get_items( $context = 'view' ) {
228
-		$items = $this->get_prop( 'items', $context );
229
-
230
-		if ( empty( $items ) || ! is_array( $items ) ) {
218
+    }
219
+
220
+    /**
221
+     * Get the items sold via the form.
222
+     *
223
+     * @since 1.0.19
224
+     * @param  string $context View or edit context.
225
+     * @return GetPaid_Form_Item[]
226
+     */
227
+    public function get_items( $context = 'view' ) {
228
+        $items = $this->get_prop( 'items', $context );
229
+
230
+        if ( empty( $items ) || ! is_array( $items ) ) {
231 231
             $items = wpinv_get_data( 'sample-payment-form-items' );
232 232
         }
233 233
 
234
-		// Convert the items.
235
-		$prepared = array();
236
-
237
-		foreach ( $items as $key => $value ) {
238
-
239
-			// $item_id => $quantity
240
-			if ( is_numeric( $key ) && is_numeric( $value ) ) {
241
-				$item   = new GetPaid_Form_Item( $key );
242
-
243
-				if ( $item->can_purchase() ) {
244
-					$item->set_quantity( $value );
245
-					$prepared[] = $item;
246
-				}
247
-
248
-				continue;
249
-			}
250
-
251
-			if ( is_array( $value ) && isset( $value['id'] ) ) {
252
-
253
-				$item = new GetPaid_Form_Item( $value['id'] );
254
-
255
-				if ( ! $item->can_purchase() ) {
256
-					continue;
257
-				}
258
-
259
-				// Cart items.
260
-				if ( isset( $value['subtotal'] ) ) {
261
-					$item->set_price( $value['subtotal'] );
262
-					$item->set_quantity( $value['quantity'] );
263
-					$prepared[] = $item;
264
-					continue;
265
-				}
266
-
267
-				// Payment form item.
268
-				$item->set_quantity( $value['quantity'] );
269
-				$item->set_allow_quantities( $value['allow_quantities'] );
270
-				$item->set_is_required( $value['required'] );
271
-				$item->set_custom_description( $value['description'] );
272
-				$prepared[] = $item;
273
-				continue;
274
-
275
-			}
276
-		}
277
-
278
-		return $prepared;
279
-	}
280
-
281
-	/**
282
-	 * Get the total amount earned via this form.
283
-	 *
284
-	 * @since 1.0.19
285
-	 * @param  string $context View or edit context.
286
-	 * @return array
287
-	 */
288
-	public function get_earned( $context = 'view' ) {
289
-		return $this->get_prop( 'earned', $context );
290
-	}
291
-
292
-	/**
293
-	 * Get the total amount refunded via this form.
294
-	 *
295
-	 * @since 1.0.19
296
-	 * @param  string $context View or edit context.
297
-	 * @return array
298
-	 */
299
-	public function get_refunded( $context = 'view' ) {
300
-		return $this->get_prop( 'refunded', $context );
301
-	}
302
-
303
-	/**
304
-	 * Get the total amount cancelled via this form.
305
-	 *
306
-	 * @since 1.0.19
307
-	 * @param  string $context View or edit context.
308
-	 * @return array
309
-	 */
310
-	public function get_cancelled( $context = 'view' ) {
311
-		return $this->get_prop( 'cancelled', $context );
312
-	}
313
-
314
-	/**
315
-	 * Get the total amount failed via this form.
316
-	 *
317
-	 * @since 1.0.19
318
-	 * @param  string $context View or edit context.
319
-	 * @return array
320
-	 */
321
-	public function get_failed( $context = 'view' ) {
322
-		return $this->get_prop( 'failed', $context );
323
-	}
234
+        // Convert the items.
235
+        $prepared = array();
236
+
237
+        foreach ( $items as $key => $value ) {
238
+
239
+            // $item_id => $quantity
240
+            if ( is_numeric( $key ) && is_numeric( $value ) ) {
241
+                $item   = new GetPaid_Form_Item( $key );
242
+
243
+                if ( $item->can_purchase() ) {
244
+                    $item->set_quantity( $value );
245
+                    $prepared[] = $item;
246
+                }
247
+
248
+                continue;
249
+            }
250
+
251
+            if ( is_array( $value ) && isset( $value['id'] ) ) {
252
+
253
+                $item = new GetPaid_Form_Item( $value['id'] );
254
+
255
+                if ( ! $item->can_purchase() ) {
256
+                    continue;
257
+                }
258
+
259
+                // Cart items.
260
+                if ( isset( $value['subtotal'] ) ) {
261
+                    $item->set_price( $value['subtotal'] );
262
+                    $item->set_quantity( $value['quantity'] );
263
+                    $prepared[] = $item;
264
+                    continue;
265
+                }
266
+
267
+                // Payment form item.
268
+                $item->set_quantity( $value['quantity'] );
269
+                $item->set_allow_quantities( $value['allow_quantities'] );
270
+                $item->set_is_required( $value['required'] );
271
+                $item->set_custom_description( $value['description'] );
272
+                $prepared[] = $item;
273
+                continue;
274
+
275
+            }
276
+        }
277
+
278
+        return $prepared;
279
+    }
280
+
281
+    /**
282
+     * Get the total amount earned via this form.
283
+     *
284
+     * @since 1.0.19
285
+     * @param  string $context View or edit context.
286
+     * @return array
287
+     */
288
+    public function get_earned( $context = 'view' ) {
289
+        return $this->get_prop( 'earned', $context );
290
+    }
291
+
292
+    /**
293
+     * Get the total amount refunded via this form.
294
+     *
295
+     * @since 1.0.19
296
+     * @param  string $context View or edit context.
297
+     * @return array
298
+     */
299
+    public function get_refunded( $context = 'view' ) {
300
+        return $this->get_prop( 'refunded', $context );
301
+    }
302
+
303
+    /**
304
+     * Get the total amount cancelled via this form.
305
+     *
306
+     * @since 1.0.19
307
+     * @param  string $context View or edit context.
308
+     * @return array
309
+     */
310
+    public function get_cancelled( $context = 'view' ) {
311
+        return $this->get_prop( 'cancelled', $context );
312
+    }
313
+
314
+    /**
315
+     * Get the total amount failed via this form.
316
+     *
317
+     * @since 1.0.19
318
+     * @param  string $context View or edit context.
319
+     * @return array
320
+     */
321
+    public function get_failed( $context = 'view' ) {
322
+        return $this->get_prop( 'failed', $context );
323
+    }
324 324
 
325 325
     /*
326 326
 	|--------------------------------------------------------------------------
@@ -333,22 +333,22 @@  discard block
 block discarded – undo
333 333
     */
334 334
 
335 335
     /**
336
-	 * Set plugin version when the item was created.
337
-	 *
338
-	 * @since 1.0.19
339
-	 */
340
-	public function set_version( $value ) {
341
-		$this->set_prop( 'version', $value );
336
+     * Set plugin version when the item was created.
337
+     *
338
+     * @since 1.0.19
339
+     */
340
+    public function set_version( $value ) {
341
+        $this->set_prop( 'version', $value );
342 342
     }
343 343
 
344 344
     /**
345
-	 * Set date when the item was created.
346
-	 *
347
-	 * @since 1.0.19
348
-	 * @param string $value Value to set.
345
+     * Set date when the item was created.
346
+     *
347
+     * @since 1.0.19
348
+     * @param string $value Value to set.
349 349
      * @return bool Whether or not the date was set.
350
-	 */
351
-	public function set_date_created( $value ) {
350
+     */
351
+    public function set_date_created( $value ) {
352 352
         $date = strtotime( $value );
353 353
 
354 354
         if ( $date ) {
@@ -361,13 +361,13 @@  discard block
 block discarded – undo
361 361
     }
362 362
 
363 363
     /**
364
-	 * Set date when the item was last modified.
365
-	 *
366
-	 * @since 1.0.19
367
-	 * @param string $value Value to set.
364
+     * Set date when the item was last modified.
365
+     *
366
+     * @since 1.0.19
367
+     * @param string $value Value to set.
368 368
      * @return bool Whether or not the date was set.
369
-	 */
370
-	public function set_date_modified( $value ) {
369
+     */
370
+    public function set_date_modified( $value ) {
371 371
         $date = strtotime( $value );
372 372
 
373 373
         if ( $date ) {
@@ -380,118 +380,118 @@  discard block
 block discarded – undo
380 380
     }
381 381
 
382 382
     /**
383
-	 * Set the item name.
384
-	 *
385
-	 * @since 1.0.19
386
-	 * @param  string $value New name.
387
-	 */
388
-	public function set_name( $value ) {
389
-		$this->set_prop( 'name', sanitize_text_field( $value ) );
383
+     * Set the item name.
384
+     *
385
+     * @since 1.0.19
386
+     * @param  string $value New name.
387
+     */
388
+    public function set_name( $value ) {
389
+        $this->set_prop( 'name', sanitize_text_field( $value ) );
390 390
     }
391 391
 
392 392
     /**
393
-	 * Alias of self::set_name().
394
-	 *
395
-	 * @since 1.0.19
396
-	 * @param  string $value New name.
397
-	 */
398
-	public function set_title( $value ) {
399
-		$this->set_name( $value );
393
+     * Alias of self::set_name().
394
+     *
395
+     * @since 1.0.19
396
+     * @param  string $value New name.
397
+     */
398
+    public function set_title( $value ) {
399
+        $this->set_name( $value );
400
+    }
401
+
402
+    /**
403
+     * Set the owner of the item.
404
+     *
405
+     * @since 1.0.19
406
+     * @param  int $value New author.
407
+     */
408
+    public function set_author( $value ) {
409
+        $this->set_prop( 'author', (int) $value );
410
+    }
411
+
412
+    /**
413
+     * Set the form elements.
414
+     *
415
+     * @since 1.0.19
416
+     * @param  array $value Form elements.
417
+     */
418
+    public function set_elements( $value ) {
419
+        if ( is_array( $value ) ) {
420
+            $this->set_prop( 'elements', $value );
421
+        }
400 422
     }
401 423
 
402 424
     /**
403
-	 * Set the owner of the item.
404
-	 *
405
-	 * @since 1.0.19
406
-	 * @param  int $value New author.
407
-	 */
408
-	public function set_author( $value ) {
409
-		$this->set_prop( 'author', (int) $value );
410
-	}
411
-
412
-	/**
413
-	 * Set the form elements.
414
-	 *
415
-	 * @since 1.0.19
416
-	 * @param  array $value Form elements.
417
-	 */
418
-	public function set_elements( $value ) {
419
-		if ( is_array( $value ) ) {
420
-			$this->set_prop( 'elements', $value );
421
-		}
422
-	}
423
-
424
-	/**
425
-	 * Set the form items.
426
-	 *
427
-	 * @since 1.0.19
428
-	 * @param  array $value Form elements.
429
-	 */
430
-	public function set_items( $value ) {
431
-		if ( is_array( $value ) ) {
432
-			$this->set_prop( 'items', $value );
433
-		}
434
-	}
425
+     * Set the form items.
426
+     *
427
+     * @since 1.0.19
428
+     * @param  array $value Form elements.
429
+     */
430
+    public function set_items( $value ) {
431
+        if ( is_array( $value ) ) {
432
+            $this->set_prop( 'items', $value );
433
+        }
434
+    }
435 435
 	
436
-	/**
437
-	 * Set the total amount earned via this form.
438
-	 *
439
-	 * @since 1.0.19
440
-	 * @param  float $value Amount earned.
441
-	 * @return array
442
-	 */
443
-	public function set_earned( $value ) {
444
-		return $this->set_prop( 'earned', $value );
445
-	}
446
-
447
-	/**
448
-	 * Set the total amount refunded via this form.
449
-	 *
450
-	 * @since 1.0.19
451
-	 * @param  float $value Amount refunded.
452
-	 * @return array
453
-	 */
454
-	public function set_refunded( $value ) {
455
-		return $this->set_prop( 'refunded', $value );
456
-	}
457
-
458
-	/**
459
-	 * Set the total amount cancelled via this form.
460
-	 *
461
-	 * @since 1.0.19
462
-	 * @param  float $value Amount cancelled.
463
-	 * @return array
464
-	 */
465
-	public function set_cancelled( $value ) {
466
-		return $this->set_prop( 'cancelled', $value );
467
-	}
468
-
469
-	/**
470
-	 * Set the total amount failed via this form.
471
-	 *
472
-	 * @since 1.0.19
473
-	 * @param  float $value Amount cancelled.
474
-	 * @return array
475
-	 */
476
-	public function set_failed( $value ) {
477
-		return $this->set_prop( 'failed', $value );
478
-	}
436
+    /**
437
+     * Set the total amount earned via this form.
438
+     *
439
+     * @since 1.0.19
440
+     * @param  float $value Amount earned.
441
+     * @return array
442
+     */
443
+    public function set_earned( $value ) {
444
+        return $this->set_prop( 'earned', $value );
445
+    }
446
+
447
+    /**
448
+     * Set the total amount refunded via this form.
449
+     *
450
+     * @since 1.0.19
451
+     * @param  float $value Amount refunded.
452
+     * @return array
453
+     */
454
+    public function set_refunded( $value ) {
455
+        return $this->set_prop( 'refunded', $value );
456
+    }
457
+
458
+    /**
459
+     * Set the total amount cancelled via this form.
460
+     *
461
+     * @since 1.0.19
462
+     * @param  float $value Amount cancelled.
463
+     * @return array
464
+     */
465
+    public function set_cancelled( $value ) {
466
+        return $this->set_prop( 'cancelled', $value );
467
+    }
468
+
469
+    /**
470
+     * Set the total amount failed via this form.
471
+     *
472
+     * @since 1.0.19
473
+     * @param  float $value Amount cancelled.
474
+     * @return array
475
+     */
476
+    public function set_failed( $value ) {
477
+        return $this->set_prop( 'failed', $value );
478
+    }
479 479
 
480 480
     /**
481 481
      * Create an item. For backwards compatibilty.
482 482
      *
483 483
      * @deprecated
484
-	 * @return int item id
484
+     * @return int item id
485 485
      */
486 486
     public function create( $data = array() ) {
487 487
 
488
-		// Set the properties.
489
-		if ( is_array( $data ) ) {
490
-			$this->set_props( $data );
491
-		}
488
+        // Set the properties.
489
+        if ( is_array( $data ) ) {
490
+            $this->set_props( $data );
491
+        }
492 492
 
493
-		// Save the item.
494
-		return $this->save();
493
+        // Save the item.
494
+        return $this->save();
495 495
 
496 496
     }
497 497
 
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
      * Updates an item. For backwards compatibilty.
500 500
      *
501 501
      * @deprecated
502
-	 * @return int item id
502
+     * @return int item id
503 503
      */
504 504
     public function update( $data = array() ) {
505 505
         return $this->create( $data );
@@ -515,22 +515,22 @@  discard block
 block discarded – undo
515 515
 	*/
516 516
 
517 517
     /**
518
-	 * Checks whether this is the default payment form.
519
-	 *
520
-	 * @since 1.0.19
521
-	 * @return bool
522
-	 */
518
+     * Checks whether this is the default payment form.
519
+     *
520
+     * @since 1.0.19
521
+     * @return bool
522
+     */
523 523
     public function is_default() {
524 524
         $is_default = $this->get_id() == wpinv_get_default_payment_form();
525 525
         return (bool) apply_filters( 'wpinv_is_default_payment_form', $is_default, $this->ID, $this );
526
-	}
526
+    }
527 527
 
528 528
     /**
529
-	 * Checks whether the form is active.
530
-	 *
531
-	 * @since 1.0.19
532
-	 * @return bool
533
-	 */
529
+     * Checks whether the form is active.
530
+     *
531
+     * @since 1.0.19
532
+     * @return bool
533
+     */
534 534
     public function is_active() {
535 535
         $is_active = null !== $this->get_id();
536 536
 
Please login to merge, or discard this patch.
Spacing   +103 added lines, -103 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if (!defined('ABSPATH')) {
3 3
 	exit;
4 4
 }
5 5
 
@@ -65,25 +65,25 @@  discard block
 block discarded – undo
65 65
 	 *
66 66
 	 * @param  int|object|WPInv_Item|WP_Post $item Item to read.
67 67
 	 */
68
-	public function __construct( $item = 0 ) {
69
-		parent::__construct( $item );
68
+	public function __construct($item = 0) {
69
+		parent::__construct($item);
70 70
 
71
-		if ( is_numeric( $item ) && $item > 0 ) {
72
-			$this->set_id( $item );
73
-		} elseif ( $item instanceof self ) {
74
-			$this->set_id( $item->get_id() );
75
-		} elseif ( ! empty( $item->ID ) ) {
76
-			$this->set_id( $item->ID );
71
+		if (is_numeric($item) && $item > 0) {
72
+			$this->set_id($item);
73
+		} elseif ($item instanceof self) {
74
+			$this->set_id($item->get_id());
75
+		} elseif (!empty($item->ID)) {
76
+			$this->set_id($item->ID);
77 77
 		} else {
78
-			$this->set_object_read( true );
78
+			$this->set_object_read(true);
79 79
 		}
80 80
 
81 81
         // Load the datastore.
82
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
82
+		$this->data_store = GetPaid_Data_Store::load($this->data_store_name);
83 83
 
84
-		if ( $this->get_id() > 0 ) {
85
-            $this->post = get_post( $this->get_id() );
86
-			$this->data_store->read( $this );
84
+		if ($this->get_id() > 0) {
85
+            $this->post = get_post($this->get_id());
86
+			$this->data_store->read($this);
87 87
         }
88 88
 
89 89
 	}
@@ -110,8 +110,8 @@  discard block
 block discarded – undo
110 110
 	 * @param  string $context View or edit context.
111 111
 	 * @return string
112 112
 	 */
113
-	public function get_version( $context = 'view' ) {
114
-		return $this->get_prop( 'version', $context );
113
+	public function get_version($context = 'view') {
114
+		return $this->get_prop('version', $context);
115 115
     }
116 116
 
117 117
     /**
@@ -121,8 +121,8 @@  discard block
 block discarded – undo
121 121
 	 * @param  string $context View or edit context.
122 122
 	 * @return string
123 123
 	 */
124
-	public function get_date_created( $context = 'view' ) {
125
-		return $this->get_prop( 'date_created', $context );
124
+	public function get_date_created($context = 'view') {
125
+		return $this->get_prop('date_created', $context);
126 126
     }
127 127
 
128 128
     /**
@@ -132,11 +132,11 @@  discard block
 block discarded – undo
132 132
 	 * @param  string $context View or edit context.
133 133
 	 * @return string
134 134
 	 */
135
-	public function get_date_created_gmt( $context = 'view' ) {
136
-        $date = $this->get_date_created( $context );
135
+	public function get_date_created_gmt($context = 'view') {
136
+        $date = $this->get_date_created($context);
137 137
 
138
-        if ( $date ) {
139
-            $date = get_gmt_from_date( $date );
138
+        if ($date) {
139
+            $date = get_gmt_from_date($date);
140 140
         }
141 141
 		return $date;
142 142
     }
@@ -148,8 +148,8 @@  discard block
 block discarded – undo
148 148
 	 * @param  string $context View or edit context.
149 149
 	 * @return string
150 150
 	 */
151
-	public function get_date_modified( $context = 'view' ) {
152
-		return $this->get_prop( 'date_modified', $context );
151
+	public function get_date_modified($context = 'view') {
152
+		return $this->get_prop('date_modified', $context);
153 153
     }
154 154
 
155 155
     /**
@@ -159,11 +159,11 @@  discard block
 block discarded – undo
159 159
 	 * @param  string $context View or edit context.
160 160
 	 * @return string
161 161
 	 */
162
-	public function get_date_modified_gmt( $context = 'view' ) {
163
-        $date = $this->get_date_modified( $context );
162
+	public function get_date_modified_gmt($context = 'view') {
163
+        $date = $this->get_date_modified($context);
164 164
 
165
-        if ( $date ) {
166
-            $date = get_gmt_from_date( $date );
165
+        if ($date) {
166
+            $date = get_gmt_from_date($date);
167 167
         }
168 168
 		return $date;
169 169
     }
@@ -175,8 +175,8 @@  discard block
 block discarded – undo
175 175
 	 * @param  string $context View or edit context.
176 176
 	 * @return string
177 177
 	 */
178
-	public function get_name( $context = 'view' ) {
179
-		return $this->get_prop( 'name', $context );
178
+	public function get_name($context = 'view') {
179
+		return $this->get_prop('name', $context);
180 180
     }
181 181
 
182 182
     /**
@@ -186,8 +186,8 @@  discard block
 block discarded – undo
186 186
 	 * @param  string $context View or edit context.
187 187
 	 * @return string
188 188
 	 */
189
-	public function get_title( $context = 'view' ) {
190
-		return $this->get_name( $context );
189
+	public function get_title($context = 'view') {
190
+		return $this->get_name($context);
191 191
 	}
192 192
 
193 193
     /**
@@ -197,8 +197,8 @@  discard block
 block discarded – undo
197 197
 	 * @param  string $context View or edit context.
198 198
 	 * @return int
199 199
 	 */
200
-	public function get_author( $context = 'view' ) {
201
-		return (int) $this->get_prop( 'author', $context );
200
+	public function get_author($context = 'view') {
201
+		return (int) $this->get_prop('author', $context);
202 202
     }
203 203
 
204 204
     /**
@@ -208,11 +208,11 @@  discard block
 block discarded – undo
208 208
 	 * @param  string $context View or edit context.
209 209
 	 * @return array
210 210
 	 */
211
-	public function get_elements( $context = 'view' ) {
212
-		$elements = $this->get_prop( 'elements', $context );
211
+	public function get_elements($context = 'view') {
212
+		$elements = $this->get_prop('elements', $context);
213 213
 
214
-		if ( empty( $elements ) || ! is_array( $elements ) ) {
215
-            return wpinv_get_data( 'sample-payment-form' );
214
+		if (empty($elements) || !is_array($elements)) {
215
+            return wpinv_get_data('sample-payment-form');
216 216
         }
217 217
         return $elements;
218 218
 	}
@@ -224,51 +224,51 @@  discard block
 block discarded – undo
224 224
 	 * @param  string $context View or edit context.
225 225
 	 * @return GetPaid_Form_Item[]
226 226
 	 */
227
-	public function get_items( $context = 'view' ) {
228
-		$items = $this->get_prop( 'items', $context );
227
+	public function get_items($context = 'view') {
228
+		$items = $this->get_prop('items', $context);
229 229
 
230
-		if ( empty( $items ) || ! is_array( $items ) ) {
231
-            $items = wpinv_get_data( 'sample-payment-form-items' );
230
+		if (empty($items) || !is_array($items)) {
231
+            $items = wpinv_get_data('sample-payment-form-items');
232 232
         }
233 233
 
234 234
 		// Convert the items.
235 235
 		$prepared = array();
236 236
 
237
-		foreach ( $items as $key => $value ) {
237
+		foreach ($items as $key => $value) {
238 238
 
239 239
 			// $item_id => $quantity
240
-			if ( is_numeric( $key ) && is_numeric( $value ) ) {
241
-				$item   = new GetPaid_Form_Item( $key );
240
+			if (is_numeric($key) && is_numeric($value)) {
241
+				$item = new GetPaid_Form_Item($key);
242 242
 
243
-				if ( $item->can_purchase() ) {
244
-					$item->set_quantity( $value );
243
+				if ($item->can_purchase()) {
244
+					$item->set_quantity($value);
245 245
 					$prepared[] = $item;
246 246
 				}
247 247
 
248 248
 				continue;
249 249
 			}
250 250
 
251
-			if ( is_array( $value ) && isset( $value['id'] ) ) {
251
+			if (is_array($value) && isset($value['id'])) {
252 252
 
253
-				$item = new GetPaid_Form_Item( $value['id'] );
253
+				$item = new GetPaid_Form_Item($value['id']);
254 254
 
255
-				if ( ! $item->can_purchase() ) {
255
+				if (!$item->can_purchase()) {
256 256
 					continue;
257 257
 				}
258 258
 
259 259
 				// Cart items.
260
-				if ( isset( $value['subtotal'] ) ) {
261
-					$item->set_price( $value['subtotal'] );
262
-					$item->set_quantity( $value['quantity'] );
260
+				if (isset($value['subtotal'])) {
261
+					$item->set_price($value['subtotal']);
262
+					$item->set_quantity($value['quantity']);
263 263
 					$prepared[] = $item;
264 264
 					continue;
265 265
 				}
266 266
 
267 267
 				// Payment form item.
268
-				$item->set_quantity( $value['quantity'] );
269
-				$item->set_allow_quantities( $value['allow_quantities'] );
270
-				$item->set_is_required( $value['required'] );
271
-				$item->set_custom_description( $value['description'] );
268
+				$item->set_quantity($value['quantity']);
269
+				$item->set_allow_quantities($value['allow_quantities']);
270
+				$item->set_is_required($value['required']);
271
+				$item->set_custom_description($value['description']);
272 272
 				$prepared[] = $item;
273 273
 				continue;
274 274
 
@@ -285,8 +285,8 @@  discard block
 block discarded – undo
285 285
 	 * @param  string $context View or edit context.
286 286
 	 * @return array
287 287
 	 */
288
-	public function get_earned( $context = 'view' ) {
289
-		return $this->get_prop( 'earned', $context );
288
+	public function get_earned($context = 'view') {
289
+		return $this->get_prop('earned', $context);
290 290
 	}
291 291
 
292 292
 	/**
@@ -296,8 +296,8 @@  discard block
 block discarded – undo
296 296
 	 * @param  string $context View or edit context.
297 297
 	 * @return array
298 298
 	 */
299
-	public function get_refunded( $context = 'view' ) {
300
-		return $this->get_prop( 'refunded', $context );
299
+	public function get_refunded($context = 'view') {
300
+		return $this->get_prop('refunded', $context);
301 301
 	}
302 302
 
303 303
 	/**
@@ -307,8 +307,8 @@  discard block
 block discarded – undo
307 307
 	 * @param  string $context View or edit context.
308 308
 	 * @return array
309 309
 	 */
310
-	public function get_cancelled( $context = 'view' ) {
311
-		return $this->get_prop( 'cancelled', $context );
310
+	public function get_cancelled($context = 'view') {
311
+		return $this->get_prop('cancelled', $context);
312 312
 	}
313 313
 
314 314
 	/**
@@ -318,8 +318,8 @@  discard block
 block discarded – undo
318 318
 	 * @param  string $context View or edit context.
319 319
 	 * @return array
320 320
 	 */
321
-	public function get_failed( $context = 'view' ) {
322
-		return $this->get_prop( 'failed', $context );
321
+	public function get_failed($context = 'view') {
322
+		return $this->get_prop('failed', $context);
323 323
 	}
324 324
 
325 325
     /*
@@ -337,8 +337,8 @@  discard block
 block discarded – undo
337 337
 	 *
338 338
 	 * @since 1.0.19
339 339
 	 */
340
-	public function set_version( $value ) {
341
-		$this->set_prop( 'version', $value );
340
+	public function set_version($value) {
341
+		$this->set_prop('version', $value);
342 342
     }
343 343
 
344 344
     /**
@@ -348,11 +348,11 @@  discard block
 block discarded – undo
348 348
 	 * @param string $value Value to set.
349 349
      * @return bool Whether or not the date was set.
350 350
 	 */
351
-	public function set_date_created( $value ) {
352
-        $date = strtotime( $value );
351
+	public function set_date_created($value) {
352
+        $date = strtotime($value);
353 353
 
354
-        if ( $date ) {
355
-            $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) );
354
+        if ($date) {
355
+            $this->set_prop('date_created', date('Y-m-d H:i:s', $date));
356 356
             return true;
357 357
         }
358 358
 
@@ -367,11 +367,11 @@  discard block
 block discarded – undo
367 367
 	 * @param string $value Value to set.
368 368
      * @return bool Whether or not the date was set.
369 369
 	 */
370
-	public function set_date_modified( $value ) {
371
-        $date = strtotime( $value );
370
+	public function set_date_modified($value) {
371
+        $date = strtotime($value);
372 372
 
373
-        if ( $date ) {
374
-            $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) );
373
+        if ($date) {
374
+            $this->set_prop('date_modified', date('Y-m-d H:i:s', $date));
375 375
             return true;
376 376
         }
377 377
 
@@ -385,8 +385,8 @@  discard block
 block discarded – undo
385 385
 	 * @since 1.0.19
386 386
 	 * @param  string $value New name.
387 387
 	 */
388
-	public function set_name( $value ) {
389
-		$this->set_prop( 'name', sanitize_text_field( $value ) );
388
+	public function set_name($value) {
389
+		$this->set_prop('name', sanitize_text_field($value));
390 390
     }
391 391
 
392 392
     /**
@@ -395,8 +395,8 @@  discard block
 block discarded – undo
395 395
 	 * @since 1.0.19
396 396
 	 * @param  string $value New name.
397 397
 	 */
398
-	public function set_title( $value ) {
399
-		$this->set_name( $value );
398
+	public function set_title($value) {
399
+		$this->set_name($value);
400 400
     }
401 401
 
402 402
     /**
@@ -405,8 +405,8 @@  discard block
 block discarded – undo
405 405
 	 * @since 1.0.19
406 406
 	 * @param  int $value New author.
407 407
 	 */
408
-	public function set_author( $value ) {
409
-		$this->set_prop( 'author', (int) $value );
408
+	public function set_author($value) {
409
+		$this->set_prop('author', (int) $value);
410 410
 	}
411 411
 
412 412
 	/**
@@ -415,9 +415,9 @@  discard block
 block discarded – undo
415 415
 	 * @since 1.0.19
416 416
 	 * @param  array $value Form elements.
417 417
 	 */
418
-	public function set_elements( $value ) {
419
-		if ( is_array( $value ) ) {
420
-			$this->set_prop( 'elements', $value );
418
+	public function set_elements($value) {
419
+		if (is_array($value)) {
420
+			$this->set_prop('elements', $value);
421 421
 		}
422 422
 	}
423 423
 
@@ -427,9 +427,9 @@  discard block
 block discarded – undo
427 427
 	 * @since 1.0.19
428 428
 	 * @param  array $value Form elements.
429 429
 	 */
430
-	public function set_items( $value ) {
431
-		if ( is_array( $value ) ) {
432
-			$this->set_prop( 'items', $value );
430
+	public function set_items($value) {
431
+		if (is_array($value)) {
432
+			$this->set_prop('items', $value);
433 433
 		}
434 434
 	}
435 435
 	
@@ -440,8 +440,8 @@  discard block
 block discarded – undo
440 440
 	 * @param  float $value Amount earned.
441 441
 	 * @return array
442 442
 	 */
443
-	public function set_earned( $value ) {
444
-		return $this->set_prop( 'earned', $value );
443
+	public function set_earned($value) {
444
+		return $this->set_prop('earned', $value);
445 445
 	}
446 446
 
447 447
 	/**
@@ -451,8 +451,8 @@  discard block
 block discarded – undo
451 451
 	 * @param  float $value Amount refunded.
452 452
 	 * @return array
453 453
 	 */
454
-	public function set_refunded( $value ) {
455
-		return $this->set_prop( 'refunded', $value );
454
+	public function set_refunded($value) {
455
+		return $this->set_prop('refunded', $value);
456 456
 	}
457 457
 
458 458
 	/**
@@ -462,8 +462,8 @@  discard block
 block discarded – undo
462 462
 	 * @param  float $value Amount cancelled.
463 463
 	 * @return array
464 464
 	 */
465
-	public function set_cancelled( $value ) {
466
-		return $this->set_prop( 'cancelled', $value );
465
+	public function set_cancelled($value) {
466
+		return $this->set_prop('cancelled', $value);
467 467
 	}
468 468
 
469 469
 	/**
@@ -473,8 +473,8 @@  discard block
 block discarded – undo
473 473
 	 * @param  float $value Amount cancelled.
474 474
 	 * @return array
475 475
 	 */
476
-	public function set_failed( $value ) {
477
-		return $this->set_prop( 'failed', $value );
476
+	public function set_failed($value) {
477
+		return $this->set_prop('failed', $value);
478 478
 	}
479 479
 
480 480
     /**
@@ -483,11 +483,11 @@  discard block
 block discarded – undo
483 483
      * @deprecated
484 484
 	 * @return int item id
485 485
      */
486
-    public function create( $data = array() ) {
486
+    public function create($data = array()) {
487 487
 
488 488
 		// Set the properties.
489
-		if ( is_array( $data ) ) {
490
-			$this->set_props( $data );
489
+		if (is_array($data)) {
490
+			$this->set_props($data);
491 491
 		}
492 492
 
493 493
 		// Save the item.
@@ -501,8 +501,8 @@  discard block
 block discarded – undo
501 501
      * @deprecated
502 502
 	 * @return int item id
503 503
      */
504
-    public function update( $data = array() ) {
505
-        return $this->create( $data );
504
+    public function update($data = array()) {
505
+        return $this->create($data);
506 506
     }
507 507
 
508 508
     /*
@@ -522,7 +522,7 @@  discard block
 block discarded – undo
522 522
 	 */
523 523
     public function is_default() {
524 524
         $is_default = $this->get_id() == wpinv_get_default_payment_form();
525
-        return (bool) apply_filters( 'wpinv_is_default_payment_form', $is_default, $this->ID, $this );
525
+        return (bool) apply_filters('wpinv_is_default_payment_form', $is_default, $this->ID, $this);
526 526
 	}
527 527
 
528 528
     /**
@@ -534,11 +534,11 @@  discard block
 block discarded – undo
534 534
     public function is_active() {
535 535
         $is_active = null !== $this->get_id();
536 536
 
537
-        if ( ! current_user_can( 'edit_post', $this->ID ) && $this->post_status != 'publish' ) {
537
+        if (!current_user_can('edit_post', $this->ID) && $this->post_status != 'publish') {
538 538
             $is_active = false;
539 539
         }
540 540
 
541
-        return (bool) apply_filters( 'wpinv_is_payment_form_active', $is_active, $this );
541
+        return (bool) apply_filters('wpinv_is_payment_form_active', $is_active, $this);
542 542
     }
543 543
 
544 544
 }
Please login to merge, or discard this patch.
includes/class-wpinv.php 2 patches
Indentation   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -161,10 +161,10 @@  discard block
 block discarded – undo
161 161
         require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php' );
162 162
 
163 163
         // Register autoloader.
164
-		try {
165
-			spl_autoload_register( array( $this, 'autoload' ), true );
166
-		} catch ( Exception $e ) {
167
-			wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true );
164
+        try {
165
+            spl_autoload_register( array( $this, 'autoload' ), true );
166
+        } catch ( Exception $e ) {
167
+            wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true );
168 168
         }
169 169
 
170 170
         require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php' );
@@ -188,11 +188,11 @@  discard block
 block discarded – undo
188 188
         require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' );
189 189
         require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' );
190 190
         require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' );
191
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' );
192
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' );
193
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' );
194
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' );
195
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' );
191
+        require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' );
192
+        require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' );
193
+        require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' );
194
+        require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' );
195
+        require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' );
196 196
         require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' );
197 197
         require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' );
198 198
         require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-payment-form-elements.php' );
@@ -254,47 +254,47 @@  discard block
 block discarded – undo
254 254
     }
255 255
 
256 256
     /**
257
-	 * Class autoloader
258
-	 *
259
-	 * @param       string $class_name The name of the class to load.
260
-	 * @access      public
261
-	 * @since       1.0.19
262
-	 * @return      void
263
-	 */
264
-	public function autoload( $class_name ) {
265
-
266
-		// Normalize the class name...
267
-		$class_name  = strtolower( $class_name );
268
-
269
-		// ... and make sure it is our class.
270
-		if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) {
271
-			return;
272
-		}
273
-
274
-		// Next, prepare the file name from the class.
275
-		$file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php';
276
-
277
-		// And an array of possible locations in order of importance.
278
-		$locations = array(
279
-			'includes',
280
-			'includes/data-stores',
257
+     * Class autoloader
258
+     *
259
+     * @param       string $class_name The name of the class to load.
260
+     * @access      public
261
+     * @since       1.0.19
262
+     * @return      void
263
+     */
264
+    public function autoload( $class_name ) {
265
+
266
+        // Normalize the class name...
267
+        $class_name  = strtolower( $class_name );
268
+
269
+        // ... and make sure it is our class.
270
+        if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) {
271
+            return;
272
+        }
273
+
274
+        // Next, prepare the file name from the class.
275
+        $file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php';
276
+
277
+        // And an array of possible locations in order of importance.
278
+        $locations = array(
279
+            'includes',
280
+            'includes/data-stores',
281 281
             'includes/admin',
282 282
             'includes/admin/meta-boxes'
283
-		);
283
+        );
284 284
 
285
-		// Base path of the classes.
286
-		$plugin_path = untrailingslashit( WPINV_PLUGIN_DIR );
285
+        // Base path of the classes.
286
+        $plugin_path = untrailingslashit( WPINV_PLUGIN_DIR );
287 287
 
288
-		foreach ( $locations as $location ) {
288
+        foreach ( $locations as $location ) {
289 289
 
290
-			if ( file_exists( "$plugin_path/$location/$file_name" ) ) {
291
-				include "$plugin_path/$location/$file_name";
292
-				break;
293
-			}
290
+            if ( file_exists( "$plugin_path/$location/$file_name" ) ) {
291
+                include "$plugin_path/$location/$file_name";
292
+                break;
293
+            }
294 294
 
295
-		}
295
+        }
296 296
 
297
-	}
297
+    }
298 298
 
299 299
     public function init() {
300 300
     }
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
             wp_register_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16' );
385 385
             wp_enqueue_style( 'jquery-ui-css' );
386 386
             wp_deregister_style( 'yoast-seo-select2' );
387
-	        wp_deregister_style( 'yoast-seo-monorepo' );
387
+            wp_deregister_style( 'yoast-seo-monorepo' );
388 388
         }
389 389
 
390 390
         wp_register_style( 'wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION );
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
         if ( $page == 'wpinv-subscriptions' ) {
399 399
             wp_enqueue_script( 'jquery-ui-datepicker' );
400 400
             wp_deregister_style( 'yoast-seo-select2' );
401
-	        wp_deregister_style( 'yoast-seo-monorepo' );
401
+            wp_deregister_style( 'yoast-seo-monorepo' );
402 402
         }
403 403
         
404 404
         if ( $enqueue_datepicker = apply_filters( 'wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue ) ) {
@@ -564,19 +564,19 @@  discard block
 block discarded – undo
564 564
         require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' );
565 565
     }
566 566
 
567
-	/**
568
-	 * Register widgets
569
-	 *
570
-	 */
571
-	public function register_widgets() {
572
-		register_widget( "WPInv_Checkout_Widget" );
573
-		register_widget( "WPInv_History_Widget" );
574
-		register_widget( "WPInv_Receipt_Widget" );
575
-		register_widget( "WPInv_Subscriptions_Widget" );
576
-		register_widget( "WPInv_Buy_Item_Widget" );
567
+    /**
568
+     * Register widgets
569
+     *
570
+     */
571
+    public function register_widgets() {
572
+        register_widget( "WPInv_Checkout_Widget" );
573
+        register_widget( "WPInv_History_Widget" );
574
+        register_widget( "WPInv_Receipt_Widget" );
575
+        register_widget( "WPInv_Subscriptions_Widget" );
576
+        register_widget( "WPInv_Buy_Item_Widget" );
577 577
         register_widget( "WPInv_Messages_Widget" );
578 578
         register_widget( 'WPInv_GetPaid_Widget' );
579
-	}
579
+    }
580 580
     
581 581
     /**
582 582
      * Remove our pages from yoast sitemaps.
Please login to merge, or discard this patch.
Spacing   +267 added lines, -267 removed lines patch added patch discarded remove patch
@@ -7,15 +7,15 @@  discard block
 block discarded – undo
7 7
  */
8 8
  
9 9
 // MUST have WordPress.
10
-if ( !defined( 'WPINC' ) ) {
11
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
10
+if (!defined('WPINC')) {
11
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
12 12
 }
13 13
 
14 14
 class WPInv_Plugin {
15 15
     private static $instance;
16 16
     
17 17
     public static function run() {
18
-        if ( !isset( self::$instance ) && !( self::$instance instanceof WPInv_Plugin ) ) {
18
+        if (!isset(self::$instance) && !(self::$instance instanceof WPInv_Plugin)) {
19 19
             self::$instance = new WPInv_Plugin;
20 20
             self::$instance->includes();
21 21
             self::$instance->actions();
@@ -33,35 +33,35 @@  discard block
 block discarded – undo
33 33
     }
34 34
     
35 35
     public function define_constants() {
36
-        define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) );
37
-        define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) );
36
+        define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE));
37
+        define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE));
38 38
     }
39 39
 
40 40
     private function actions() {
41 41
         /* Internationalize the text strings used. */
42
-        add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) );
42
+        add_action('plugins_loaded', array(&$this, 'plugins_loaded'));
43 43
         
44 44
         /* Perform actions on admin initialization. */
45
-        add_action( 'admin_init', array( &$this, 'admin_init') );
46
-        add_action( 'init', array( &$this, 'init' ), 3 );
47
-        add_action( 'init', array( &$this, 'wpinv_actions' ) );
45
+        add_action('admin_init', array(&$this, 'admin_init'));
46
+        add_action('init', array(&$this, 'init'), 3);
47
+        add_action('init', array(&$this, 'wpinv_actions'));
48 48
         
49
-        if ( class_exists( 'BuddyPress' ) ) {
50
-            add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) );
49
+        if (class_exists('BuddyPress')) {
50
+            add_action('bp_include', array(&$this, 'bp_invoicing_init'));
51 51
         }
52 52
 
53
-        add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) );
54
-        add_action( 'wp_footer', array( &$this, 'wp_footer' ) );
55
-        add_action( 'widgets_init', array( &$this, 'register_widgets' ) );
56
-        add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) );
53
+        add_action('wp_enqueue_scripts', array(&$this, 'enqueue_scripts'));
54
+        add_action('wp_footer', array(&$this, 'wp_footer'));
55
+        add_action('widgets_init', array(&$this, 'register_widgets'));
56
+        add_filter('wpseo_exclude_from_sitemap_by_post_ids', array($this, 'wpseo_exclude_from_sitemap_by_post_ids'));
57 57
 
58
-        if ( is_admin() ) {
59
-            add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_scripts' ) );
60
-            add_filter( 'admin_body_class', array( &$this, 'admin_body_class' ) );
61
-            add_action( 'admin_init', array( &$this, 'init_ayecode_connect_helper' ) );
58
+        if (is_admin()) {
59
+            add_action('admin_enqueue_scripts', array(&$this, 'admin_enqueue_scripts'));
60
+            add_filter('admin_body_class', array(&$this, 'admin_body_class'));
61
+            add_action('admin_init', array(&$this, 'init_ayecode_connect_helper'));
62 62
 
63 63
         } else {
64
-            add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
64
+            add_filter('pre_get_posts', array(&$this, 'pre_get_posts'));
65 65
         }
66 66
         
67 67
         /**
@@ -71,28 +71,28 @@  discard block
 block discarded – undo
71 71
          *
72 72
          * @param WPInv_Plugin $this. Current WPInv_Plugin instance. Passed by reference.
73 73
          */
74
-        do_action_ref_array( 'wpinv_actions', array( &$this ) );
74
+        do_action_ref_array('wpinv_actions', array(&$this));
75 75
 
76
-        add_action( 'admin_init', array( &$this, 'activation_redirect') );
76
+        add_action('admin_init', array(&$this, 'activation_redirect'));
77 77
     }
78 78
 
79 79
     /**
80 80
      * Maybe show the AyeCode Connect Notice.
81 81
      */
82
-    public function init_ayecode_connect_helper(){
82
+    public function init_ayecode_connect_helper() {
83 83
         // AyeCode Connect notice
84
-        if ( is_admin() ){
84
+        if (is_admin()) {
85 85
             // set the strings so they can be translated
86 86
             $strings = array(
87
-                'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"),
88
-                'connect_external'  => __( "Please confirm you wish to connect your site?","invoicing" ),
89
-                'connect'           => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ),
90
-                'connect_button'    => __("Connect Site","invoicing"),
91
-                'connecting_button'    => __("Connecting...","invoicing"),
92
-                'error_localhost'   => __( "This service will only work with a live domain, not a localhost.","invoicing" ),
93
-                'error'             => __( "Something went wrong, please refresh and try again.","invoicing" ),
87
+                'connect_title' => __("WP Invoicing - an AyeCode product!", "invoicing"),
88
+                'connect_external'  => __("Please confirm you wish to connect your site?", "invoicing"),
89
+                'connect'           => sprintf(__("<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s", "invoicing"), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", "</a>"),
90
+                'connect_button'    => __("Connect Site", "invoicing"),
91
+                'connecting_button'    => __("Connecting...", "invoicing"),
92
+                'error_localhost'   => __("This service will only work with a live domain, not a localhost.", "invoicing"),
93
+                'error'             => __("Something went wrong, please refresh and try again.", "invoicing"),
94 94
             );
95
-            new AyeCode_Connect_Helper($strings,array('wpi-addons'));
95
+            new AyeCode_Connect_Helper($strings, array('wpi-addons'));
96 96
         }
97 97
     }
98 98
     
@@ -100,10 +100,10 @@  discard block
 block discarded – undo
100 100
         /* Internationalize the text strings used. */
101 101
         $this->load_textdomain();
102 102
 
103
-        do_action( 'wpinv_loaded' );
103
+        do_action('wpinv_loaded');
104 104
 
105 105
         // Fix oxygen page builder conflict
106
-        if ( function_exists( 'ct_css_output' ) ) {
106
+        if (function_exists('ct_css_output')) {
107 107
             wpinv_oxygen_fix_conflict();
108 108
         }
109 109
     }
@@ -113,144 +113,144 @@  discard block
 block discarded – undo
113 113
      *
114 114
      * @since 1.0
115 115
      */
116
-    public function load_textdomain( $locale = NULL ) {
117
-        if ( empty( $locale ) ) {
118
-            $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
116
+    public function load_textdomain($locale = NULL) {
117
+        if (empty($locale)) {
118
+            $locale = is_admin() && function_exists('get_user_locale') ? get_user_locale() : get_locale();
119 119
         }
120 120
 
121
-        $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' );
121
+        $locale = apply_filters('plugin_locale', $locale, 'invoicing');
122 122
         
123
-        unload_textdomain( 'invoicing' );
124
-        load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' );
125
-        load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' );
123
+        unload_textdomain('invoicing');
124
+        load_textdomain('invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo');
125
+        load_plugin_textdomain('invoicing', false, WPINV_PLUGIN_DIR . 'languages');
126 126
         
127 127
         /**
128 128
          * Define language constants.
129 129
          */
130
-        require_once( WPINV_PLUGIN_DIR . 'language.php' );
130
+        require_once(WPINV_PLUGIN_DIR . 'language.php');
131 131
     }
132 132
 
133 133
     public function includes() {
134 134
         global $wpinv_options;
135 135
 
136
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' );
136
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php');
137 137
         $wpinv_options = wpinv_get_settings();
138 138
 
139 139
         // Load composer packages.
140
-        require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' );
140
+        require_once(WPINV_PLUGIN_DIR . 'vendor/autoload.php');
141 141
 
142 142
         // load AUI
143
-        require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' );
143
+        require_once(WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php');
144 144
 
145 145
         // Load the action scheduler.
146
-        require_once( WPINV_PLUGIN_DIR . 'includes/libraries/action-scheduler/action-scheduler.php' );
146
+        require_once(WPINV_PLUGIN_DIR . 'includes/libraries/action-scheduler/action-scheduler.php');
147 147
 
148 148
         // Load functions.
149
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' );
150
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' );
151
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' );
152
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' );
153
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' );
154
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' );
155
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php' );
156
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' );
157
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' );
158
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' );
159
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' );
160
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' );
161
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php' );
149
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php');
150
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php');
151
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php');
152
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php');
153
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php');
154
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php');
155
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php');
156
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php');
157
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php');
158
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php');
159
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php');
160
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php');
161
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php');
162 162
 
163 163
         // Register autoloader.
164 164
 		try {
165
-			spl_autoload_register( array( $this, 'autoload' ), true );
166
-		} catch ( Exception $e ) {
167
-			wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true );
168
-        }
169
-
170
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php' );
171
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php' );
172
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-discount.php' );
173
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php' );
174
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php' );
175
-        require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' );
176
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' );
177
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' );
178
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' );
179
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' );
180
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' );
181
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' );
182
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
183
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' );
184
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions.php' );
185
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' );
186
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-subscriptions-list-table.php' );
187
-        require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' );
188
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' );
189
-        require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' );
190
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' );
191
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' );
192
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' );
193
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' );
194
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' );
195
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' );
196
-        require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' );
197
-        require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' );
198
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-payment-form-elements.php' );
199
-
200
-        if ( !class_exists( 'WPInv_EUVat' ) ) {
201
-            require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' );
165
+			spl_autoload_register(array($this, 'autoload'), true);
166
+		} catch (Exception $e) {
167
+			wpinv_error_log($e->getMessage(), '', __FILE__, 149, true);
168
+        }
169
+
170
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php');
171
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php');
172
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-discount.php');
173
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php');
174
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php');
175
+        require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php');
176
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php');
177
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php');
178
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php');
179
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php');
180
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php');
181
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php');
182
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php');
183
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php');
184
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions.php');
185
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php');
186
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-subscriptions-list-table.php');
187
+        require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php');
188
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php');
189
+        require_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php');
190
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php');
191
+	    require_once(WPINV_PLUGIN_DIR . 'widgets/checkout.php');
192
+	    require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-history.php');
193
+	    require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php');
194
+	    require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php');
195
+	    require_once(WPINV_PLUGIN_DIR . 'widgets/subscriptions.php');
196
+        require_once(WPINV_PLUGIN_DIR . 'widgets/buy-item.php');
197
+        require_once(WPINV_PLUGIN_DIR . 'widgets/getpaid.php');
198
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-payment-form-elements.php');
199
+
200
+        if (!class_exists('WPInv_EUVat')) {
201
+            require_once(WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php');
202 202
         }
203 203
         
204
-        $gateways = array_keys( wpinv_get_enabled_payment_gateways() );
205
-        if ( !empty( $gateways ) ) {
206
-            foreach ( $gateways as $gateway ) {
207
-                if ( $gateway == 'manual' ) {
204
+        $gateways = array_keys(wpinv_get_enabled_payment_gateways());
205
+        if (!empty($gateways)) {
206
+            foreach ($gateways as $gateway) {
207
+                if ($gateway == 'manual') {
208 208
                     continue;
209 209
                 }
210 210
                 
211 211
                 $gateway_file = WPINV_PLUGIN_DIR . 'includes/gateways/' . $gateway . '.php';
212 212
                 
213
-                if ( file_exists( $gateway_file ) ) {
214
-                    require_once( $gateway_file );
213
+                if (file_exists($gateway_file)) {
214
+                    require_once($gateway_file);
215 215
                 }
216 216
             }
217 217
         }
218
-        require_once( WPINV_PLUGIN_DIR . 'includes/gateways/manual.php' );
218
+        require_once(WPINV_PLUGIN_DIR . 'includes/gateways/manual.php');
219 219
         
220
-        if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
221
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' );
222
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' );
223
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php' );
220
+        if (is_admin() || (defined('WP_CLI') && WP_CLI)) {
221
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php');
222
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php');
223
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php');
224 224
             //require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-recurring-admin.php' );
225
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php' );
226
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php' );
227
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' );
228
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' );
229
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php' );
230
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' );
231
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' );
232
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' );
233
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' );
225
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php');
226
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php');
227
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php');
228
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php');
229
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php');
230
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php');
231
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php');
232
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php');
233
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php');
234 234
             //require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
235 235
             // load the user class only on the users.php page
236 236
             global $pagenow;
237
-            if($pagenow=='users.php'){
237
+            if ($pagenow == 'users.php') {
238 238
                 new WPInv_Admin_Users();
239 239
             }
240 240
         }
241 241
 
242 242
         // Register cli commands
243
-        if ( defined( 'WP_CLI' ) && WP_CLI ) {
244
-            require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' );
245
-            WP_CLI::add_command( 'invoicing', 'WPInv_CLI' );
243
+        if (defined('WP_CLI') && WP_CLI) {
244
+            require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php');
245
+            WP_CLI::add_command('invoicing', 'WPInv_CLI');
246 246
         }
247 247
         
248 248
         // include css inliner
249
-        if ( ! class_exists( 'Emogrifier' ) && class_exists( 'DOMDocument' ) ) {
250
-            include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' );
249
+        if (!class_exists('Emogrifier') && class_exists('DOMDocument')) {
250
+            include_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php');
251 251
         }
252 252
         
253
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' );
253
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/install.php');
254 254
     }
255 255
 
256 256
     /**
@@ -261,18 +261,18 @@  discard block
 block discarded – undo
261 261
 	 * @since       1.0.19
262 262
 	 * @return      void
263 263
 	 */
264
-	public function autoload( $class_name ) {
264
+	public function autoload($class_name) {
265 265
 
266 266
 		// Normalize the class name...
267
-		$class_name  = strtolower( $class_name );
267
+		$class_name = strtolower($class_name);
268 268
 
269 269
 		// ... and make sure it is our class.
270
-		if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) {
270
+		if (false === strpos($class_name, 'getpaid_') && false === strpos($class_name, 'wpinv_')) {
271 271
 			return;
272 272
 		}
273 273
 
274 274
 		// Next, prepare the file name from the class.
275
-		$file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php';
275
+		$file_name = 'class-' . str_replace('_', '-', $class_name) . '.php';
276 276
 
277 277
 		// And an array of possible locations in order of importance.
278 278
 		$locations = array(
@@ -283,11 +283,11 @@  discard block
 block discarded – undo
283 283
 		);
284 284
 
285 285
 		// Base path of the classes.
286
-		$plugin_path = untrailingslashit( WPINV_PLUGIN_DIR );
286
+		$plugin_path = untrailingslashit(WPINV_PLUGIN_DIR);
287 287
 
288
-		foreach ( $locations as $location ) {
288
+		foreach ($locations as $location) {
289 289
 
290
-			if ( file_exists( "$plugin_path/$location/$file_name" ) ) {
290
+			if (file_exists("$plugin_path/$location/$file_name")) {
291 291
 				include "$plugin_path/$location/$file_name";
292 292
 				break;
293 293
 			}
@@ -301,114 +301,114 @@  discard block
 block discarded – undo
301 301
     
302 302
     public function admin_init() {
303 303
         self::$instance->default_payment_form = wpinv_get_default_payment_form();
304
-        add_action( 'admin_print_scripts-edit.php', array( &$this, 'admin_print_scripts_edit_php' ) );
304
+        add_action('admin_print_scripts-edit.php', array(&$this, 'admin_print_scripts_edit_php'));
305 305
     }
306 306
 
307 307
     public function activation_redirect() {
308 308
         // Bail if no activation redirect
309
-        if ( !get_transient( '_wpinv_activation_redirect' ) ) {
309
+        if (!get_transient('_wpinv_activation_redirect')) {
310 310
             return;
311 311
         }
312 312
 
313 313
         // Delete the redirect transient
314
-        delete_transient( '_wpinv_activation_redirect' );
314
+        delete_transient('_wpinv_activation_redirect');
315 315
 
316 316
         // Bail if activating from network, or bulk
317
-        if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
317
+        if (is_network_admin() || isset($_GET['activate-multi'])) {
318 318
             return;
319 319
         }
320 320
 
321
-        wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) );
321
+        wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general'));
322 322
         exit;
323 323
     }
324 324
     
325 325
     public function enqueue_scripts() {
326
-        $suffix       = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
326
+        $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
327 327
         
328
-        wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION );
329
-        wp_enqueue_style( 'wpinv_front_style' );
328
+        wp_register_style('wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION);
329
+        wp_enqueue_style('wpinv_front_style');
330 330
                
331 331
         // Register scripts
332
-        wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
333
-        wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array( 'jquery' ),  filemtime( WPINV_PLUGIN_DIR . 'assets/js/invoice-front.js' ) );
332
+        wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true);
333
+        wp_register_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array('jquery'), filemtime(WPINV_PLUGIN_DIR . 'assets/js/invoice-front.js'));
334 334
 
335 335
         $localize                         = array();
336
-        $localize['ajax_url']             = admin_url( 'admin-ajax.php' );
337
-        $localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
336
+        $localize['ajax_url']             = admin_url('admin-ajax.php');
337
+        $localize['nonce']                = wp_create_nonce('wpinv-nonce');
338 338
         $localize['currency_symbol']      = wpinv_currency_symbol();
339 339
         $localize['currency_pos']         = wpinv_currency_position();
340 340
         $localize['thousand_sep']         = wpinv_thousands_separator();
341 341
         $localize['decimal_sep']          = wpinv_decimal_separator();
342 342
         $localize['decimals']             = wpinv_decimals();
343
-        $localize['txtComplete']          = __( 'Continue', 'invoicing' );
343
+        $localize['txtComplete']          = __('Continue', 'invoicing');
344 344
         $localize['UseTaxes']             = wpinv_use_taxes();
345
-        $localize['checkoutNonce']        = wp_create_nonce( 'wpinv_checkout_nonce' );
345
+        $localize['checkoutNonce']        = wp_create_nonce('wpinv_checkout_nonce');
346 346
 
347
-        $localize = apply_filters( 'wpinv_front_js_localize', $localize );
347
+        $localize = apply_filters('wpinv_front_js_localize', $localize);
348 348
         
349
-        wp_enqueue_script( 'jquery-blockui' );
349
+        wp_enqueue_script('jquery-blockui');
350 350
         $autofill_api = wpinv_get_option('address_autofill_api');
351 351
         $autofill_active = wpinv_get_option('address_autofill_active');
352
-        if ( isset( $autofill_active ) && 1 == $autofill_active && !empty( $autofill_api ) && wpinv_is_checkout() ) {
353
-            if ( wp_script_is( 'google-maps-api', 'enqueued' ) ) {
354
-                wp_dequeue_script( 'google-maps-api' );
352
+        if (isset($autofill_active) && 1 == $autofill_active && !empty($autofill_api) && wpinv_is_checkout()) {
353
+            if (wp_script_is('google-maps-api', 'enqueued')) {
354
+                wp_dequeue_script('google-maps-api');
355 355
             }
356
-            wp_enqueue_script( 'google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array( 'jquery' ), '', false );
357
-            wp_enqueue_script( 'google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array( 'jquery', 'google-maps-api' ), '', true );
356
+            wp_enqueue_script('google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array('jquery'), '', false);
357
+            wp_enqueue_script('google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array('jquery', 'google-maps-api'), '', true);
358 358
         }
359 359
 
360
-        wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' );
361
-        wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION );
360
+        wp_enqueue_style("select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all');
361
+        wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array('jquery'), WPINV_VERSION);
362 362
 
363
-        wp_enqueue_script( 'wpinv-front-script' );
364
-        wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
363
+        wp_enqueue_script('wpinv-front-script');
364
+        wp_localize_script('wpinv-front-script', 'WPInv', $localize);
365 365
 
366
-        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' );
367
-        wp_enqueue_script( 'wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'wpinv-front-script', 'wp-hooks' ),  $version, true );
366
+        $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js');
367
+        wp_enqueue_script('wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array('wpinv-front-script', 'wp-hooks'), $version, true);
368 368
     }
369 369
 
370
-    public function admin_enqueue_scripts( $hook ) {
370
+    public function admin_enqueue_scripts($hook) {
371 371
         global $post, $pagenow;
372 372
         
373 373
         $post_type  = wpinv_admin_post_type();
374
-        $suffix     = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
375
-        $page       = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : '';
374
+        $suffix     = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
375
+        $page       = isset($_GET['page']) ? strtolower($_GET['page']) : '';
376 376
 
377 377
         $jquery_ui_css = false;
378
-        if ( ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount' ) && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ) {
378
+        if (($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount') && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) {
379 379
             $jquery_ui_css = true;
380
-        } else if ( $page == 'wpinv-settings' || $page == 'wpinv-reports' ) {
380
+        } else if ($page == 'wpinv-settings' || $page == 'wpinv-reports') {
381 381
             $jquery_ui_css = true;
382 382
         }
383
-        if ( $jquery_ui_css ) {
384
-            wp_register_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16' );
385
-            wp_enqueue_style( 'jquery-ui-css' );
386
-            wp_deregister_style( 'yoast-seo-select2' );
387
-	        wp_deregister_style( 'yoast-seo-monorepo' );
383
+        if ($jquery_ui_css) {
384
+            wp_register_style('jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16');
385
+            wp_enqueue_style('jquery-ui-css');
386
+            wp_deregister_style('yoast-seo-select2');
387
+	        wp_deregister_style('yoast-seo-monorepo');
388 388
         }
389 389
 
390
-        wp_register_style( 'wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION );
391
-        wp_enqueue_style( 'wpinv_meta_box_style' );
390
+        wp_register_style('wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION);
391
+        wp_enqueue_style('wpinv_meta_box_style');
392 392
         
393
-        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/admin.css' );
394
-        wp_register_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), $version );
395
-        wp_enqueue_style( 'wpinv_admin_style' );
393
+        $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/admin.css');
394
+        wp_register_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), $version);
395
+        wp_enqueue_style('wpinv_admin_style');
396 396
 
397
-        $enqueue = ( $post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) );
398
-        if ( $page == 'wpinv-subscriptions' ) {
399
-            wp_enqueue_script( 'jquery-ui-datepicker' );
400
-            wp_deregister_style( 'yoast-seo-select2' );
401
-	        wp_deregister_style( 'yoast-seo-monorepo' );
397
+        $enqueue = ($post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ($pagenow == 'post-new.php' || $pagenow == 'post.php'));
398
+        if ($page == 'wpinv-subscriptions') {
399
+            wp_enqueue_script('jquery-ui-datepicker');
400
+            wp_deregister_style('yoast-seo-select2');
401
+	        wp_deregister_style('yoast-seo-monorepo');
402 402
         }
403 403
         
404
-        if ( $enqueue_datepicker = apply_filters( 'wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue ) ) {
405
-            wp_enqueue_script( 'jquery-ui-datepicker' );
404
+        if ($enqueue_datepicker = apply_filters('wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue)) {
405
+            wp_enqueue_script('jquery-ui-datepicker');
406 406
         }
407 407
 
408
-        wp_enqueue_style( 'wp-color-picker' );
409
-        wp_enqueue_script( 'wp-color-picker' );
408
+        wp_enqueue_style('wp-color-picker');
409
+        wp_enqueue_script('wp-color-picker');
410 410
         
411
-        wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
411
+        wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true);
412 412
 
413 413
         if (($post_type == 'wpi_invoice' || $post_type == 'wpi_quote') && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) {
414 414
             $autofill_api = wpinv_get_option('address_autofill_api');
@@ -419,21 +419,21 @@  discard block
 block discarded – undo
419 419
             }
420 420
         }
421 421
 
422
-        wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' );
423
-        wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION );
422
+        wp_enqueue_style("select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all');
423
+        wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array('jquery'), WPINV_VERSION);
424 424
 
425
-        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin.js' );
426
-        wp_register_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'jquery-blockui','jquery-ui-tooltip' ),  $version );
427
-        wp_enqueue_script( 'wpinv-admin-script' );
425
+        $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin.js');
426
+        wp_register_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array('jquery', 'jquery-blockui', 'jquery-ui-tooltip'), $version);
427
+        wp_enqueue_script('wpinv-admin-script');
428 428
         
429 429
         $localize                               = array();
430
-        $localize['ajax_url']                   = admin_url( 'admin-ajax.php' );
431
-        $localize['post_ID']                    = isset( $post->ID ) ? $post->ID : '';
432
-        $localize['wpinv_nonce']                = wp_create_nonce( 'wpinv-nonce' );
433
-        $localize['add_invoice_note_nonce']     = wp_create_nonce( 'add-invoice-note' );
434
-        $localize['delete_invoice_note_nonce']  = wp_create_nonce( 'delete-invoice-note' );
435
-        $localize['invoice_item_nonce']         = wp_create_nonce( 'invoice-item' );
436
-        $localize['billing_details_nonce']      = wp_create_nonce( 'get-billing-details' );
430
+        $localize['ajax_url']                   = admin_url('admin-ajax.php');
431
+        $localize['post_ID']                    = isset($post->ID) ? $post->ID : '';
432
+        $localize['wpinv_nonce']                = wp_create_nonce('wpinv-nonce');
433
+        $localize['add_invoice_note_nonce']     = wp_create_nonce('add-invoice-note');
434
+        $localize['delete_invoice_note_nonce']  = wp_create_nonce('delete-invoice-note');
435
+        $localize['invoice_item_nonce']         = wp_create_nonce('invoice-item');
436
+        $localize['billing_details_nonce']      = wp_create_nonce('get-billing-details');
437 437
         $localize['tax']                        = wpinv_tax_amount();
438 438
         $localize['discount']                   = wpinv_discount_amount();
439 439
         $localize['currency_symbol']            = wpinv_currency_symbol();
@@ -441,101 +441,101 @@  discard block
 block discarded – undo
441 441
         $localize['thousand_sep']               = wpinv_thousands_separator();
442 442
         $localize['decimal_sep']                = wpinv_decimal_separator();
443 443
         $localize['decimals']                   = wpinv_decimals();
444
-        $localize['save_invoice']               = __( 'Save Invoice', 'invoicing' );
445
-        $localize['status_publish']             = wpinv_status_nicename( 'publish' );
446
-        $localize['status_pending']             = wpinv_status_nicename( 'wpi-pending' );
447
-        $localize['delete_tax_rate']            = __( 'Are you sure you wish to delete this tax rate?', 'invoicing' );
448
-        $localize['OneItemMin']                 = __( 'Invoice must contain at least one item', 'invoicing' );
449
-        $localize['DeleteInvoiceItem']          = __( 'Are you sure you wish to delete this item?', 'invoicing' );
450
-        $localize['FillBillingDetails']         = __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' );
451
-        $localize['confirmCalcTotals']          = __( 'Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing' );
452
-        $localize['AreYouSure']                 = __( 'Are you sure?', 'invoicing' );
453
-        $localize['emptyInvoice']               = __( 'Add at least one item to save invoice!', 'invoicing' );
454
-        $localize['errDeleteItem']              = __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' );
455
-        $localize['delete_subscription']        = __( 'Are you sure you want to delete this subscription?', 'invoicing' );
456
-        $localize['action_edit']                = __( 'Edit', 'invoicing' );
457
-        $localize['action_cancel']              = __( 'Cancel', 'invoicing' );
458
-        $localize['item_description']           = __( 'Item Description', 'invoicing' );
459
-
460
-        $localize = apply_filters( 'wpinv_admin_js_localize', $localize );
461
-
462
-        wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', $localize );
444
+        $localize['save_invoice']               = __('Save Invoice', 'invoicing');
445
+        $localize['status_publish']             = wpinv_status_nicename('publish');
446
+        $localize['status_pending']             = wpinv_status_nicename('wpi-pending');
447
+        $localize['delete_tax_rate']            = __('Are you sure you wish to delete this tax rate?', 'invoicing');
448
+        $localize['OneItemMin']                 = __('Invoice must contain at least one item', 'invoicing');
449
+        $localize['DeleteInvoiceItem']          = __('Are you sure you wish to delete this item?', 'invoicing');
450
+        $localize['FillBillingDetails']         = __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing');
451
+        $localize['confirmCalcTotals']          = __('Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing');
452
+        $localize['AreYouSure']                 = __('Are you sure?', 'invoicing');
453
+        $localize['emptyInvoice']               = __('Add at least one item to save invoice!', 'invoicing');
454
+        $localize['errDeleteItem']              = __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing');
455
+        $localize['delete_subscription']        = __('Are you sure you want to delete this subscription?', 'invoicing');
456
+        $localize['action_edit']                = __('Edit', 'invoicing');
457
+        $localize['action_cancel']              = __('Cancel', 'invoicing');
458
+        $localize['item_description']           = __('Item Description', 'invoicing');
459
+
460
+        $localize = apply_filters('wpinv_admin_js_localize', $localize);
461
+
462
+        wp_localize_script('wpinv-admin-script', 'WPInv_Admin', $localize);
463 463
 
464 464
         // Load payment form scripts on our admin pages only.
465
-        if ( ( $hook == 'post-new.php' || $hook == 'post.php' ) && 'wpi_payment_form' === $post->post_type ) {
465
+        if (($hook == 'post-new.php' || $hook == 'post.php') && 'wpi_payment_form' === $post->post_type) {
466 466
 
467
-            wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION );
468
-            wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
469
-            wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
467
+            wp_enqueue_script('vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION);
468
+            wp_enqueue_script('sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION);
469
+            wp_enqueue_script('vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array('sortable', 'vue'), WPINV_VERSION);
470 470
 
471
-            $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
472
-            wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ),  $version );
471
+            $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js');
472
+            wp_register_script('wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array('wpinv-admin-script', 'vue_draggable'), $version);
473 473
         
474
-            wp_localize_script( 'wpinv-admin-payment-form-script', 'wpinvPaymentFormAdmin', array(
474
+            wp_localize_script('wpinv-admin-payment-form-script', 'wpinvPaymentFormAdmin', array(
475 475
                 'elements'      => $this->form_elements->get_elements(),
476
-                'form_elements' => $this->form_elements->get_form_elements( $post->ID ),
476
+                'form_elements' => $this->form_elements->get_form_elements($post->ID),
477 477
                 'all_items'     => $this->form_elements->get_published_items(),
478 478
                 'currency'      => wpinv_currency_symbol(),
479 479
                 'position'      => wpinv_currency_position(),
480 480
                 'decimals'      => (int) wpinv_decimals(),
481 481
                 'thousands_sep' => wpinv_thousands_separator(),
482 482
                 'decimals_sep'  => wpinv_decimal_separator(),
483
-                'form_items'    => $this->form_elements->get_form_items( $post->ID ),
483
+                'form_items'    => $this->form_elements->get_form_items($post->ID),
484 484
                 'is_default'    => $post->ID == $this->default_payment_form,
485
-            ) );
485
+            ));
486 486
 
487
-            wp_enqueue_script( 'wpinv-admin-payment-form-script' );
487
+            wp_enqueue_script('wpinv-admin-payment-form-script');
488 488
         }
489 489
 
490
-        if ( $page == 'wpinv-subscriptions' ) {
491
-            wp_register_script( 'wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array( 'wpinv-admin-script' ),  WPINV_VERSION );
492
-            wp_enqueue_script( 'wpinv-sub-admin-script' );
490
+        if ($page == 'wpinv-subscriptions') {
491
+            wp_register_script('wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array('wpinv-admin-script'), WPINV_VERSION);
492
+            wp_enqueue_script('wpinv-sub-admin-script');
493 493
         }
494 494
 
495
-        if ( $page == 'wpinv-reports' ) {
496
-            wp_enqueue_script( 'jquery-flot', WPINV_PLUGIN_URL . 'assets/js/jquery.flot.min.js', array( 'jquery' ), '0.7' );
495
+        if ($page == 'wpinv-reports') {
496
+            wp_enqueue_script('jquery-flot', WPINV_PLUGIN_URL . 'assets/js/jquery.flot.min.js', array('jquery'), '0.7');
497 497
         }
498 498
 
499 499
     }
500 500
 
501
-    public function admin_body_class( $classes ) {
501
+    public function admin_body_class($classes) {
502 502
         global $pagenow, $post, $current_screen;
503 503
         
504
-        if ( !empty( $current_screen->post_type ) && ( $current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_payment_form' || $current_screen->post_type == 'wpi_quote' ) ) {
504
+        if (!empty($current_screen->post_type) && ($current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_payment_form' || $current_screen->post_type == 'wpi_quote')) {
505 505
             $classes .= ' wpinv-cpt';
506 506
         }
507 507
         
508
-        $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false;
508
+        $page = isset($_GET['page']) ? strtolower($_GET['page']) : false;
509 509
 
510
-        $add_class = $page && $pagenow == 'admin.php' && strpos( $page, 'wpinv-' ) === 0 ? true : false;
511
-        if ( $add_class ) {
512
-            $classes .= ' wpi-' . wpinv_sanitize_key( $page );
510
+        $add_class = $page && $pagenow == 'admin.php' && strpos($page, 'wpinv-') === 0 ? true : false;
511
+        if ($add_class) {
512
+            $classes .= ' wpi-' . wpinv_sanitize_key($page);
513 513
         }
514 514
         
515 515
         $settings_class = array();
516
-        if ( $page == 'wpinv-settings' ) {
517
-            if ( !empty( $_REQUEST['tab'] ) ) {
518
-                $settings_class[] = sanitize_text_field( $_REQUEST['tab'] );
516
+        if ($page == 'wpinv-settings') {
517
+            if (!empty($_REQUEST['tab'])) {
518
+                $settings_class[] = sanitize_text_field($_REQUEST['tab']);
519 519
             }
520 520
             
521
-            if ( !empty( $_REQUEST['section'] ) ) {
522
-                $settings_class[] = sanitize_text_field( $_REQUEST['section'] );
521
+            if (!empty($_REQUEST['section'])) {
522
+                $settings_class[] = sanitize_text_field($_REQUEST['section']);
523 523
             }
524 524
             
525
-            $settings_class[] = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field( $_REQUEST['wpi_sub'] ) : 'main';
525
+            $settings_class[] = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field($_REQUEST['wpi_sub']) : 'main';
526 526
         }
527 527
         
528
-        if ( !empty( $settings_class ) ) {
529
-            $classes .= ' wpi-' . wpinv_sanitize_key( implode( $settings_class, '-' ) );
528
+        if (!empty($settings_class)) {
529
+            $classes .= ' wpi-' . wpinv_sanitize_key(implode($settings_class, '-'));
530 530
         }
531 531
         
532 532
         $post_type = wpinv_admin_post_type();
533 533
 
534
-        if ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false ) {
534
+        if ($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false) {
535 535
             return $classes .= ' wpinv';
536 536
         }
537 537
         
538
-        if ( $pagenow == 'post.php' && $post_type == 'wpi_item' && !empty( $post ) && !wpinv_item_is_editable( $post ) ) {
538
+        if ($pagenow == 'post.php' && $post_type == 'wpi_item' && !empty($post) && !wpinv_item_is_editable($post)) {
539 539
             $classes .= ' wpi-editable-n';
540 540
         }
541 541
 
@@ -547,21 +547,21 @@  discard block
 block discarded – undo
547 547
     }
548 548
     
549 549
     public function wpinv_actions() {
550
-        if ( isset( $_REQUEST['wpi_action'] ) ) {
551
-            do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
550
+        if (isset($_REQUEST['wpi_action'])) {
551
+            do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST);
552 552
         }
553 553
     }
554 554
     
555
-    public function pre_get_posts( $wp_query ) {
556
-        if ( !empty( $wp_query->query_vars['post_type'] ) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) {
557
-            $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() );
555
+    public function pre_get_posts($wp_query) {
556
+        if (!empty($wp_query->query_vars['post_type']) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query()) {
557
+            $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses());
558 558
         }
559 559
         
560 560
         return $wp_query;
561 561
     }
562 562
     
563 563
     public function bp_invoicing_init() {
564
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' );
564
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php');
565 565
     }
566 566
 
567 567
 	/**
@@ -569,13 +569,13 @@  discard block
 block discarded – undo
569 569
 	 *
570 570
 	 */
571 571
 	public function register_widgets() {
572
-		register_widget( "WPInv_Checkout_Widget" );
573
-		register_widget( "WPInv_History_Widget" );
574
-		register_widget( "WPInv_Receipt_Widget" );
575
-		register_widget( "WPInv_Subscriptions_Widget" );
576
-		register_widget( "WPInv_Buy_Item_Widget" );
577
-        register_widget( "WPInv_Messages_Widget" );
578
-        register_widget( 'WPInv_GetPaid_Widget' );
572
+		register_widget("WPInv_Checkout_Widget");
573
+		register_widget("WPInv_History_Widget");
574
+		register_widget("WPInv_Receipt_Widget");
575
+		register_widget("WPInv_Subscriptions_Widget");
576
+		register_widget("WPInv_Buy_Item_Widget");
577
+        register_widget("WPInv_Messages_Widget");
578
+        register_widget('WPInv_GetPaid_Widget');
579 579
 	}
580 580
     
581 581
     /**
@@ -584,10 +584,10 @@  discard block
 block discarded – undo
584 584
      * @since 1.0.19
585 585
      * @param int[] $excluded_posts_ids
586 586
      */
587
-    public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){
587
+    public function wpseo_exclude_from_sitemap_by_post_ids($excluded_posts_ids) {
588 588
 
589 589
         // Ensure that we have an array.
590
-        if ( ! is_array( $excluded_posts_ids ) ) {
590
+        if (!is_array($excluded_posts_ids)) {
591 591
             $excluded_posts_ids = array();
592 592
         }
593 593
 
@@ -595,24 +595,24 @@  discard block
 block discarded – undo
595 595
         $our_pages = array();
596 596
     
597 597
         // Checkout page.
598
-        $our_pages[] = wpinv_get_option( 'checkout_page', false );
598
+        $our_pages[] = wpinv_get_option('checkout_page', false);
599 599
 
600 600
         // Success page.
601
-        $our_pages[] = wpinv_get_option( 'success_page', false );
601
+        $our_pages[] = wpinv_get_option('success_page', false);
602 602
 
603 603
         // Failure page.
604
-        $our_pages[] = wpinv_get_option( 'failure_page', false );
604
+        $our_pages[] = wpinv_get_option('failure_page', false);
605 605
 
606 606
         // History page.
607
-        $our_pages[] = wpinv_get_option( 'invoice_history_page', false );
607
+        $our_pages[] = wpinv_get_option('invoice_history_page', false);
608 608
 
609 609
         // Subscriptions page.
610
-        $our_pages[] = wpinv_get_option( 'invoice_subscription_page', false );
610
+        $our_pages[] = wpinv_get_option('invoice_subscription_page', false);
611 611
 
612
-        $our_pages   = array_map( 'intval', array_filter( $our_pages ) );
612
+        $our_pages   = array_map('intval', array_filter($our_pages));
613 613
 
614 614
         $excluded_posts_ids = $excluded_posts_ids + $our_pages;
615
-        return array_unique( $excluded_posts_ids );
615
+        return array_unique($excluded_posts_ids);
616 616
 
617 617
     }
618 618
 
Please login to merge, or discard this patch.