Passed
Push — master ( 98a546...e8e8db )
by Brian
05:59
created
includes/data-stores/class-getpaid-item-data-store.php 1 patch
Indentation   +209 added lines, -209 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 if ( ! defined( 'ABSPATH' ) ) {
7
-	exit;
7
+    exit;
8 8
 }
9 9
 
10 10
 /**
@@ -14,228 +14,228 @@  discard block
 block discarded – undo
14 14
  */
15 15
 class GetPaid_Item_Data_Store extends GetPaid_Data_Store_WP {
16 16
 
17
-	/**
18
-	 * Data stored in meta keys, but not considered "meta" for an item.
19
-	 *
20
-	 * @since 1.0.19
21
-	 * @var array
22
-	 */
23
-	protected $internal_meta_keys = array(
24
-		'_wpinv_price',
25
-		'_wpinv_vat_rule',
26
-		'_wpinv_vat_class',
27
-		'_wpinv_type',
28
-		'_wpinv_custom_id',
29
-		'_wpinv_custom_name',
30
-		'_wpinv_custom_singular_name',
31
-		'_wpinv_editable',
32
-		'_wpinv_dynamic_pricing',
33
-		'_minimum_price',
34
-		'_wpinv_is_recurring',
35
-		'_wpinv_recurring_period',
36
-		'_wpinv_recurring_interval',
37
-		'_wpinv_recurring_limit',
38
-		'_wpinv_free_trial',
39
-		'_wpinv_trial_period',
40
-		'_wpinv_trial_interval'
41
-	);
42
-
43
-	/**
44
-	 * A map of meta keys to data props.
45
-	 *
46
-	 * @since 1.0.19
47
-	 *
48
-	 * @var array
49
-	 */
50
-	protected $meta_key_to_props = array(
51
-		'_wpinv_price'                => 'price',
52
-		'_wpinv_vat_rule'             => 'vat_rule',
53
-		'_wpinv_vat_class'            => 'vat_class',
54
-		'_wpinv_type'                 => 'type',
55
-		'_wpinv_custom_id'            => 'custom_id',
56
-		'_wpinv_custom_name'          => 'custom_name',
57
-		'_wpinv_custom_singular_name' => 'custom_singular_name',
58
-		'_wpinv_editable'             => 'is_editable',
59
-		'_wpinv_dynamic_pricing'      => 'is_dynamic_pricing',
60
-		'_minimum_price'              => 'minimum_price',
61
-		'_wpinv_custom_name'          => 'custom_name',
62
-		'_wpinv_is_recurring'         => 'is_recurring',
63
-		'_wpinv_recurring_period'     => 'recurring_period',
64
-		'_wpinv_recurring_interval'   => 'recurring_interval',
65
-		'_wpinv_recurring_limit'      => 'recurring_limit',
66
-		'_wpinv_free_trial'           => 'is_free_trial',
67
-		'_wpinv_trial_period'         => 'trial_period',
68
-		'_wpinv_trial_interval'       => 'trial_interval',
69
-		'_wpinv_version'              => 'version',
70
-	);
71
-
72
-	/*
17
+    /**
18
+     * Data stored in meta keys, but not considered "meta" for an item.
19
+     *
20
+     * @since 1.0.19
21
+     * @var array
22
+     */
23
+    protected $internal_meta_keys = array(
24
+        '_wpinv_price',
25
+        '_wpinv_vat_rule',
26
+        '_wpinv_vat_class',
27
+        '_wpinv_type',
28
+        '_wpinv_custom_id',
29
+        '_wpinv_custom_name',
30
+        '_wpinv_custom_singular_name',
31
+        '_wpinv_editable',
32
+        '_wpinv_dynamic_pricing',
33
+        '_minimum_price',
34
+        '_wpinv_is_recurring',
35
+        '_wpinv_recurring_period',
36
+        '_wpinv_recurring_interval',
37
+        '_wpinv_recurring_limit',
38
+        '_wpinv_free_trial',
39
+        '_wpinv_trial_period',
40
+        '_wpinv_trial_interval'
41
+    );
42
+
43
+    /**
44
+     * A map of meta keys to data props.
45
+     *
46
+     * @since 1.0.19
47
+     *
48
+     * @var array
49
+     */
50
+    protected $meta_key_to_props = array(
51
+        '_wpinv_price'                => 'price',
52
+        '_wpinv_vat_rule'             => 'vat_rule',
53
+        '_wpinv_vat_class'            => 'vat_class',
54
+        '_wpinv_type'                 => 'type',
55
+        '_wpinv_custom_id'            => 'custom_id',
56
+        '_wpinv_custom_name'          => 'custom_name',
57
+        '_wpinv_custom_singular_name' => 'custom_singular_name',
58
+        '_wpinv_editable'             => 'is_editable',
59
+        '_wpinv_dynamic_pricing'      => 'is_dynamic_pricing',
60
+        '_minimum_price'              => 'minimum_price',
61
+        '_wpinv_custom_name'          => 'custom_name',
62
+        '_wpinv_is_recurring'         => 'is_recurring',
63
+        '_wpinv_recurring_period'     => 'recurring_period',
64
+        '_wpinv_recurring_interval'   => 'recurring_interval',
65
+        '_wpinv_recurring_limit'      => 'recurring_limit',
66
+        '_wpinv_free_trial'           => 'is_free_trial',
67
+        '_wpinv_trial_period'         => 'trial_period',
68
+        '_wpinv_trial_interval'       => 'trial_interval',
69
+        '_wpinv_version'              => 'version',
70
+    );
71
+
72
+    /*
73 73
 	|--------------------------------------------------------------------------
74 74
 	| CRUD Methods
75 75
 	|--------------------------------------------------------------------------
76 76
 	*/
77 77
 
78
-	/**
79
-	 * Method to create a new item in the database.
80
-	 *
81
-	 * @param WPInv_Item $item Item object.
82
-	 */
83
-	public function create( &$item ) {
84
-		$item->set_version( WPINV_VERSION );
85
-		$item->set_date_created( current_time('mysql') );
86
-
87
-		// Create a new post.
88
-		$id = wp_insert_post(
89
-			apply_filters(
90
-				'getpaid_new_item_data',
91
-				array(
92
-					'post_date'     => $item->get_date_created( 'edit' ),
93
-					'post_type'     => 'wpi_item',
94
-					'post_status'   => $this->get_post_status( $item ),
95
-					'ping_status'   => 'closed',
96
-					'post_author'   => $item->get_author( 'edit' ),
97
-					'post_title'    => $item->get_name( 'edit' ),
98
-					'post_parent'   => 0,
99
-					'post_excerpt'  => $item->get_description( 'edit' ),
100
-				)
101
-			),
102
-			true
103
-		);
104
-
105
-		if ( $id && ! is_wp_error( $id ) ) {
106
-			$item->set_id( $id );
107
-			$this->update_post_meta( $item );
108
-			$item->save_meta_data();
109
-			$item->apply_changes();
110
-			$this->clear_caches( $item );
111
-			do_action( 'getpaid_new_item', $item );
112
-			return true;
113
-		}
114
-
115
-		if ( is_wp_error( $id ) ) {
116
-			$item->last_error = $id->get_error_message();
117
-		}
78
+    /**
79
+     * Method to create a new item in the database.
80
+     *
81
+     * @param WPInv_Item $item Item object.
82
+     */
83
+    public function create( &$item ) {
84
+        $item->set_version( WPINV_VERSION );
85
+        $item->set_date_created( current_time('mysql') );
86
+
87
+        // Create a new post.
88
+        $id = wp_insert_post(
89
+            apply_filters(
90
+                'getpaid_new_item_data',
91
+                array(
92
+                    'post_date'     => $item->get_date_created( 'edit' ),
93
+                    'post_type'     => 'wpi_item',
94
+                    'post_status'   => $this->get_post_status( $item ),
95
+                    'ping_status'   => 'closed',
96
+                    'post_author'   => $item->get_author( 'edit' ),
97
+                    'post_title'    => $item->get_name( 'edit' ),
98
+                    'post_parent'   => 0,
99
+                    'post_excerpt'  => $item->get_description( 'edit' ),
100
+                )
101
+            ),
102
+            true
103
+        );
104
+
105
+        if ( $id && ! is_wp_error( $id ) ) {
106
+            $item->set_id( $id );
107
+            $this->update_post_meta( $item );
108
+            $item->save_meta_data();
109
+            $item->apply_changes();
110
+            $this->clear_caches( $item );
111
+            do_action( 'getpaid_new_item', $item );
112
+            return true;
113
+        }
114
+
115
+        if ( is_wp_error( $id ) ) {
116
+            $item->last_error = $id->get_error_message();
117
+        }
118 118
 		
119
-		return false;
120
-	}
121
-
122
-	/**
123
-	 * Method to read an item from the database.
124
-	 *
125
-	 * @param WPInv_Item $item Item object.
126
-	 *
127
-	 */
128
-	public function read( &$item ) {
129
-
130
-		$item->set_defaults();
131
-		$item_object = get_post( $item->get_id() );
132
-
133
-		if ( ! $item->get_id() || ! $item_object || $item_object->post_type != 'wpi_item' ) {
134
-			$item->last_error = __( 'Invalid item.', 'invoicing' );
135
-			$item->set_id( 0 );
136
-			return false;
137
-		}
138
-
139
-		$item->set_props(
140
-			array(
141
-				'parent_id'     => $item_object->post_parent,
142
-				'date_created'  => 0 < $item_object->post_date ? $item_object->post_date : null,
143
-				'date_modified' => 0 < $item_object->post_modified ? $item_object->post_modified : null,
144
-				'status'        => $item_object->post_status,
145
-				'name'          => $item_object->post_title,
146
-				'description'   => $item_object->post_excerpt,
147
-				'author'        => $item_object->post_author,
148
-			)
149
-		);
150
-
151
-		$this->read_object_data( $item, $item_object );
152
-		$item->read_meta_data();
153
-		$item->set_object_read( true );
154
-		do_action( 'getpaid_read_item', $item );
155
-
156
-	}
157
-
158
-	/**
159
-	 * Method to update an item in the database.
160
-	 *
161
-	 * @param WPInv_Item $item Item object.
162
-	 */
163
-	public function update( &$item ) {
164
-		$item->save_meta_data();
165
-		$item->set_version( WPINV_VERSION );
166
-
167
-		if ( null === $item->get_date_created( 'edit' ) ) {
168
-			$item->set_date_created(  current_time('mysql') );
169
-		}
170
-
171
-		// Grab the current status so we can compare.
172
-		$previous_status = get_post_status( $item->get_id() );
173
-
174
-		$changes = $item->get_changes();
175
-
176
-		// Only update the post when the post data changes.
177
-		if ( array_intersect( array( 'date_created', 'date_modified', 'status', 'parent_id', 'description', 'name', 'author' ), array_keys( $changes ) ) ) {
178
-			$post_data = array(
179
-				'post_date'         => $item->get_date_created( 'edit' ),
180
-				'post_status'       => $item->get_status( 'edit' ),
181
-				'post_parent'       => $item->get_parent_id( 'edit' ),
182
-				'post_excerpt'      => $item->get_description( 'edit' ),
183
-				'post_modified'     => $item->get_date_modified( 'edit' ),
184
-				'post_title'        => $item->get_name( 'edit' ),
185
-				'post_author'       => $item->get_author( 'edit' ),
186
-			);
187
-
188
-			/**
189
-			 * When updating this object, to prevent infinite loops, use $wpdb
190
-			 * to update data, since wp_update_post spawns more calls to the
191
-			 * save_post action.
192
-			 *
193
-			 * This ensures hooks are fired by either WP itself (admin screen save),
194
-			 * or an update purely from CRUD.
195
-			 */
196
-			if ( doing_action( 'save_post' ) ) {
197
-				$GLOBALS['wpdb']->update( $GLOBALS['wpdb']->posts, $post_data, array( 'ID' => $item->get_id() ) );
198
-				clean_post_cache( $item->get_id() );
199
-			} else {
200
-				wp_update_post( array_merge( array( 'ID' => $item->get_id() ), $post_data ) );
201
-			}
202
-			$item->read_meta_data( true ); // Refresh internal meta data, in case things were hooked into `save_post` or another WP hook.
203
-		}
204
-		$this->update_post_meta( $item );
205
-		$item->apply_changes();
206
-		$this->clear_caches( $item );
207
-
208
-		// Fire a hook depending on the status - this should be considered a creation if it was previously draft status.
209
-		$new_status = $item->get_status( 'edit' );
210
-
211
-		if ( $new_status !== $previous_status && in_array( $previous_status, array( 'new', 'auto-draft', 'draft' ), true ) ) {
212
-			do_action( 'getpaid_new_item', $item );
213
-		} else {
214
-			do_action( 'getpaid_update_item', $item );
215
-		}
216
-
217
-	}
218
-
219
-	/*
119
+        return false;
120
+    }
121
+
122
+    /**
123
+     * Method to read an item from the database.
124
+     *
125
+     * @param WPInv_Item $item Item object.
126
+     *
127
+     */
128
+    public function read( &$item ) {
129
+
130
+        $item->set_defaults();
131
+        $item_object = get_post( $item->get_id() );
132
+
133
+        if ( ! $item->get_id() || ! $item_object || $item_object->post_type != 'wpi_item' ) {
134
+            $item->last_error = __( 'Invalid item.', 'invoicing' );
135
+            $item->set_id( 0 );
136
+            return false;
137
+        }
138
+
139
+        $item->set_props(
140
+            array(
141
+                'parent_id'     => $item_object->post_parent,
142
+                'date_created'  => 0 < $item_object->post_date ? $item_object->post_date : null,
143
+                'date_modified' => 0 < $item_object->post_modified ? $item_object->post_modified : null,
144
+                'status'        => $item_object->post_status,
145
+                'name'          => $item_object->post_title,
146
+                'description'   => $item_object->post_excerpt,
147
+                'author'        => $item_object->post_author,
148
+            )
149
+        );
150
+
151
+        $this->read_object_data( $item, $item_object );
152
+        $item->read_meta_data();
153
+        $item->set_object_read( true );
154
+        do_action( 'getpaid_read_item', $item );
155
+
156
+    }
157
+
158
+    /**
159
+     * Method to update an item in the database.
160
+     *
161
+     * @param WPInv_Item $item Item object.
162
+     */
163
+    public function update( &$item ) {
164
+        $item->save_meta_data();
165
+        $item->set_version( WPINV_VERSION );
166
+
167
+        if ( null === $item->get_date_created( 'edit' ) ) {
168
+            $item->set_date_created(  current_time('mysql') );
169
+        }
170
+
171
+        // Grab the current status so we can compare.
172
+        $previous_status = get_post_status( $item->get_id() );
173
+
174
+        $changes = $item->get_changes();
175
+
176
+        // Only update the post when the post data changes.
177
+        if ( array_intersect( array( 'date_created', 'date_modified', 'status', 'parent_id', 'description', 'name', 'author' ), array_keys( $changes ) ) ) {
178
+            $post_data = array(
179
+                'post_date'         => $item->get_date_created( 'edit' ),
180
+                'post_status'       => $item->get_status( 'edit' ),
181
+                'post_parent'       => $item->get_parent_id( 'edit' ),
182
+                'post_excerpt'      => $item->get_description( 'edit' ),
183
+                'post_modified'     => $item->get_date_modified( 'edit' ),
184
+                'post_title'        => $item->get_name( 'edit' ),
185
+                'post_author'       => $item->get_author( 'edit' ),
186
+            );
187
+
188
+            /**
189
+             * When updating this object, to prevent infinite loops, use $wpdb
190
+             * to update data, since wp_update_post spawns more calls to the
191
+             * save_post action.
192
+             *
193
+             * This ensures hooks are fired by either WP itself (admin screen save),
194
+             * or an update purely from CRUD.
195
+             */
196
+            if ( doing_action( 'save_post' ) ) {
197
+                $GLOBALS['wpdb']->update( $GLOBALS['wpdb']->posts, $post_data, array( 'ID' => $item->get_id() ) );
198
+                clean_post_cache( $item->get_id() );
199
+            } else {
200
+                wp_update_post( array_merge( array( 'ID' => $item->get_id() ), $post_data ) );
201
+            }
202
+            $item->read_meta_data( true ); // Refresh internal meta data, in case things were hooked into `save_post` or another WP hook.
203
+        }
204
+        $this->update_post_meta( $item );
205
+        $item->apply_changes();
206
+        $this->clear_caches( $item );
207
+
208
+        // Fire a hook depending on the status - this should be considered a creation if it was previously draft status.
209
+        $new_status = $item->get_status( 'edit' );
210
+
211
+        if ( $new_status !== $previous_status && in_array( $previous_status, array( 'new', 'auto-draft', 'draft' ), true ) ) {
212
+            do_action( 'getpaid_new_item', $item );
213
+        } else {
214
+            do_action( 'getpaid_update_item', $item );
215
+        }
216
+
217
+    }
218
+
219
+    /*
220 220
 	|--------------------------------------------------------------------------
221 221
 	| Additional Methods
222 222
 	|--------------------------------------------------------------------------
223 223
 	*/
224 224
 
225
-	/**
226
-	 * Helper method that updates all the post meta for an item based on it's settings in the WPInv_Item class.
227
-	 *
228
-	 * @param WPInv_Item $item WPInv_Item object.
229
-	 * @since 1.0.19
230
-	 */
231
-	protected function update_post_meta( &$item ) {
225
+    /**
226
+     * Helper method that updates all the post meta for an item based on it's settings in the WPInv_Item class.
227
+     *
228
+     * @param WPInv_Item $item WPInv_Item object.
229
+     * @since 1.0.19
230
+     */
231
+    protected function update_post_meta( &$item ) {
232 232
 
233
-		// Ensure that we have a custom id.
233
+        // Ensure that we have a custom id.
234 234
         if ( ! $item->get_custom_id() ) {
235 235
             $item->set_custom_id( $item->get_id() );
236
-		}
236
+        }
237 237
 
238
-		parent::update_post_meta( $item );
239
-	}
238
+        parent::update_post_meta( $item );
239
+    }
240 240
 
241 241
 }
Please login to merge, or discard this patch.
vendor/composer/installers/src/Composer/Installers/OxidInstaller.php 1 patch
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
 
6 6
 class OxidInstaller extends BaseInstaller
7 7
 {
8
-	const VENDOR_PATTERN = '/^modules\/(?P<vendor>.+)\/.+/';
8
+    const VENDOR_PATTERN = '/^modules\/(?P<vendor>.+)\/.+/';
9 9
 
10 10
     protected $locations = array(
11 11
         'module'    => 'modules/{$name}/',
@@ -13,47 +13,47 @@  discard block
 block discarded – undo
13 13
         'out'    => 'out/{$name}/',
14 14
     );
15 15
 
16
-	/**
17
-	 * getInstallPath
18
-	 *
19
-	 * @param PackageInterface $package
20
-	 * @param string $frameworkType
21
-	 * @return string
22
-	 */
23
-	public function getInstallPath(PackageInterface $package, $frameworkType = '')
24
-	{
25
-		$installPath = parent::getInstallPath($package, $frameworkType);
26
-		$type = $this->package->getType();
27
-		if ($type === 'oxid-module') {
28
-			$this->prepareVendorDirectory($installPath);
29
-		}
30
-		return $installPath;
31
-	}
16
+    /**
17
+     * getInstallPath
18
+     *
19
+     * @param PackageInterface $package
20
+     * @param string $frameworkType
21
+     * @return string
22
+     */
23
+    public function getInstallPath(PackageInterface $package, $frameworkType = '')
24
+    {
25
+        $installPath = parent::getInstallPath($package, $frameworkType);
26
+        $type = $this->package->getType();
27
+        if ($type === 'oxid-module') {
28
+            $this->prepareVendorDirectory($installPath);
29
+        }
30
+        return $installPath;
31
+    }
32 32
 
33
-	/**
34
-	 * prepareVendorDirectory
35
-	 *
36
-	 * Makes sure there is a vendormetadata.php file inside
37
-	 * the vendor folder if there is a vendor folder.
38
-	 *
39
-	 * @param string $installPath
40
-	 * @return void
41
-	 */
42
-	protected function prepareVendorDirectory($installPath)
43
-	{
44
-		$matches = '';
45
-		$hasVendorDirectory = preg_match(self::VENDOR_PATTERN, $installPath, $matches);
46
-		if (!$hasVendorDirectory) {
47
-			return;
48
-		}
33
+    /**
34
+     * prepareVendorDirectory
35
+     *
36
+     * Makes sure there is a vendormetadata.php file inside
37
+     * the vendor folder if there is a vendor folder.
38
+     *
39
+     * @param string $installPath
40
+     * @return void
41
+     */
42
+    protected function prepareVendorDirectory($installPath)
43
+    {
44
+        $matches = '';
45
+        $hasVendorDirectory = preg_match(self::VENDOR_PATTERN, $installPath, $matches);
46
+        if (!$hasVendorDirectory) {
47
+            return;
48
+        }
49 49
 
50
-		$vendorDirectory = $matches['vendor'];
51
-		$vendorPath = getcwd() . '/modules/' . $vendorDirectory;
52
-		if (!file_exists($vendorPath)) {
53
-			mkdir($vendorPath, 0755, true);
54
-		}
50
+        $vendorDirectory = $matches['vendor'];
51
+        $vendorPath = getcwd() . '/modules/' . $vendorDirectory;
52
+        if (!file_exists($vendorPath)) {
53
+            mkdir($vendorPath, 0755, true);
54
+        }
55 55
 
56
-		$vendorMetaDataPath = $vendorPath . '/vendormetadata.php';
57
-		touch($vendorMetaDataPath);
58
-	}
56
+        $vendorMetaDataPath = $vendorPath . '/vendormetadata.php';
57
+        touch($vendorMetaDataPath);
58
+    }
59 59
 }
Please login to merge, or discard this patch.
ayecode/wp-ayecode-ui/includes/components/class-aui-component-helper.php 1 patch
Indentation   +369 added lines, -369 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if ( ! defined( 'ABSPATH' ) ) {
4
-	exit; // Exit if accessed directly
4
+    exit; // Exit if accessed directly
5 5
 }
6 6
 
7 7
 /**
@@ -11,372 +11,372 @@  discard block
 block discarded – undo
11 11
  */
12 12
 class AUI_Component_Helper {
13 13
 
14
-	/**
15
-	 * A component helper for generating a input name.
16
-	 *
17
-	 * @param $text
18
-	 * @param $multiple bool If the name is set to be multiple but no brackets found then we add some.
19
-	 *
20
-	 * @return string
21
-	 */
22
-	public static function name($text,$multiple = false){
23
-		$output = '';
24
-
25
-		if($text){
26
-			$is_multiple = strpos($text, '[') === false && $multiple  ? '[]' : '';
27
-			$output = ' name="'.esc_attr($text).$is_multiple.'" ';
28
-		}
29
-
30
-		return $output;
31
-	}
32
-
33
-	/**
34
-	 * A component helper for generating a item id.
35
-	 *
36
-	 * @param $text string The text to be used as the value.
37
-	 *
38
-	 * @return string The sanitized item.
39
-	 */
40
-	public static function id($text){
41
-		$output = '';
42
-
43
-		if($text){
44
-			$output = ' id="'.sanitize_html_class($text).'" ';
45
-		}
46
-
47
-		return $output;
48
-	}
49
-
50
-	/**
51
-	 * A component helper for generating a item title.
52
-	 *
53
-	 * @param $text string The text to be used as the value.
54
-	 *
55
-	 * @return string The sanitized item.
56
-	 */
57
-	public static function title($text){
58
-		$output = '';
59
-
60
-		if($text){
61
-			$output = ' title="'.esc_attr($text).'" ';
62
-		}
63
-
64
-		return $output;
65
-	}
66
-
67
-	/**
68
-	 * A component helper for generating a item value.
69
-	 *
70
-	 * @param $text string The text to be used as the value.
71
-	 *
72
-	 * @return string The sanitized item.
73
-	 */
74
-	public static function value($text){
75
-		$output = '';
76
-
77
-		if($text){
78
-			$output = ' value="'.sanitize_text_field($text).'" ';
79
-		}
80
-
81
-		return $output;
82
-	}
83
-
84
-	/**
85
-	 * A component helper for generating a item class attribute.
86
-	 *
87
-	 * @param $text string The text to be used as the value.
88
-	 *
89
-	 * @return string The sanitized item.
90
-	 */
91
-	public static function class_attr($text){
92
-		$output = '';
93
-
94
-		if($text){
95
-			$classes = self::esc_classes($text);
96
-			if(!empty($classes)){
97
-				$output = ' class="'.$classes.'" ';
98
-			}
99
-		}
100
-
101
-		return $output;
102
-	}
103
-
104
-	/**
105
-	 * Escape a string of classes.
106
-	 *
107
-	 * @param $text
108
-	 *
109
-	 * @return string
110
-	 */
111
-	public static function esc_classes($text){
112
-		$output = '';
113
-
114
-		if($text){
115
-			$classes = explode(" ",$text);
116
-			$classes = array_map("trim",$classes);
117
-			$classes = array_map("sanitize_html_class",$classes);
118
-			if(!empty($classes)){
119
-				$output = implode(" ",$classes);
120
-			}
121
-		}
122
-
123
-		return $output;
124
-
125
-	}
126
-
127
-	/**
128
-	 * @param $args
129
-	 *
130
-	 * @return string
131
-	 */
132
-	public static function data_attributes($args){
133
-		$output = '';
134
-
135
-		if(!empty($args)){
136
-
137
-			foreach($args as $key => $val){
138
-				if(substr( $key, 0, 5 ) === "data-"){
139
-					$output .= ' '.sanitize_html_class($key).'="'.esc_attr($val).'" ';
140
-				}
141
-			}
142
-		}
143
-
144
-		return $output;
145
-	}
146
-
147
-	/**
148
-	 * @param $args
149
-	 *
150
-	 * @return string
151
-	 */
152
-	public static function aria_attributes($args){
153
-		$output = '';
154
-
155
-		if(!empty($args)){
156
-
157
-			foreach($args as $key => $val){
158
-				if(substr( $key, 0, 5 ) === "aria-"){
159
-					$output .= ' '.sanitize_html_class($key).'="'.esc_attr($val).'" ';
160
-				}
161
-			}
162
-		}
163
-
164
-		return $output;
165
-	}
166
-
167
-	/**
168
-	 * Build a font awesome icon from a class.
169
-	 *
170
-	 * @param $class
171
-	 * @param bool $space_after
172
-	 * @param array $extra_attributes An array of extra attributes.
173
-	 *
174
-	 * @return string
175
-	 */
176
-	public static function icon($class,$space_after = false, $extra_attributes = array()){
177
-		$output = '';
178
-
179
-		if($class){
180
-			$classes = self::esc_classes($class);
181
-			if(!empty($classes)){
182
-				$output = '<i class="'.$classes.'" ';
183
-				// extra attributes
184
-				if(!empty($extra_attributes)){
185
-					$output .= AUI_Component_Helper::extra_attributes($extra_attributes);
186
-				}
187
-				$output .= '></i>';
188
-				if($space_after){
189
-					$output .= " ";
190
-				}
191
-			}
192
-		}
193
-
194
-		return $output;
195
-	}
196
-
197
-	/**
198
-	 * @param $args
199
-	 *
200
-	 * @return string
201
-	 */
202
-	public static function extra_attributes($args){
203
-		$output = '';
204
-
205
-		if(!empty($args)){
206
-
207
-			if( is_array($args) ){
208
-				foreach($args as $key => $val){
209
-					$output .= ' '.sanitize_html_class($key).'="'.esc_attr($val).'" ';
210
-				}
211
-			}else{
212
-				$output .= ' '.$args.' ';
213
-			}
214
-
215
-		}
216
-
217
-		return $output;
218
-	}
219
-
220
-	/**
221
-	 * @param $args
222
-	 *
223
-	 * @return string
224
-	 */
225
-	public static function help_text($text){
226
-		$output = '';
227
-
228
-		if($text){
229
-			$output .= '<small class="form-text text-muted">'.wp_kses_post($text).'</small>';
230
-		}
231
-
232
-
233
-		return $output;
234
-	}
235
-
236
-	/**
237
-	 * Replace element require context with JS.
238
-	 *
239
-	 * @param $input
240
-	 *
241
-	 * @return string|void
242
-	 */
243
-	public static function element_require( $input ) {
244
-
245
-		$input = str_replace( "'", '"', $input );// we only want double quotes
246
-
247
-		$output = esc_attr( str_replace( array( "[%", "%]", "%:checked]" ), array(
248
-			"jQuery(form).find('[data-argument=\"",
249
-			"\"]').find('input,select,textarea').val()",
250
-			"\"]').find('input:checked').val()",
251
-		), $input ) );
252
-
253
-		if($output){
254
-			$output = ' data-element-require="'.$output.'" ';
255
-		}
256
-
257
-		return $output;
258
-	}
259
-
260
-	/**
261
-	 * Returns an array of allowed HTML tags and attributes for a given context.
262
-	 *
263
-	 * @since 0.1.41
264
-	 *
265
-	 * @param string|array $context The context for which to retrieve tags. Allowed values are 'post',
266
-	 *                              'strip', 'data', 'entities', or the name of a field filter such as
267
-	 *                              'pre_user_description'.
268
-	 * @param array $input Input.
269
-	 * @return array Array of allowed HTML tags and their allowed attributes.
270
-	 */
271
-	public static function kses_allowed_html( $context = 'post', $input = array() ) {
272
-		$allowed_html = wp_kses_allowed_html( $context );
273
-
274
-		if ( is_array( $allowed_html ) ) {
275
-			// <iframe>
276
-			if ( ! isset( $allowed_html['iframe'] ) && $context == 'post' ) {
277
-				$allowed_html['iframe']     = array(
278
-					'class'        => true,
279
-					'id'           => true,
280
-					'src'          => true,
281
-					'width'        => true,
282
-					'height'       => true,
283
-					'frameborder'  => true,
284
-					'marginwidth'  => true,
285
-					'marginheight' => true,
286
-					'scrolling'    => true,
287
-					'style'        => true,
288
-					'title'        => true,
289
-					'allow'        => true,
290
-					'allowfullscreen' => true,
291
-					'data-*'       => true,
292
-				);
293
-			}
294
-		}
295
-
296
-		/**
297
-		 * Filters the allowed html tags.
298
-		 *
299
-		 * @since 0.1.41
300
-		 *
301
-		 * @param array[]|string $allowed_html Allowed html tags.
302
-		 * @param @param string|array $context The context for which to retrieve tags.
303
-		 * @param array $input Input field.
304
-		 */
305
-		return apply_filters( 'ayecode_ui_kses_allowed_html', $allowed_html, $context, $input );
306
-	}
307
-
308
-	/**
309
-	 * Filters content and keeps only allowable HTML elements.
310
-	 *
311
-	 * This function makes sure that only the allowed HTML element names, attribute
312
-	 * names and attribute values plus only sane HTML entities will occur in
313
-	 * $string. You have to remove any slashes from PHP's magic quotes before you
314
-	 * call this function.
315
-	 *
316
-	 * The default allowed protocols are 'http', 'https', 'ftp', 'mailto', 'news',
317
-	 * 'irc', 'gopher', 'nntp', 'feed', 'telnet, 'mms', 'rtsp' and 'svn'. This
318
-	 * covers all common link protocols, except for 'javascript' which should not
319
-	 * be allowed for untrusted users.
320
-	 *
321
-	 * @since 0.1.41
322
-	 *
323
-	 * @param string|array $value Content to filter through kses.
324
-	 * @param array  $input       Input Field.
325
-	 * @return string Filtered content with only allowed HTML elements.
326
-	 */
327
-	public static function _sanitize_html_field( $value, $input = array() ) {
328
-		if ( $value === '' ) {
329
-			return $value;
330
-		}
331
-
332
-		$allowed_html = self::kses_allowed_html( 'post', $input );
333
-
334
-		if ( ! is_array( $allowed_html ) ) {
335
-			$allowed_html = wp_kses_allowed_html( 'post' );
336
-		}
337
-
338
-		$filtered = trim( wp_unslash( $value ) );
339
-		$filtered = wp_kses( $filtered, $allowed_html );
340
-		$filtered = balanceTags( $filtered ); // Balances tags
341
-
342
-		return $filtered;
343
-	}
344
-
345
-	/**
346
-	 * Navigates through an array, object, or scalar, and removes slashes from the values.
347
-	 *
348
-	 * @since 0.1.41
349
-	 *
350
-	 * @param mixed $value The value to be stripped.
351
-	 * @param array  $input Input Field.
352
-	 * @return mixed Stripped value.
353
-	 */
354
-	public static function sanitize_html_field( $value, $input = array() ) {
355
-		$original = $value;
356
-
357
-		if ( is_array( $value ) ) {
358
-			foreach ( $value as $index => $item ) {
359
-				$value[ $index ] = self::_sanitize_html_field( $value, $input );
360
-			}
361
-		} elseif ( is_object( $value ) ) {
362
-			$object_vars = get_object_vars( $value );
363
-
364
-			foreach ( $object_vars as $property_name => $property_value ) {
365
-				$value->$property_name = self::_sanitize_html_field( $property_value, $input );
366
-			}
367
-		} else {
368
-			$value = self::_sanitize_html_field( $value, $input );
369
-		}
370
-
371
-		/**
372
-		 * Filters content and keeps only allowable HTML elements.
373
-		 *
374
-		 * @since 0.1.41
375
-		 *
376
-		 * @param string|array $value Content to filter through kses.
377
-		 * @param string|array $value Original content without filter.
378
-		 * @param array  $input       Input Field.
379
-		 */
380
-		return apply_filters( 'ayecode_ui_sanitize_html_field', $value, $original, $input );
381
-	}
14
+    /**
15
+     * A component helper for generating a input name.
16
+     *
17
+     * @param $text
18
+     * @param $multiple bool If the name is set to be multiple but no brackets found then we add some.
19
+     *
20
+     * @return string
21
+     */
22
+    public static function name($text,$multiple = false){
23
+        $output = '';
24
+
25
+        if($text){
26
+            $is_multiple = strpos($text, '[') === false && $multiple  ? '[]' : '';
27
+            $output = ' name="'.esc_attr($text).$is_multiple.'" ';
28
+        }
29
+
30
+        return $output;
31
+    }
32
+
33
+    /**
34
+     * A component helper for generating a item id.
35
+     *
36
+     * @param $text string The text to be used as the value.
37
+     *
38
+     * @return string The sanitized item.
39
+     */
40
+    public static function id($text){
41
+        $output = '';
42
+
43
+        if($text){
44
+            $output = ' id="'.sanitize_html_class($text).'" ';
45
+        }
46
+
47
+        return $output;
48
+    }
49
+
50
+    /**
51
+     * A component helper for generating a item title.
52
+     *
53
+     * @param $text string The text to be used as the value.
54
+     *
55
+     * @return string The sanitized item.
56
+     */
57
+    public static function title($text){
58
+        $output = '';
59
+
60
+        if($text){
61
+            $output = ' title="'.esc_attr($text).'" ';
62
+        }
63
+
64
+        return $output;
65
+    }
66
+
67
+    /**
68
+     * A component helper for generating a item value.
69
+     *
70
+     * @param $text string The text to be used as the value.
71
+     *
72
+     * @return string The sanitized item.
73
+     */
74
+    public static function value($text){
75
+        $output = '';
76
+
77
+        if($text){
78
+            $output = ' value="'.sanitize_text_field($text).'" ';
79
+        }
80
+
81
+        return $output;
82
+    }
83
+
84
+    /**
85
+     * A component helper for generating a item class attribute.
86
+     *
87
+     * @param $text string The text to be used as the value.
88
+     *
89
+     * @return string The sanitized item.
90
+     */
91
+    public static function class_attr($text){
92
+        $output = '';
93
+
94
+        if($text){
95
+            $classes = self::esc_classes($text);
96
+            if(!empty($classes)){
97
+                $output = ' class="'.$classes.'" ';
98
+            }
99
+        }
100
+
101
+        return $output;
102
+    }
103
+
104
+    /**
105
+     * Escape a string of classes.
106
+     *
107
+     * @param $text
108
+     *
109
+     * @return string
110
+     */
111
+    public static function esc_classes($text){
112
+        $output = '';
113
+
114
+        if($text){
115
+            $classes = explode(" ",$text);
116
+            $classes = array_map("trim",$classes);
117
+            $classes = array_map("sanitize_html_class",$classes);
118
+            if(!empty($classes)){
119
+                $output = implode(" ",$classes);
120
+            }
121
+        }
122
+
123
+        return $output;
124
+
125
+    }
126
+
127
+    /**
128
+     * @param $args
129
+     *
130
+     * @return string
131
+     */
132
+    public static function data_attributes($args){
133
+        $output = '';
134
+
135
+        if(!empty($args)){
136
+
137
+            foreach($args as $key => $val){
138
+                if(substr( $key, 0, 5 ) === "data-"){
139
+                    $output .= ' '.sanitize_html_class($key).'="'.esc_attr($val).'" ';
140
+                }
141
+            }
142
+        }
143
+
144
+        return $output;
145
+    }
146
+
147
+    /**
148
+     * @param $args
149
+     *
150
+     * @return string
151
+     */
152
+    public static function aria_attributes($args){
153
+        $output = '';
154
+
155
+        if(!empty($args)){
156
+
157
+            foreach($args as $key => $val){
158
+                if(substr( $key, 0, 5 ) === "aria-"){
159
+                    $output .= ' '.sanitize_html_class($key).'="'.esc_attr($val).'" ';
160
+                }
161
+            }
162
+        }
163
+
164
+        return $output;
165
+    }
166
+
167
+    /**
168
+     * Build a font awesome icon from a class.
169
+     *
170
+     * @param $class
171
+     * @param bool $space_after
172
+     * @param array $extra_attributes An array of extra attributes.
173
+     *
174
+     * @return string
175
+     */
176
+    public static function icon($class,$space_after = false, $extra_attributes = array()){
177
+        $output = '';
178
+
179
+        if($class){
180
+            $classes = self::esc_classes($class);
181
+            if(!empty($classes)){
182
+                $output = '<i class="'.$classes.'" ';
183
+                // extra attributes
184
+                if(!empty($extra_attributes)){
185
+                    $output .= AUI_Component_Helper::extra_attributes($extra_attributes);
186
+                }
187
+                $output .= '></i>';
188
+                if($space_after){
189
+                    $output .= " ";
190
+                }
191
+            }
192
+        }
193
+
194
+        return $output;
195
+    }
196
+
197
+    /**
198
+     * @param $args
199
+     *
200
+     * @return string
201
+     */
202
+    public static function extra_attributes($args){
203
+        $output = '';
204
+
205
+        if(!empty($args)){
206
+
207
+            if( is_array($args) ){
208
+                foreach($args as $key => $val){
209
+                    $output .= ' '.sanitize_html_class($key).'="'.esc_attr($val).'" ';
210
+                }
211
+            }else{
212
+                $output .= ' '.$args.' ';
213
+            }
214
+
215
+        }
216
+
217
+        return $output;
218
+    }
219
+
220
+    /**
221
+     * @param $args
222
+     *
223
+     * @return string
224
+     */
225
+    public static function help_text($text){
226
+        $output = '';
227
+
228
+        if($text){
229
+            $output .= '<small class="form-text text-muted">'.wp_kses_post($text).'</small>';
230
+        }
231
+
232
+
233
+        return $output;
234
+    }
235
+
236
+    /**
237
+     * Replace element require context with JS.
238
+     *
239
+     * @param $input
240
+     *
241
+     * @return string|void
242
+     */
243
+    public static function element_require( $input ) {
244
+
245
+        $input = str_replace( "'", '"', $input );// we only want double quotes
246
+
247
+        $output = esc_attr( str_replace( array( "[%", "%]", "%:checked]" ), array(
248
+            "jQuery(form).find('[data-argument=\"",
249
+            "\"]').find('input,select,textarea').val()",
250
+            "\"]').find('input:checked').val()",
251
+        ), $input ) );
252
+
253
+        if($output){
254
+            $output = ' data-element-require="'.$output.'" ';
255
+        }
256
+
257
+        return $output;
258
+    }
259
+
260
+    /**
261
+     * Returns an array of allowed HTML tags and attributes for a given context.
262
+     *
263
+     * @since 0.1.41
264
+     *
265
+     * @param string|array $context The context for which to retrieve tags. Allowed values are 'post',
266
+     *                              'strip', 'data', 'entities', or the name of a field filter such as
267
+     *                              'pre_user_description'.
268
+     * @param array $input Input.
269
+     * @return array Array of allowed HTML tags and their allowed attributes.
270
+     */
271
+    public static function kses_allowed_html( $context = 'post', $input = array() ) {
272
+        $allowed_html = wp_kses_allowed_html( $context );
273
+
274
+        if ( is_array( $allowed_html ) ) {
275
+            // <iframe>
276
+            if ( ! isset( $allowed_html['iframe'] ) && $context == 'post' ) {
277
+                $allowed_html['iframe']     = array(
278
+                    'class'        => true,
279
+                    'id'           => true,
280
+                    'src'          => true,
281
+                    'width'        => true,
282
+                    'height'       => true,
283
+                    'frameborder'  => true,
284
+                    'marginwidth'  => true,
285
+                    'marginheight' => true,
286
+                    'scrolling'    => true,
287
+                    'style'        => true,
288
+                    'title'        => true,
289
+                    'allow'        => true,
290
+                    'allowfullscreen' => true,
291
+                    'data-*'       => true,
292
+                );
293
+            }
294
+        }
295
+
296
+        /**
297
+         * Filters the allowed html tags.
298
+         *
299
+         * @since 0.1.41
300
+         *
301
+         * @param array[]|string $allowed_html Allowed html tags.
302
+         * @param @param string|array $context The context for which to retrieve tags.
303
+         * @param array $input Input field.
304
+         */
305
+        return apply_filters( 'ayecode_ui_kses_allowed_html', $allowed_html, $context, $input );
306
+    }
307
+
308
+    /**
309
+     * Filters content and keeps only allowable HTML elements.
310
+     *
311
+     * This function makes sure that only the allowed HTML element names, attribute
312
+     * names and attribute values plus only sane HTML entities will occur in
313
+     * $string. You have to remove any slashes from PHP's magic quotes before you
314
+     * call this function.
315
+     *
316
+     * The default allowed protocols are 'http', 'https', 'ftp', 'mailto', 'news',
317
+     * 'irc', 'gopher', 'nntp', 'feed', 'telnet, 'mms', 'rtsp' and 'svn'. This
318
+     * covers all common link protocols, except for 'javascript' which should not
319
+     * be allowed for untrusted users.
320
+     *
321
+     * @since 0.1.41
322
+     *
323
+     * @param string|array $value Content to filter through kses.
324
+     * @param array  $input       Input Field.
325
+     * @return string Filtered content with only allowed HTML elements.
326
+     */
327
+    public static function _sanitize_html_field( $value, $input = array() ) {
328
+        if ( $value === '' ) {
329
+            return $value;
330
+        }
331
+
332
+        $allowed_html = self::kses_allowed_html( 'post', $input );
333
+
334
+        if ( ! is_array( $allowed_html ) ) {
335
+            $allowed_html = wp_kses_allowed_html( 'post' );
336
+        }
337
+
338
+        $filtered = trim( wp_unslash( $value ) );
339
+        $filtered = wp_kses( $filtered, $allowed_html );
340
+        $filtered = balanceTags( $filtered ); // Balances tags
341
+
342
+        return $filtered;
343
+    }
344
+
345
+    /**
346
+     * Navigates through an array, object, or scalar, and removes slashes from the values.
347
+     *
348
+     * @since 0.1.41
349
+     *
350
+     * @param mixed $value The value to be stripped.
351
+     * @param array  $input Input Field.
352
+     * @return mixed Stripped value.
353
+     */
354
+    public static function sanitize_html_field( $value, $input = array() ) {
355
+        $original = $value;
356
+
357
+        if ( is_array( $value ) ) {
358
+            foreach ( $value as $index => $item ) {
359
+                $value[ $index ] = self::_sanitize_html_field( $value, $input );
360
+            }
361
+        } elseif ( is_object( $value ) ) {
362
+            $object_vars = get_object_vars( $value );
363
+
364
+            foreach ( $object_vars as $property_name => $property_value ) {
365
+                $value->$property_name = self::_sanitize_html_field( $property_value, $input );
366
+            }
367
+        } else {
368
+            $value = self::_sanitize_html_field( $value, $input );
369
+        }
370
+
371
+        /**
372
+         * Filters content and keeps only allowable HTML elements.
373
+         *
374
+         * @since 0.1.41
375
+         *
376
+         * @param string|array $value Content to filter through kses.
377
+         * @param string|array $value Original content without filter.
378
+         * @param array  $input       Input Field.
379
+         */
380
+        return apply_filters( 'ayecode_ui_sanitize_html_field', $value, $original, $input );
381
+    }
382 382
 }
383 383
\ No newline at end of file
Please login to merge, or discard this patch.
includes/data/eu-states.php 1 patch
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -9,31 +9,31 @@
 block discarded – undo
9 9
 defined( 'ABSPATH' ) || exit;
10 10
 
11 11
 return array(
12
-	'AT',
13
-	'BE',
14
-	'BG',
15
-	'HR',
16
-	'CY',
17
-	'CZ',
18
-	'DK',
19
-	'EE',
20
-	'FI',
21
-	'FR',
22
-	'DE',
23
-	'GR',
24
-	'HU',
25
-	'IE',
26
-	'IT',
27
-	'LV',
28
-	'LT',
29
-	'LU',
30
-	'MT',
31
-	'NL',
32
-	'PL',
33
-	'PT',
34
-	'RO',
35
-	'SK',
36
-	'SI',
37
-	'ES',
38
-	'SE'
12
+    'AT',
13
+    'BE',
14
+    'BG',
15
+    'HR',
16
+    'CY',
17
+    'CZ',
18
+    'DK',
19
+    'EE',
20
+    'FI',
21
+    'FR',
22
+    'DE',
23
+    'GR',
24
+    'HU',
25
+    'IE',
26
+    'IT',
27
+    'LV',
28
+    'LT',
29
+    'LU',
30
+    'MT',
31
+    'NL',
32
+    'PL',
33
+    'PT',
34
+    'RO',
35
+    'SK',
36
+    'SI',
37
+    'ES',
38
+    'SE'
39 39
 );
Please login to merge, or discard this patch.
includes/user-functions.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -34,11 +34,11 @@  discard block
 block discarded – undo
34 34
  */
35 35
 function wpinv_get_capability( $capalibilty = 'manage_invoicing' ) {
36 36
 
37
-	if ( current_user_can( 'manage_options' ) ) {
38
-		return 'manage_options';
39
-	};
37
+    if ( current_user_can( 'manage_options' ) ) {
38
+        return 'manage_options';
39
+    };
40 40
 
41
-	return $capalibilty;
41
+    return $capalibilty;
42 42
 }
43 43
 
44 44
 /**
@@ -62,10 +62,10 @@  discard block
 block discarded – undo
62 62
     // Prepare user values.
63 63
     $prefix = preg_replace( '/\s+/', '', $prefix );
64 64
     $prefix = empty( $prefix ) ? $email : $prefix;
65
-	$args   = array(
66
-		'user_login' => wpinv_generate_user_name( $prefix ),
67
-		'user_pass'  => wp_generate_password(),
68
-		'user_email' => $email,
65
+    $args   = array(
66
+        'user_login' => wpinv_generate_user_name( $prefix ),
67
+        'user_pass'  => wp_generate_password(),
68
+        'user_email' => $email,
69 69
         'role'       => 'subscriber',
70 70
     );
71 71
 
@@ -82,16 +82,16 @@  discard block
 block discarded – undo
82 82
 function wpinv_generate_user_name( $prefix = '' ) {
83 83
 
84 84
     // If prefix is an email, retrieve the part before the email.
85
-	$prefix = strtok( $prefix, '@' );
85
+    $prefix = strtok( $prefix, '@' );
86 86
     $prefix = trim( $prefix, '.' );
87 87
 
88
-	// Sanitize the username.
89
-	$prefix = sanitize_user( $prefix, true );
88
+    // Sanitize the username.
89
+    $prefix = sanitize_user( $prefix, true );
90 90
 
91
-	$illegal_logins = (array) apply_filters( 'illegal_user_logins', array() );
92
-	if ( empty( $prefix ) || in_array( strtolower( $prefix ), array_map( 'strtolower', $illegal_logins ), true ) ) {
93
-		$prefix = 'gtp_' . zeroise( wp_rand( 0, 9999 ), 4 );
94
-	}
91
+    $illegal_logins = (array) apply_filters( 'illegal_user_logins', array() );
92
+    if ( empty( $prefix ) || in_array( strtolower( $prefix ), array_map( 'strtolower', $illegal_logins ), true ) ) {
93
+        $prefix = 'gtp_' . zeroise( wp_rand( 0, 9999 ), 4 );
94
+    }
95 95
 
96 96
     $username = $prefix;
97 97
     $postfix  = 2;
Please login to merge, or discard this patch.
includes/gateways/class-getpaid-bank-transfer-gateway.php 1 patch
Indentation   +175 added lines, -175 removed lines patch added patch discarded remove patch
@@ -13,30 +13,30 @@  discard block
 block discarded – undo
13 13
 class GetPaid_Bank_Transfer_Gateway extends GetPaid_Payment_Gateway {
14 14
 
15 15
     /**
16
-	 * Payment method id.
17
-	 *
18
-	 * @var string
19
-	 */
16
+     * Payment method id.
17
+     *
18
+     * @var string
19
+     */
20 20
     public $id = 'bank_transfer';
21 21
 
22
-	/**
23
-	 * An array of features that this gateway supports.
24
-	 *
25
-	 * @var array
26
-	 */
27
-	protected $supports = array( 'addons' );
22
+    /**
23
+     * An array of features that this gateway supports.
24
+     *
25
+     * @var array
26
+     */
27
+    protected $supports = array( 'addons' );
28 28
 
29 29
     /**
30
-	 * Payment method order.
31
-	 *
32
-	 * @var int
33
-	 */
34
-	public $order = 8;
30
+     * Payment method order.
31
+     *
32
+     * @var int
33
+     */
34
+    public $order = 8;
35 35
 
36 36
     /**
37
-	 * Class constructor.
38
-	 */
39
-	public function __construct() {
37
+     * Class constructor.
38
+     */
39
+    public function __construct() {
40 40
         parent::__construct();
41 41
 
42 42
         $this->title                = __( 'Direct bank transfer', 'invoicing' );
@@ -44,23 +44,23 @@  discard block
 block discarded – undo
44 44
         $this->checkout_button_text = __( 'Proceed', 'invoicing' );
45 45
         $this->instructions         = apply_filters( 'wpinv_bank_instructions', $this->get_option( 'info' ) );
46 46
 
47
-		add_action( 'wpinv_receipt_end', array( $this, 'thankyou_page' ) );
48
-		add_action( 'getpaid_invoice_line_items', array( $this, 'thankyou_page' ), 40 );
49
-		add_action( 'wpinv_pdf_content_billing', array( $this, 'thankyou_page' ), 11 );
50
-		add_action( 'wpinv_email_invoice_details', array( $this, 'email_instructions' ), 10, 3 );
47
+        add_action( 'wpinv_receipt_end', array( $this, 'thankyou_page' ) );
48
+        add_action( 'getpaid_invoice_line_items', array( $this, 'thankyou_page' ), 40 );
49
+        add_action( 'wpinv_pdf_content_billing', array( $this, 'thankyou_page' ), 11 );
50
+        add_action( 'wpinv_email_invoice_details', array( $this, 'email_instructions' ), 10, 3 );
51 51
 
52 52
     }
53 53
 
54 54
     /**
55
-	 * Process Payment.
56
-	 *
57
-	 *
58
-	 * @param WPInv_Invoice $invoice Invoice.
59
-	 * @param array $submission_data Posted checkout fields.
60
-	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
61
-	 * @return array
62
-	 */
63
-	public function process_payment( $invoice, $submission_data, $submission ) {
55
+     * Process Payment.
56
+     *
57
+     *
58
+     * @param WPInv_Invoice $invoice Invoice.
59
+     * @param array $submission_data Posted checkout fields.
60
+     * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
61
+     * @return array
62
+     */
63
+    public function process_payment( $invoice, $submission_data, $submission ) {
64 64
 
65 65
         // Add a transaction id.
66 66
         $invoice->set_transaction_id( $invoice->generate_key('trans_') );
@@ -81,66 +81,66 @@  discard block
 block discarded – undo
81 81
     }
82 82
 
83 83
     /**
84
-	 * Output for the order received page.
85
-	 *
86
-	 * @param WPInv_Invoice $invoice Invoice.
87
-	 */
88
-	public function thankyou_page( $invoice ) {
84
+     * Output for the order received page.
85
+     *
86
+     * @param WPInv_Invoice $invoice Invoice.
87
+     */
88
+    public function thankyou_page( $invoice ) {
89 89
 
90 90
         if ( 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) {
91 91
 
92
-			echo '<div class="mt-4 mb-2 getpaid-bank-transfer-details">' . PHP_EOL;
92
+            echo '<div class="mt-4 mb-2 getpaid-bank-transfer-details">' . PHP_EOL;
93 93
 
94 94
             if ( ! empty( $this->instructions ) ) {
95 95
                 echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) );
96
-			}
96
+            }
97 97
 
98
-			$this->bank_details( $invoice );
98
+            $this->bank_details( $invoice );
99 99
 
100
-			echo '</div>';
100
+            echo '</div>';
101 101
 
102 102
         }
103 103
 
104
-	}
104
+    }
105 105
 
106 106
     /**
107
-	 * Add content to the WPI emails.
108
-	 *
109
-	 * @param WPInv_Invoice $invoice Invoice.
110
-	 * @param string     $email_type Email format: plain text or HTML.
111
-	 * @param bool     $sent_to_admin Sent to admin.
112
-	 */
113
-	public function email_instructions( $invoice, $email_type, $sent_to_admin ) {
107
+     * Add content to the WPI emails.
108
+     *
109
+     * @param WPInv_Invoice $invoice Invoice.
110
+     * @param string     $email_type Email format: plain text or HTML.
111
+     * @param bool     $sent_to_admin Sent to admin.
112
+     */
113
+    public function email_instructions( $invoice, $email_type, $sent_to_admin ) {
114 114
 
115
-		if ( ! $sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) {
115
+        if ( ! $sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) {
116 116
 
117
-			echo '<div class="wpi-email-row getpaid-bank-transfer-details">';
117
+            echo '<div class="wpi-email-row getpaid-bank-transfer-details">';
118 118
 
119
-			if ( $this->instructions ) {
120
-				echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) . PHP_EOL );
119
+            if ( $this->instructions ) {
120
+                echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) . PHP_EOL );
121 121
             }
122 122
 
123
-			$this->bank_details( $invoice );
123
+            $this->bank_details( $invoice );
124 124
 			
125
-			echo '</div>';
125
+            echo '</div>';
126 126
 
127
-		}
127
+        }
128 128
 
129 129
     }
130 130
     
131 131
     /**
132
-	 * Get bank details and place into a list format.
133
-	 *
134
-	 * @param WPInv_Invoice $invoice Invoice.
135
-	 */
136
-	protected function bank_details( $invoice ) {
132
+     * Get bank details and place into a list format.
133
+     *
134
+     * @param WPInv_Invoice $invoice Invoice.
135
+     */
136
+    protected function bank_details( $invoice ) {
137 137
 
138
-		// Get the invoice country and country $locale.
139
-		$country = $invoice->get_country();
140
-		$locale  = $this->get_country_locale();
138
+        // Get the invoice country and country $locale.
139
+        $country = $invoice->get_country();
140
+        $locale  = $this->get_country_locale();
141 141
 
142
-		// Get sortcode label in the $locale array and use appropriate one.
143
-		$sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
142
+        // Get sortcode label in the $locale array and use appropriate one.
143
+        $sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
144 144
 
145 145
         $bank_fields = array(
146 146
             'ac_name'     => __( 'Account Name', 'invoicing' ),
@@ -169,144 +169,144 @@  discard block
 block discarded – undo
169 169
             return;
170 170
         }
171 171
 
172
-		echo '<h3 class="getpaid-bank-transfer-title"> ' . apply_filters( 'wpinv_receipt_bank_details_title', __( 'Bank Details', 'invoicing' ) ) . '</h3>' . PHP_EOL;
172
+        echo '<h3 class="getpaid-bank-transfer-title"> ' . apply_filters( 'wpinv_receipt_bank_details_title', __( 'Bank Details', 'invoicing' ) ) . '</h3>' . PHP_EOL;
173 173
 
174
-		echo '<table class="table table-bordered getpaid-bank-transfer-details">' . PHP_EOL;
174
+        echo '<table class="table table-bordered getpaid-bank-transfer-details">' . PHP_EOL;
175 175
 
176
-		foreach ( $bank_info as $key => $data ) {
176
+        foreach ( $bank_info as $key => $data ) {
177 177
 
178
-			$key   = sanitize_html_class( $key );
179
-			$label = wp_kses_post( $data['label'] );
180
-			$value = wp_kses_post( wptexturize( $data['value'] ) );
178
+            $key   = sanitize_html_class( $key );
179
+            $label = wp_kses_post( $data['label'] );
180
+            $value = wp_kses_post( wptexturize( $data['value'] ) );
181 181
 
182
-			echo "<tr class='getpaid-bank-transfer-$key'><th class='font-weight-bold'>$label</th><td class='w-75'>$value</td></tr>" . PHP_EOL;
183
-		}
182
+            echo "<tr class='getpaid-bank-transfer-$key'><th class='font-weight-bold'>$label</th><td class='w-75'>$value</td></tr>" . PHP_EOL;
183
+        }
184 184
 
185
-		echo '</table>';
185
+        echo '</table>';
186 186
 
187 187
     }
188 188
     
189 189
     /**
190
-	 * Get country locale if localized.
191
-	 *
192
-	 * @return array
193
-	 */
194
-	public function get_country_locale() {
195
-
196
-		if ( empty( $this->locale ) ) {
197
-
198
-			// Locale information to be used - only those that are not 'Sort Code'.
199
-			$this->locale = apply_filters(
200
-				'getpaid_get_bank_transfer_locale',
201
-				array(
202
-					'AU' => array(
203
-						'sortcode' => array(
204
-							'label' => __( 'BSB', 'invoicing' ),
205
-						),
206
-					),
207
-					'CA' => array(
208
-						'sortcode' => array(
209
-							'label' => __( 'Bank transit number', 'invoicing' ),
210
-						),
211
-					),
212
-					'IN' => array(
213
-						'sortcode' => array(
214
-							'label' => __( 'IFSC', 'invoicing' ),
215
-						),
216
-					),
217
-					'IT' => array(
218
-						'sortcode' => array(
219
-							'label' => __( 'Branch sort', 'invoicing' ),
220
-						),
221
-					),
222
-					'NZ' => array(
223
-						'sortcode' => array(
224
-							'label' => __( 'Bank code', 'invoicing' ),
225
-						),
226
-					),
227
-					'SE' => array(
228
-						'sortcode' => array(
229
-							'label' => __( 'Bank code', 'invoicing' ),
230
-						),
231
-					),
232
-					'US' => array(
233
-						'sortcode' => array(
234
-							'label' => __( 'Routing number', 'invoicing' ),
235
-						),
236
-					),
237
-					'ZA' => array(
238
-						'sortcode' => array(
239
-							'label' => __( 'Branch code', 'invoicing' ),
240
-						),
241
-					),
242
-				)
243
-			);
244
-
245
-		}
246
-
247
-		return $this->locale;
248
-
249
-	}
250
-
251
-	/**
252
-	 * Filters the gateway settings.
253
-	 * 
254
-	 * @param array $admin_settings
255
-	 */
256
-	public function admin_settings( $admin_settings ) {
190
+     * Get country locale if localized.
191
+     *
192
+     * @return array
193
+     */
194
+    public function get_country_locale() {
195
+
196
+        if ( empty( $this->locale ) ) {
197
+
198
+            // Locale information to be used - only those that are not 'Sort Code'.
199
+            $this->locale = apply_filters(
200
+                'getpaid_get_bank_transfer_locale',
201
+                array(
202
+                    'AU' => array(
203
+                        'sortcode' => array(
204
+                            'label' => __( 'BSB', 'invoicing' ),
205
+                        ),
206
+                    ),
207
+                    'CA' => array(
208
+                        'sortcode' => array(
209
+                            'label' => __( 'Bank transit number', 'invoicing' ),
210
+                        ),
211
+                    ),
212
+                    'IN' => array(
213
+                        'sortcode' => array(
214
+                            'label' => __( 'IFSC', 'invoicing' ),
215
+                        ),
216
+                    ),
217
+                    'IT' => array(
218
+                        'sortcode' => array(
219
+                            'label' => __( 'Branch sort', 'invoicing' ),
220
+                        ),
221
+                    ),
222
+                    'NZ' => array(
223
+                        'sortcode' => array(
224
+                            'label' => __( 'Bank code', 'invoicing' ),
225
+                        ),
226
+                    ),
227
+                    'SE' => array(
228
+                        'sortcode' => array(
229
+                            'label' => __( 'Bank code', 'invoicing' ),
230
+                        ),
231
+                    ),
232
+                    'US' => array(
233
+                        'sortcode' => array(
234
+                            'label' => __( 'Routing number', 'invoicing' ),
235
+                        ),
236
+                    ),
237
+                    'ZA' => array(
238
+                        'sortcode' => array(
239
+                            'label' => __( 'Branch code', 'invoicing' ),
240
+                        ),
241
+                    ),
242
+                )
243
+            );
244
+
245
+        }
246
+
247
+        return $this->locale;
248
+
249
+    }
250
+
251
+    /**
252
+     * Filters the gateway settings.
253
+     * 
254
+     * @param array $admin_settings
255
+     */
256
+    public function admin_settings( $admin_settings ) {
257 257
 
258 258
         $admin_settings['bank_transfer_desc']['std']    = __( "Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing' );
259
-		$admin_settings['bank_transfer_active']['desc'] = __( 'Enable bank transfer', 'invoicing' );
259
+        $admin_settings['bank_transfer_active']['desc'] = __( 'Enable bank transfer', 'invoicing' );
260 260
 
261
-		$locale  = $this->get_country_locale();
261
+        $locale  = $this->get_country_locale();
262 262
 
263
-		// Get sortcode label in the $locale array and use appropriate one.
264
-		$country  = wpinv_default_billing_country();
265
-		$sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
263
+        // Get sortcode label in the $locale array and use appropriate one.
264
+        $country  = wpinv_default_billing_country();
265
+        $sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
266 266
 
267
-		$admin_settings['bank_transfer_ac_name'] = array(
267
+        $admin_settings['bank_transfer_ac_name'] = array(
268 268
             'type' => 'text',
269 269
             'id'   => 'bank_transfer_ac_name',
270 270
             'name' => __( 'Account Name', 'invoicing' ),
271
-		);
271
+        );
272 272
 		
273
-		$admin_settings['bank_transfer_ac_no'] = array(
273
+        $admin_settings['bank_transfer_ac_no'] = array(
274 274
             'type' => 'text',
275 275
             'id'   => 'bank_transfer_ac_no',
276 276
             'name' => __( 'Account Number', 'invoicing' ),
277
-		);
277
+        );
278 278
 		
279
-		$admin_settings['bank_transfer_bank_name'] = array(
279
+        $admin_settings['bank_transfer_bank_name'] = array(
280 280
             'type' => 'text',
281 281
             'id'   => 'bank_transfer_bank_name',
282 282
             'name' => __( 'Bank Name', 'invoicing' ),
283
-		);
283
+        );
284 284
 
285
-		$admin_settings['bank_transfer_ifsc'] = array(
285
+        $admin_settings['bank_transfer_ifsc'] = array(
286 286
             'type' => 'text',
287 287
             'id'   => 'bank_transfer_ifsc',
288 288
             'name' => __( 'IFSC Code', 'invoicing' ),
289
-		);
289
+        );
290 290
 
291
-		$admin_settings['bank_transfer_iban'] = array(
291
+        $admin_settings['bank_transfer_iban'] = array(
292 292
             'type' => 'text',
293 293
             'id'   => 'bank_transfer_iban',
294 294
             'name' => __( 'IBAN', 'invoicing' ),
295
-		);
295
+        );
296 296
 
297
-		$admin_settings['bank_transfer_bic'] = array(
297
+        $admin_settings['bank_transfer_bic'] = array(
298 298
             'type' => 'text',
299 299
             'id'   => 'bank_transfer_bic',
300 300
             'name' => __( 'BIC/Swift Code', 'invoicing' ),
301
-		);
301
+        );
302 302
 		
303
-		$admin_settings['bank_transfer_sort_code'] = array(
304
-			'type' => 'text',
305
-			'id'   => 'bank_transfer_sort_code',
306
-			'name' => $sortcode,
307
-		);
303
+        $admin_settings['bank_transfer_sort_code'] = array(
304
+            'type' => 'text',
305
+            'id'   => 'bank_transfer_sort_code',
306
+            'name' => $sortcode,
307
+        );
308 308
 
309
-		$admin_settings['bank_transfer_info'] = array(
309
+        $admin_settings['bank_transfer_info'] = array(
310 310
             'id'   => 'bank_transfer_info',
311 311
             'name' => __( 'Instructions', 'invoicing' ),
312 312
             'desc' => __( 'Instructions that will be added to the thank you page and emails.', 'invoicing' ),
@@ -316,17 +316,17 @@  discard block
 block discarded – undo
316 316
             'rows' => 5
317 317
         );
318 318
 
319
-		return $admin_settings;
320
-	}
319
+        return $admin_settings;
320
+    }
321 321
 
322
-	/**
323
-	 * Processes invoice addons.
324
-	 *
325
-	 * @param WPInv_Invoice $invoice
326
-	 * @param GetPaid_Form_Item[] $items
327
-	 * @return WPInv_Invoice
328
-	 */
329
-	public function process_addons( $invoice, $items ) {
322
+    /**
323
+     * Processes invoice addons.
324
+     *
325
+     * @param WPInv_Invoice $invoice
326
+     * @param GetPaid_Form_Item[] $items
327
+     * @return WPInv_Invoice
328
+     */
329
+    public function process_addons( $invoice, $items ) {
330 330
 
331 331
         foreach ( $items as $item ) {
332 332
             $invoice->add_item( $item );
@@ -334,6 +334,6 @@  discard block
 block discarded – undo
334 334
 
335 335
         $invoice->recalculate_total();
336 336
         $invoice->save();
337
-	}
337
+    }
338 338
 
339 339
 }
Please login to merge, or discard this patch.
templates/payment-forms/cart-item.php 1 patch
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -24,64 +24,64 @@  discard block
 block discarded – undo
24 24
 
25 25
 				<?php
26 26
 
27
-					// Fires before printing a line item column.
28
-					do_action( "getpaid_form_cart_item_before_$key", $item, $form );
27
+                    // Fires before printing a line item column.
28
+                    do_action( "getpaid_form_cart_item_before_$key", $item, $form );
29 29
 
30
-					// Item name.
31
-					if ( 'name' == $key ) {
30
+                    // Item name.
31
+                    if ( 'name' == $key ) {
32 32
 
33
-						// Display the name.
34
-						echo '<div class="mb-1">' . sanitize_text_field( $item->get_name() ) . '</div>';
33
+                        // Display the name.
34
+                        echo '<div class="mb-1">' . sanitize_text_field( $item->get_name() ) . '</div>';
35 35
 
36
-						// And an optional description.
36
+                        // And an optional description.
37 37
                         $description = $item->get_description();
38 38
 
39 39
                         if ( ! empty( $description ) ) {
40 40
                             $description = wp_kses_post( $description );
41 41
                             echo "<small class='form-text text-muted pr-2 m-0'>$description</small>";
42
-						}
42
+                        }
43 43
 
44
-						// Price help text.
44
+                        // Price help text.
45 45
                         $description = getpaid_item_recurring_price_help_text( $item, $currency );
46 46
                         if ( $description ) {
47 47
                             echo "<small class='getpaid-form-item-price-desc form-text text-muted pr-2 m-0'>$description</small>";
48
-						}
48
+                        }
49 49
 
50
-					}
50
+                    }
51 51
 
52
-					// Item price.
53
-					if ( 'price' == $key ) {
52
+                    // Item price.
53
+                    if ( 'price' == $key ) {
54 54
 
55
-						// Set the currency position.
56
-						$position = wpinv_currency_position();
55
+                        // Set the currency position.
56
+                        $position = wpinv_currency_position();
57 57
 
58
-						if ( $position == 'left_space' ) {
59
-							$position = 'left';
60
-						}
58
+                        if ( $position == 'left_space' ) {
59
+                            $position = 'left';
60
+                        }
61 61
 
62
-						if ( $position == 'right_space' ) {
63
-							$position = 'right';
64
-						}
62
+                        if ( $position == 'right_space' ) {
63
+                            $position = 'right';
64
+                        }
65 65
 
66
-						if ( $item->user_can_set_their_price() ) {
67
-							$price            = max( (float) $item->get_price(), (float) $item->get_minimum_price() );
68
-							$minimum          = (float) $item->get_minimum_price();
69
-							$validate_minimum = '';
70
-							$class            = '';
71
-							$data_minimum     = '';
66
+                        if ( $item->user_can_set_their_price() ) {
67
+                            $price            = max( (float) $item->get_price(), (float) $item->get_minimum_price() );
68
+                            $minimum          = (float) $item->get_minimum_price();
69
+                            $validate_minimum = '';
70
+                            $class            = '';
71
+                            $data_minimum     = '';
72 72
 
73
-							if ( $minimum > 0 ) {
74
-								$validate_minimum = sprintf(
75
-									esc_attr__( 'The minimum allowed amount is %s', 'invoicing' ),
76
-									sanitize_text_field( wpinv_price( $minimum, $currency ) )
77
-								);
73
+                            if ( $minimum > 0 ) {
74
+                                $validate_minimum = sprintf(
75
+                                    esc_attr__( 'The minimum allowed amount is %s', 'invoicing' ),
76
+                                    sanitize_text_field( wpinv_price( $minimum, $currency ) )
77
+                                );
78 78
 
79
-								$class = 'getpaid-validate-minimum-amount';
79
+                                $class = 'getpaid-validate-minimum-amount';
80 80
 
81
-								$data_minimum     = "data-minimum-amount='$minimum'";
82
-							}
81
+                                $data_minimum     = "data-minimum-amount='$minimum'";
82
+                            }
83 83
 
84
-							?>
84
+                            ?>
85 85
 								<div class="input-group input-group-sm">
86 86
 									<?php if( 'left' == $position ) : ?>
87 87
 										<div class="input-group-prepend">
@@ -105,37 +105,37 @@  discard block
 block discarded – undo
105 105
 								</div>
106 106
 
107 107
 							<?php
108
-						} else {
109
-							echo wpinv_price( $item->get_price(), $currency );
110
-							?>
108
+                        } else {
109
+                            echo wpinv_price( $item->get_price(), $currency );
110
+                            ?>
111 111
 								<input name='getpaid-items[<?php echo (int) $item->get_id(); ?>][price]' type='hidden' class='getpaid-item-price-input' value='<?php echo esc_attr( $item->get_price() ); ?>'>
112 112
 							<?php
113
-						}
114
-					}
113
+                        }
114
+                    }
115 115
 
116
-					// Item quantity.
117
-					if ( 'quantity' == $key ) {
116
+                    // Item quantity.
117
+                    if ( 'quantity' == $key ) {
118 118
 
119
-						if ( $item->allows_quantities() ) {
120
-							?>
119
+                        if ( $item->allows_quantities() ) {
120
+                            ?>
121 121
 								<input name='getpaid-items[<?php echo (int) $item->get_id(); ?>][quantity]' type='text' style='width: 64px; line-height: 1; min-height: 35px;' class='getpaid-item-quantity-input p-1 align-middle font-weight-normal shadow-none m-0 rounded-0 text-center border' value='<?php echo (float) $item->get_quantity(); ?>' min='1' required>
122 122
 							<?php
123
-						} else {
124
-							echo (float) $item->get_quantity();
125
-							echo '&nbsp;&nbsp;&nbsp;';
126
-							?>
123
+                        } else {
124
+                            echo (float) $item->get_quantity();
125
+                            echo '&nbsp;&nbsp;&nbsp;';
126
+                            ?>
127 127
 								<input type='hidden' name='getpaid-items[<?php echo (int) $item->get_id(); ?>][quantity]' class='getpaid-item-quantity-input' value='<?php echo (float) $item->get_quantity(); ?>'>
128 128
 							<?php
129
-						}
130
-					}
129
+                        }
130
+                    }
131 131
 
132
-					// Item sub total.
133
-					if ( 'subtotal' == $key ) {
134
-						echo wpinv_price( $item->get_sub_total(), $currency );
135
-					}
132
+                    // Item sub total.
133
+                    if ( 'subtotal' == $key ) {
134
+                        echo wpinv_price( $item->get_sub_total(), $currency );
135
+                    }
136 136
 
137
-					do_action( "getpaid_payment_form_cart_item_$key", $item, $form );
138
-				?>
137
+                    do_action( "getpaid_payment_form_cart_item_$key", $item, $form );
138
+                ?>
139 139
 
140 140
 			</div>
141 141
 
Please login to merge, or discard this patch.
includes/class-bp-getpaid-component.php 1 patch
Indentation   +129 added lines, -129 removed lines patch added patch discarded remove patch
@@ -17,45 +17,45 @@  discard block
 block discarded – undo
17 17
  */
18 18
 class BP_GetPaid_Component extends BP_Component {
19 19
 
20
-	/**
21
-	 * Start the component setup process.
22
-	 *
23
-	 * @since 2.1.5
24
-	 */
25
-	public function __construct() {
26
-		parent::start(
27
-			'getpaid',
28
-			'GetPaid',
29
-			buddypress()->plugin_dir,
30
-			array(
31
-				'adminbar_myaccount_order' => 30,
32
-			)
33
-		);
34
-	}
20
+    /**
21
+     * Start the component setup process.
22
+     *
23
+     * @since 2.1.5
24
+     */
25
+    public function __construct() {
26
+        parent::start(
27
+            'getpaid',
28
+            'GetPaid',
29
+            buddypress()->plugin_dir,
30
+            array(
31
+                'adminbar_myaccount_order' => 30,
32
+            )
33
+        );
34
+    }
35 35
 
36 36
     /**
37
-	 * Set up component global variables.
38
-	 *
39
-	 * @since 2.1.5
40
-	 *
41
-	 *
42
-	 * @param array $args {
43
-	 *     All values are optional.
44
-	 *     @type string   $slug                  The component slug. Used to construct certain URLs, such as 'friends' in
45
-	 *                                           http://example.com/members/joe/friends/. Default: the value of $this->id.
46
-	 *     @type string   $root_slug             The component root slug. Note that this value is generally unused if the
47
-	 *                                           component has a root directory (the slug will be overridden by the
48
-	 *                                           post_name of the directory page). Default: the slug of the directory page
49
-	 *                                           if one is found, otherwise an empty string.
50
-	 *     @type bool     $has_directory         Set to true if the component requires an associated WordPress page.
51
-	 *     @type callable $notification_callback Optional. The callable function that formats the component's notifications.
52
-	 *     @type string   $search_term           Optional. The placeholder text in the component directory search box. Eg,
53
-	 *                                           'Search Groups...'.
54
-	 *     @type array    $global_tables         Optional. An array of database table names.
55
-	 *     @type array    $meta_tables           Optional. An array of metadata table names.
56
-	 * }
57
-	 */
58
-	public function setup_globals( $args = array() ) {
37
+     * Set up component global variables.
38
+     *
39
+     * @since 2.1.5
40
+     *
41
+     *
42
+     * @param array $args {
43
+     *     All values are optional.
44
+     *     @type string   $slug                  The component slug. Used to construct certain URLs, such as 'friends' in
45
+     *                                           http://example.com/members/joe/friends/. Default: the value of $this->id.
46
+     *     @type string   $root_slug             The component root slug. Note that this value is generally unused if the
47
+     *                                           component has a root directory (the slug will be overridden by the
48
+     *                                           post_name of the directory page). Default: the slug of the directory page
49
+     *                                           if one is found, otherwise an empty string.
50
+     *     @type bool     $has_directory         Set to true if the component requires an associated WordPress page.
51
+     *     @type callable $notification_callback Optional. The callable function that formats the component's notifications.
52
+     *     @type string   $search_term           Optional. The placeholder text in the component directory search box. Eg,
53
+     *                                           'Search Groups...'.
54
+     *     @type array    $global_tables         Optional. An array of database table names.
55
+     *     @type array    $meta_tables           Optional. An array of metadata table names.
56
+     * }
57
+     */
58
+    public function setup_globals( $args = array() ) {
59 59
         parent::setup_globals(
60 60
             array(
61 61
                 'id'            => 'getpaid',
@@ -64,21 +64,21 @@  discard block
 block discarded – undo
64 64
                 'has_directory' => false
65 65
             )
66 66
         );
67
-	}
68
-
69
-	/**
70
-	 * Set up component navigation.
71
-	 *
72
-	 * @since 2.1.5
73
-	 *
74
-	 * @see BP_Component::setup_nav() for a description of arguments.
75
-	 *
76
-	 * @param array $main_nav Optional. See BP_Component::setup_nav() for description.
77
-	 * @param array $sub_nav  Optional. See BP_Component::setup_nav() for description.
78
-	 */
79
-	public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
80
-
81
-		// Abort if the integration is inactive.
67
+    }
68
+
69
+    /**
70
+     * Set up component navigation.
71
+     *
72
+     * @since 2.1.5
73
+     *
74
+     * @see BP_Component::setup_nav() for a description of arguments.
75
+     *
76
+     * @param array $main_nav Optional. See BP_Component::setup_nav() for description.
77
+     * @param array $sub_nav  Optional. See BP_Component::setup_nav() for description.
78
+     */
79
+    public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
80
+
81
+        // Abort if the integration is inactive.
82 82
         if ( ! getpaid_is_buddypress_integration_active() || ! is_user_logged_in() ) {
83 83
             return;
84 84
         }
@@ -88,25 +88,25 @@  discard block
 block discarded – undo
88 88
             return;
89 89
         }
90 90
 
91
-		// Determine user to use.
92
-		$user_domain   = bp_loggedin_user_domain();
93
-		$slug          = 'getpaid';
94
-		$payments_link = trailingslashit( $user_domain . $slug );
95
-
96
-		// Add 'Payments' to the main navigation.
97
-		$main_nav = array(
98
-			'name'                => _x( 'Billing', 'BuddyPress profile payments screen nav', 'invoicing' ),
99
-			'slug'                => $slug,
100
-			'position'            => apply_filters( 'wpinv_bp_nav_position', wpinv_get_option( 'wpinv_menu_position', 91 ), $slug ),
101
-			'screen_function'     => array( $this, 'display_current_tab' ),
102
-			'default_subnav_slug' => 'gp-edit-address',
91
+        // Determine user to use.
92
+        $user_domain   = bp_loggedin_user_domain();
93
+        $slug          = 'getpaid';
94
+        $payments_link = trailingslashit( $user_domain . $slug );
95
+
96
+        // Add 'Payments' to the main navigation.
97
+        $main_nav = array(
98
+            'name'                => _x( 'Billing', 'BuddyPress profile payments screen nav', 'invoicing' ),
99
+            'slug'                => $slug,
100
+            'position'            => apply_filters( 'wpinv_bp_nav_position', wpinv_get_option( 'wpinv_menu_position', 91 ), $slug ),
101
+            'screen_function'     => array( $this, 'display_current_tab' ),
102
+            'default_subnav_slug' => 'gp-edit-address',
103 103
             'show_for_displayed_user' => false,
104
-			'item_css_id'         => $this->id,
105
-			'parent_url'          => $user_domain,
106
-			'parent_slug'         => buddypress()->slug,
107
-		);
104
+            'item_css_id'         => $this->id,
105
+            'parent_url'          => $user_domain,
106
+            'parent_slug'         => buddypress()->slug,
107
+        );
108 108
 
109
-		// Add the subnav items to the payments nav item if we are using a theme that supports this.
109
+        // Add the subnav items to the payments nav item if we are using a theme that supports this.
110 110
         foreach ( getpaid_get_user_content_tabs() as $_slug => $tab ) {
111 111
 
112 112
             $sub_nav[] = array(
@@ -116,8 +116,8 @@  discard block
 block discarded – undo
116 116
                 'parent_slug'     => $slug,
117 117
                 'position' => 10,
118 118
                 'screen_function'        => function() use ( $tab ) {
119
-					$GLOBALS['getpaid_bp_current_tab'] = $tab;
120
-					$this->display_current_tab();
119
+                    $GLOBALS['getpaid_bp_current_tab'] = $tab;
120
+                    $this->display_current_tab();
121 121
                 },
122 122
                 'show_for_displayed_user' => false,
123 123
                 'item_css_id'             => "getpaid-bp-$_slug",
@@ -125,27 +125,27 @@  discard block
 block discarded – undo
125 125
 
126 126
         }
127 127
 
128
-		parent::setup_nav( $main_nav, $sub_nav );
129
-	}
130
-
131
-	/**
132
-	 * Set up the component entries in the WordPress Admin Bar.
133
-	 *
134
-	 * @since 2.1.5
135
-	 *
136
-	 * @see BP_Component::setup_nav() for a description of the $wp_admin_nav
137
-	 *      parameter array.
138
-	 *
139
-	 * @param array $wp_admin_nav See BP_Component::setup_admin_bar() for a
140
-	 *                            description.
141
-	 */
142
-	public function setup_admin_bar( $wp_admin_nav = array() ) {
143
-
144
-		// Menus for logged in user.
145
-		if ( is_user_logged_in() ) {
128
+        parent::setup_nav( $main_nav, $sub_nav );
129
+    }
146 130
 
147
-			// Setup the logged in user variables.
148
-			$payments_link = trailingslashit( bp_loggedin_user_domain() . 'getpaid/' );
131
+    /**
132
+     * Set up the component entries in the WordPress Admin Bar.
133
+     *
134
+     * @since 2.1.5
135
+     *
136
+     * @see BP_Component::setup_nav() for a description of the $wp_admin_nav
137
+     *      parameter array.
138
+     *
139
+     * @param array $wp_admin_nav See BP_Component::setup_admin_bar() for a
140
+     *                            description.
141
+     */
142
+    public function setup_admin_bar( $wp_admin_nav = array() ) {
143
+
144
+        // Menus for logged in user.
145
+        if ( is_user_logged_in() ) {
146
+
147
+            // Setup the logged in user variables.
148
+            $payments_link = trailingslashit( bp_loggedin_user_domain() . 'getpaid/' );
149 149
 
150 150
             // Add the "Payments" sub menu.
151 151
             $wp_admin_nav[] = array(
@@ -167,50 +167,50 @@  discard block
 block discarded – undo
167 167
 
168 168
             }
169 169
 
170
-		}
171
-
172
-		parent::setup_admin_bar( $wp_admin_nav );
173
-	}
170
+        }
174 171
 
175
-	/**
176
-	 * Retrieves the current tab.
177
-	 *
178
-	 * @since 2.1.5
179
-	 */
180
-	public function get_current_tab() {
181
-		global $getpaid_bp_current_tab;
172
+        parent::setup_admin_bar( $wp_admin_nav );
173
+    }
182 174
 
183
-		if ( empty( $getpaid_bp_current_tab ) ) {
184
-			return array(
185
-				'label'     => __( 'Invoices', 'invoicing' ),
186
-				'content'   => '[wpinv_history]',
187
-				'icon'      => 'fas fa-file-invoice',
188
-			);
189
-		}
175
+    /**
176
+     * Retrieves the current tab.
177
+     *
178
+     * @since 2.1.5
179
+     */
180
+    public function get_current_tab() {
181
+        global $getpaid_bp_current_tab;
182
+
183
+        if ( empty( $getpaid_bp_current_tab ) ) {
184
+            return array(
185
+                'label'     => __( 'Invoices', 'invoicing' ),
186
+                'content'   => '[wpinv_history]',
187
+                'icon'      => 'fas fa-file-invoice',
188
+            );
189
+        }
190 190
 
191
-		return $getpaid_bp_current_tab;
192
-	}
191
+        return $getpaid_bp_current_tab;
192
+    }
193 193
 
194
-	/**
195
-	 * Displays the current tab.
196
-	 *
197
-	 * @since 2.1.5
198
-	 */
199
-	public function display_current_tab() {
194
+    /**
195
+     * Displays the current tab.
196
+     *
197
+     * @since 2.1.5
198
+     */
199
+    public function display_current_tab() {
200 200
 
201
-		add_action( 'bp_template_content', array( $this, 'handle_display_current_tab' ) );
202
-		$template = apply_filters( 'bp_core_template_plugin', 'members/single/plugins' );
201
+        add_action( 'bp_template_content', array( $this, 'handle_display_current_tab' ) );
202
+        $template = apply_filters( 'bp_core_template_plugin', 'members/single/plugins' );
203 203
 
204 204
         bp_core_load_template( apply_filters( 'wpinv_bp_core_template_plugin', $template ) );
205
-	}
206
-
207
-	/**
208
-	 * Handles the actual display of the current tab.
209
-	 *
210
-	 * @since 2.1.5
211
-	 */
212
-	public function handle_display_current_tab() {
213
-		echo getpaid_prepare_user_content_tab( $this->get_current_tab() );
214
-	}
205
+    }
206
+
207
+    /**
208
+     * Handles the actual display of the current tab.
209
+     *
210
+     * @since 2.1.5
211
+     */
212
+    public function handle_display_current_tab() {
213
+        echo getpaid_prepare_user_content_tab( $this->get_current_tab() );
214
+    }
215 215
 
216 216
 }
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-invoice-address.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  */
9 9
 
10 10
 if ( ! defined( 'ABSPATH' ) ) {
11
-	exit; // Exit if accessed directly
11
+    exit; // Exit if accessed directly
12 12
 }
13 13
 
14 14
 /**
@@ -17,10 +17,10 @@  discard block
 block discarded – undo
17 17
 class GetPaid_Meta_Box_Invoice_Address {
18 18
 
19 19
     /**
20
-	 * Output the metabox.
21
-	 *
22
-	 * @param WP_Post $post
23
-	 */
20
+     * Output the metabox.
21
+     *
22
+     * @param WP_Post $post
23
+     */
24 24
     public static function output( $post ) {
25 25
 
26 26
         // Prepare the invoice.
@@ -298,18 +298,18 @@  discard block
 block discarded – undo
298 298
     }
299 299
 
300 300
     /**
301
-	 * Save meta box data.
302
-	 *
303
-	 * @param int $post_id
304
-	 */
305
-	public static function save( $post_id ) {
301
+     * Save meta box data.
302
+     *
303
+     * @param int $post_id
304
+     */
305
+    public static function save( $post_id ) {
306 306
 
307 307
         // Prepare the invoice.
308 308
         $invoice = new WPInv_Invoice( $post_id );
309 309
 
310 310
         // Load new data.
311 311
         $invoice->set_props(
312
-			array(
312
+            array(
313 313
                 'template'             => isset( $_POST['wpinv_template'] ) ? wpinv_clean( $_POST['wpinv_template'] ) : null,
314 314
                 'email_cc'             => isset( $_POST['wpinv_cc'] ) ? wpinv_clean( $_POST['wpinv_cc'] ) : null,
315 315
                 'disable_taxes'        => isset( $_POST['disable_taxes'] ),
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
                 'due_date'             => isset( $_POST['wpinv_due_date'] ) ? wpinv_clean( $_POST['wpinv_due_date'] ) : null,
331 331
                 'number'               => isset( $_POST['wpinv_number'] ) ? wpinv_clean( $_POST['wpinv_number'] ) : null,
332 332
                 'status'               => isset( $_POST['wpinv_status'] ) ? wpinv_clean( $_POST['wpinv_status'] ) : null,
333
-			)
333
+            )
334 334
         );
335 335
 
336 336
         // Discount code.
@@ -376,6 +376,6 @@  discard block
 block discarded – undo
376 376
         }
377 377
 
378 378
         // Fires after an invoice is saved.
379
-		do_action( 'wpinv_invoice_metabox_saved', $invoice );
380
-	}
379
+        do_action( 'wpinv_invoice_metabox_saved', $invoice );
380
+    }
381 381
 }
Please login to merge, or discard this patch.