Passed
Push — develop ( d1cf82...ff75e1 )
by Remco
04:14
created
classes/Payments/StatusChecker.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	 */
30 30
 	public function __construct() {
31 31
 		// The 'pronamic_ideal_check_transaction_status' hook is scheduled to request the payment status.
32
-		add_action( 'pronamic_ideal_check_transaction_status', array( $this, 'check_status' ), 10, 3 );
32
+		add_action('pronamic_ideal_check_transaction_status', array($this, 'check_status'), 10, 3);
33 33
 	}
34 34
 
35 35
 	/**
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	 *
38 38
 	 * @param Payment $payment The payment to schedule the status check event.
39 39
 	 */
40
-	public static function schedule_event( $payment ) {
40
+	public static function schedule_event($payment) {
41 41
 		/*
42 42
 		 * Schedule status requests
43 43
 		 * http://pronamic.nl/wp-content/uploads/2011/12/iDEAL_Advanced_PHP_EN_V2.2.pdf (page 19)
@@ -77,8 +77,8 @@  discard block
 block discarded – undo
77 77
 	 *
78 78
 	 * @return int
79 79
 	 */
80
-	private function get_delay_seconds( $number_tries ) {
81
-		switch ( $number_tries ) {
80
+	private function get_delay_seconds($number_tries) {
81
+		switch ($number_tries) {
82 82
 			case 0:
83 83
 				// 15 minutes after a transaction request is sent.
84 84
 				return 15 * MINUTE_IN_SECONDS;
@@ -103,29 +103,29 @@  discard block
 block discarded – undo
103 103
 	 *
104 104
 	 * @internal param string $paymentId
105 105
 	 */
106
-	public function check_status( $payment_id = null, $seconds = null, $number_tries = 1 ) {
107
-		$payment = new Payment( $payment_id );
106
+	public function check_status($payment_id = null, $seconds = null, $number_tries = 1) {
107
+		$payment = new Payment($payment_id);
108 108
 
109 109
 		// Empty payment.
110
-		if ( null === $payment ) {
110
+		if (null === $payment) {
111 111
 			// Payment with the specified ID could not be found, can't check the status.
112 112
 			return;
113 113
 		}
114 114
 
115 115
 		// Limit number tries.
116
-		if ( $number_tries >= 4 ) {
116
+		if ($number_tries >= 4) {
117 117
 			return;
118 118
 		}
119 119
 
120 120
 		// http://pronamic.nl/wp-content/uploads/2011/12/iDEAL_Advanced_PHP_EN_V2.2.pdf (page 19)
121 121
 		// - No status request after a final status has been received for a transaction.
122
-		if ( empty( $payment->status ) || Statuses::OPEN === $payment->status ) {
123
-			Plugin::update_payment( $payment );
122
+		if (empty($payment->status) || Statuses::OPEN === $payment->status) {
123
+			Plugin::update_payment($payment);
124 124
 
125
-			if ( empty( $payment->status ) || Statuses::OPEN === $payment->status ) {
125
+			if (empty($payment->status) || Statuses::OPEN === $payment->status) {
126 126
 				$time = time();
127 127
 
128
-				$seconds = $this->get_delay_seconds( $number_tries );
128
+				$seconds = $this->get_delay_seconds($number_tries);
129 129
 
130 130
 				wp_schedule_single_event(
131 131
 					$time + $seconds, 'pronamic_ideal_check_transaction_status', array(
Please login to merge, or discard this patch.
classes/Payments/PaymentTestData.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 	 * @param WP_User $user   A WordPress user.
43 43
 	 * @param float   $amount The amount to test.
44 44
 	 */
45
-	public function __construct( WP_User $user, $amount ) {
45
+	public function __construct(WP_User $user, $amount) {
46 46
 		parent::__construct();
47 47
 
48 48
 		$this->user   = $user;
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 	 * @return string
67 67
 	 */
68 68
 	public function get_description() {
69
-		return sprintf( __( 'Test %s', 'pronamic_ideal' ), $this->get_order_id() );
69
+		return sprintf(__('Test %s', 'pronamic_ideal'), $this->get_order_id());
70 70
 	}
71 71
 
72 72
 	/**
@@ -91,12 +91,12 @@  discard block
 block discarded – undo
91 91
 
92 92
 		// Item.
93 93
 		$item = new Item();
94
-		$item->setNumber( $this->get_order_id() );
95
-		$item->setDescription( sprintf( __( 'Test %s', 'pronamic_ideal' ), $this->get_order_id() ) );
96
-		$item->setPrice( $this->amount );
97
-		$item->setQuantity( 1 );
94
+		$item->setNumber($this->get_order_id());
95
+		$item->setDescription(sprintf(__('Test %s', 'pronamic_ideal'), $this->get_order_id()));
96
+		$item->setPrice($this->amount);
97
+		$item->setQuantity(1);
98 98
 
99
-		$items->addItem( $item );
99
+		$items->addItem($item);
100 100
 
101 101
 		return $items;
102 102
 	}
@@ -147,27 +147,27 @@  discard block
 block discarded – undo
147 147
 	 * @return string|bool
148 148
 	 */
149 149
 	public function get_subscription() {
150
-		$test_subscription = filter_input( INPUT_POST, 'pronamic_pay_test_subscription', FILTER_VALIDATE_BOOLEAN );
150
+		$test_subscription = filter_input(INPUT_POST, 'pronamic_pay_test_subscription', FILTER_VALIDATE_BOOLEAN);
151 151
 
152
-		if ( ! $test_subscription ) {
152
+		if ( ! $test_subscription) {
153 153
 			return false;
154 154
 		}
155 155
 
156
-		$times = filter_input( INPUT_POST, 'pronamic_pay_ends_on_count', FILTER_VALIDATE_INT );
156
+		$times = filter_input(INPUT_POST, 'pronamic_pay_ends_on_count', FILTER_VALIDATE_INT);
157 157
 
158
-		if ( empty( $times ) ) {
158
+		if (empty($times)) {
159 159
 			return false;
160 160
 		}
161 161
 
162
-		$interval = filter_input( INPUT_POST, 'pronamic_pay_test_repeat_interval', FILTER_VALIDATE_INT );
162
+		$interval = filter_input(INPUT_POST, 'pronamic_pay_test_repeat_interval', FILTER_VALIDATE_INT);
163 163
 
164
-		if ( empty( $interval ) ) {
164
+		if (empty($interval)) {
165 165
 			return false;
166 166
 		}
167 167
 
168
-		$interval_period = filter_input( INPUT_POST, 'pronamic_pay_test_repeat_frequency', FILTER_SANITIZE_STRING );
168
+		$interval_period = filter_input(INPUT_POST, 'pronamic_pay_test_repeat_frequency', FILTER_SANITIZE_STRING);
169 169
 
170
-		if ( empty( $interval_period ) ) {
170
+		if (empty($interval_period)) {
171 171
 			return false;
172 172
 		}
173 173
 
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 		$subscription->amount          = $this->get_amount();
180 180
 		$subscription->frequency       = $times;
181 181
 		$subscription->interval        = $interval;
182
-		$subscription->interval_period = Core_Util::to_period( $interval_period );
182
+		$subscription->interval_period = Core_Util::to_period($interval_period);
183 183
 
184 184
 		return $subscription;
185 185
 	}
@@ -197,15 +197,15 @@  discard block
 block discarded – undo
197 197
 		// $credit_card->set_number( '5555555555554444' );
198 198
 		// $credit_card->set_number( '4111111111111111' );
199 199
 		// $credit_card->set_number( '4000000000000002' );
200
-		$credit_card->set_number( '5300000000000006' );
200
+		$credit_card->set_number('5300000000000006');
201 201
 
202
-		$credit_card->set_expiration_month( 12 );
202
+		$credit_card->set_expiration_month(12);
203 203
 
204
-		$credit_card->set_expiration_year( date( 'Y' ) + 5 );
204
+		$credit_card->set_expiration_year(date('Y') + 5);
205 205
 
206
-		$credit_card->set_security_code( '123' );
206
+		$credit_card->set_security_code('123');
207 207
 
208
-		$credit_card->set_name( 'Pronamic' );
208
+		$credit_card->set_name('Pronamic');
209 209
 
210 210
 		return $credit_card;
211 211
 	}
Please login to merge, or discard this patch.
classes/Payments/Item.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 	 *
70 70
 	 * @param string $number Number.
71 71
 	 */
72
-	public function setNumber( $number ) {
72
+	public function setNumber($number) {
73 73
 		$this->number = $number;
74 74
 	}
75 75
 
@@ -88,8 +88,8 @@  discard block
 block discarded – undo
88 88
 	 *
89 89
 	 * @param string $description Description.
90 90
 	 */
91
-	public function setDescription( $description ) {
92
-		$this->description = substr( $description, 0, 32 );
91
+	public function setDescription($description) {
92
+		$this->description = substr($description, 0, 32);
93 93
 	}
94 94
 
95 95
 	/**
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 	 *
107 107
 	 * @param int $quantity Quantity.
108 108
 	 */
109
-	public function setQuantity( $quantity ) {
109
+	public function setQuantity($quantity) {
110 110
 		$this->quantity = $quantity;
111 111
 	}
112 112
 
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 	 *
125 125
 	 * @param float $price Price.
126 126
 	 */
127
-	public function setPrice( $price ) {
127
+	public function setPrice($price) {
128 128
 		$this->price = $price;
129 129
 	}
130 130
 
Please login to merge, or discard this patch.
classes/Payments/Items.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	 * @see IteratorAggregate::getIterator()
41 41
 	 */
42 42
 	public function getIterator() {
43
-		return new ArrayIterator( $this->items );
43
+		return new ArrayIterator($this->items);
44 44
 	}
45 45
 
46 46
 	/**
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 	 *
49 49
 	 * @param Item $item The item to add.
50 50
 	 */
51
-	public function addItem( Item $item ) {
51
+	public function addItem(Item $item) {
52 52
 		$this->items[] = $item;
53 53
 	}
54 54
 
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 	public function get_amount() {
61 61
 		$amount = 0;
62 62
 
63
-		foreach ( $this->items as $item ) {
63
+		foreach ($this->items as $item) {
64 64
 			$amount += $item->get_amount();
65 65
 		}
66 66
 
Please login to merge, or discard this patch.
classes/LicenseManager.php 1 patch
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -29,15 +29,15 @@  discard block
 block discarded – undo
29 29
 	 *
30 30
 	 * @param Plugin $plugin Plugin.
31 31
 	 */
32
-	public function __construct( Plugin $plugin ) {
32
+	public function __construct(Plugin $plugin) {
33 33
 		$this->plugin = $plugin;
34 34
 
35 35
 		// Actions.
36
-		add_action( 'pronamic_pay_license_check', array( $this, 'license_check_event' ) );
37
-		add_action( 'admin_notices', array( $this, 'admin_notices' ) );
36
+		add_action('pronamic_pay_license_check', array($this, 'license_check_event'));
37
+		add_action('admin_notices', array($this, 'admin_notices'));
38 38
 
39 39
 		// Filters.
40
-		add_filter( sprintf( 'pre_update_option_%s', 'pronamic_pay_license_key' ), array( $this, 'pre_update_option_license_key' ), 10, 2 );
40
+		add_filter(sprintf('pre_update_option_%s', 'pronamic_pay_license_key'), array($this, 'pre_update_option_license_key'), 10, 2);
41 41
 	}
42 42
 
43 43
 	/**
@@ -47,12 +47,12 @@  discard block
 block discarded – undo
47 47
 	 * @see https://github.com/easydigitaldownloads/Easy-Digital-Downloads/blob/2.4.2/includes/class-edd-license-handler.php#L309-L369
48 48
 	 */
49 49
 	public function admin_notices() {
50
-		$data = get_transient( 'pronamic_pay_license_data' );
50
+		$data = get_transient('pronamic_pay_license_data');
51 51
 
52
-		if ( $data ) {
52
+		if ($data) {
53 53
 			include $this->plugin->get_plugin_dir_path() . 'admin/notice-license.php';
54 54
 
55
-			delete_transient( 'pronamic_pay_license_data' );
55
+			delete_transient('pronamic_pay_license_data');
56 56
 		}
57 57
 	}
58 58
 
@@ -63,33 +63,33 @@  discard block
 block discarded – undo
63 63
 	 * @param string $oldvalue Old value.
64 64
 	 * @return string
65 65
 	 */
66
-	public function pre_update_option_license_key( $newvalue, $oldvalue ) {
67
-		$newvalue = trim( $newvalue );
66
+	public function pre_update_option_license_key($newvalue, $oldvalue) {
67
+		$newvalue = trim($newvalue);
68 68
 
69
-		if ( $newvalue !== $oldvalue ) {
70
-			delete_option( 'pronamic_pay_license_status' );
69
+		if ($newvalue !== $oldvalue) {
70
+			delete_option('pronamic_pay_license_status');
71 71
 
72
-			if ( ! empty( $oldvalue ) ) {
73
-				$this->deactivate_license( $oldvalue );
72
+			if ( ! empty($oldvalue)) {
73
+				$this->deactivate_license($oldvalue);
74 74
 			}
75 75
 		}
76 76
 
77
-		delete_transient( 'pronamic_pay_license_data' );
77
+		delete_transient('pronamic_pay_license_data');
78 78
 
79
-		if ( ! empty( $newvalue ) ) {
79
+		if ( ! empty($newvalue)) {
80 80
 			// Always try to activate the new license, it could be deactivated.
81
-			$this->activate_license( $newvalue );
81
+			$this->activate_license($newvalue);
82 82
 		}
83 83
 
84 84
 		// Shedule daily license check.
85 85
 		$time = time() + DAY_IN_SECONDS;
86 86
 
87
-		wp_clear_scheduled_hook( 'pronamic_pay_license_check' );
87
+		wp_clear_scheduled_hook('pronamic_pay_license_check');
88 88
 
89
-		wp_schedule_event( $time, 'daily', 'pronamic_pay_license_check' );
89
+		wp_schedule_event($time, 'daily', 'pronamic_pay_license_check');
90 90
 
91 91
 		// Get and update license status.
92
-		$this->check_license( $newvalue );
92
+		$this->check_license($newvalue);
93 93
 
94 94
 		return $newvalue;
95 95
 	}
@@ -98,9 +98,9 @@  discard block
 block discarded – undo
98 98
 	 * License check event.
99 99
 	 */
100 100
 	public function license_check_event() {
101
-		$license = get_option( 'pronamic_pay_license_key' );
101
+		$license = get_option('pronamic_pay_license_key');
102 102
 
103
-		$this->check_license( $license );
103
+		$this->check_license($license);
104 104
 	}
105 105
 
106 106
 	/**
@@ -108,10 +108,10 @@  discard block
 block discarded – undo
108 108
 	 *
109 109
 	 * @param string $license License.
110 110
 	 */
111
-	public function check_license( $license ) {
111
+	public function check_license($license) {
112 112
 		$status = null;
113 113
 
114
-		if ( empty( $license ) ) {
114
+		if (empty($license)) {
115 115
 			$status = 'invalid';
116 116
 		} else {
117 117
 			// Request.
@@ -121,10 +121,10 @@  discard block
 block discarded – undo
121 121
 				'url'     => home_url(),
122 122
 			);
123 123
 
124
-			$args = urlencode_deep( $args );
124
+			$args = urlencode_deep($args);
125 125
 
126 126
 			$response = wp_remote_get(
127
-				add_query_arg( $args, 'https://api.pronamic.eu/licenses/check/1.0/' ),
127
+				add_query_arg($args, 'https://api.pronamic.eu/licenses/check/1.0/'),
128 128
 				array(
129 129
 					'timeout' => 20,
130 130
 				)
@@ -133,15 +133,15 @@  discard block
 block discarded – undo
133 133
 			// On errors we give benefit of the doubt.
134 134
 			$status = 'valid';
135 135
 
136
-			$data = json_decode( wp_remote_retrieve_body( $response ) );
136
+			$data = json_decode(wp_remote_retrieve_body($response));
137 137
 
138
-			if ( $data ) {
138
+			if ($data) {
139 139
 				$status = $data->license;
140 140
 			}
141 141
 		}
142 142
 
143 143
 		// Update.
144
-		update_option( 'pronamic_pay_license_status', $status );
144
+		update_option('pronamic_pay_license_status', $status);
145 145
 	}
146 146
 
147 147
 	/**
@@ -149,17 +149,17 @@  discard block
 block discarded – undo
149 149
 	 *
150 150
 	 * @param string $license License to deactivate.
151 151
 	 */
152
-	public function deactivate_license( $license ) {
152
+	public function deactivate_license($license) {
153 153
 		$args = array(
154 154
 			'license' => $license,
155 155
 			'name'    => 'Pronamic iDEAL',
156 156
 			'url'     => home_url(),
157 157
 		);
158 158
 
159
-		$args = urlencode_deep( $args );
159
+		$args = urlencode_deep($args);
160 160
 
161 161
 		$response = wp_remote_get(
162
-			add_query_arg( $args, 'https://api.pronamic.eu/licenses/deactivate/1.0/' ),
162
+			add_query_arg($args, 'https://api.pronamic.eu/licenses/deactivate/1.0/'),
163 163
 			array(
164 164
 				'timeout' => 20,
165 165
 			)
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 	 *
172 172
 	 * @param string $license License to activate.
173 173
 	 */
174
-	public function activate_license( $license ) {
174
+	public function activate_license($license) {
175 175
 		// Request.
176 176
 		$args = array(
177 177
 			'license' => $license,
@@ -179,19 +179,19 @@  discard block
 block discarded – undo
179 179
 			'url'     => home_url(),
180 180
 		);
181 181
 
182
-		$args = urlencode_deep( $args );
182
+		$args = urlencode_deep($args);
183 183
 
184 184
 		$response = wp_remote_get(
185
-			add_query_arg( $args, 'https://api.pronamic.eu/licenses/activate/1.0/' ),
185
+			add_query_arg($args, 'https://api.pronamic.eu/licenses/activate/1.0/'),
186 186
 			array(
187 187
 				'timeout' => 20,
188 188
 			)
189 189
 		);
190 190
 
191
-		$data = json_decode( wp_remote_retrieve_body( $response ) );
191
+		$data = json_decode(wp_remote_retrieve_body($response));
192 192
 
193
-		if ( $data ) {
194
-			set_transient( 'pronamic_pay_license_data', $data, 30 );
193
+		if ($data) {
194
+			set_transient('pronamic_pay_license_data', $data, 30);
195 195
 		}
196 196
 	}
197 197
 }
Please login to merge, or discard this patch.
classes/Forms/FormShortcode.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -23,12 +23,12 @@  discard block
 block discarded – undo
23 23
 	 *
24 24
 	 * @param FormsModule $forms_module Reference to the forms module.
25 25
 	 */
26
-	public function __construct( $forms_module ) {
26
+	public function __construct($forms_module) {
27 27
 		$this->forms_module = $forms_module;
28 28
 
29
-		add_shortcode( 'pronamic_payment_form', array( $this, 'shortcode_form' ) );
29
+		add_shortcode('pronamic_payment_form', array($this, 'shortcode_form'));
30 30
 
31
-		add_action( 'init', array( $this, 'shortcode_ui_register' ) );
31
+		add_action('init', array($this, 'shortcode_ui_register'));
32 32
 	}
33 33
 
34 34
 	/**
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	 * @param array $atts Shortcode attributes array.
40 40
 	 * @return string
41 41
 	 */
42
-	public function shortcode_form( $atts ) {
42
+	public function shortcode_form($atts) {
43 43
 		$atts = shortcode_atts(
44 44
 			array(
45 45
 				'id' => null,
@@ -48,14 +48,14 @@  discard block
 block discarded – undo
48 48
 
49 49
 		$id = $atts['id'];
50 50
 
51
-		return $this->forms_module->get_form_output( $id );
51
+		return $this->forms_module->get_form_output($id);
52 52
 	}
53 53
 
54 54
 	/**
55 55
 	 * Shortcode user interface register.
56 56
 	 */
57 57
 	public function shortcode_ui_register() {
58
-		if ( ! function_exists( 'shortcode_ui_register_for_shortcode' ) ) {
58
+		if ( ! function_exists('shortcode_ui_register_for_shortcode')) {
59 59
 			return;
60 60
 		}
61 61
 
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 			'pronamic_payment_form',
64 64
 			array(
65 65
 				// Display label. String. Required.
66
-				'label'         => __( 'Payment Form', 'pronamic_ideal' ),
66
+				'label'         => __('Payment Form', 'pronamic_ideal'),
67 67
 
68 68
 				// Icon/attachment for shortcode. Optional. src or dashicons-$icon. Defaults to carrot.
69 69
 				'listItemImage' => 'dashicons-money',
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 				'attrs'         => array(
75 75
 
76 76
 					array(
77
-						'label'    => __( 'Select Payment Form', 'pronamic_ideal' ),
77
+						'label'    => __('Select Payment Form', 'pronamic_ideal'),
78 78
 						'attr'     => 'id',
79 79
 						'type'     => 'post_select',
80 80
 						'query'    => array(
Please login to merge, or discard this patch.
classes/Forms/FormPostType.php 1 patch
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -58,21 +58,21 @@  discard block
 block discarded – undo
58 58
 		 *
59 59
 		 * @see https://github.com/WordPress/WordPress/blob/4.0/wp-includes/post.php#L167.
60 60
 		 */
61
-		add_action( 'init', array( $this, 'register_post_type' ), 0 ); // Highest priority.
61
+		add_action('init', array($this, 'register_post_type'), 0); // Highest priority.
62 62
 
63
-		add_filter( 'manage_edit-' . self::POST_TYPE . '_columns', array( $this, 'edit_columns' ) );
63
+		add_filter('manage_edit-' . self::POST_TYPE . '_columns', array($this, 'edit_columns'));
64 64
 
65
-		add_action( 'manage_' . self::POST_TYPE . '_posts_custom_column', array( $this, 'custom_columns' ), 10, 2 );
65
+		add_action('manage_' . self::POST_TYPE . '_posts_custom_column', array($this, 'custom_columns'), 10, 2);
66 66
 
67 67
 		/*
68 68
 		 * Add meta box, we use priority 9 to make sure it loads before Yoast SEO meta box.
69 69
 		 * @see https://github.com/Yoast/wordpress-seo/blob/2.3.4/admin/class-metabox.php#L20.
70 70
 		 */
71
-		add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ), 9 );
71
+		add_action('add_meta_boxes', array($this, 'add_meta_boxes'), 9);
72 72
 
73
-		add_action( 'save_post_' . self::POST_TYPE, array( $this, 'save_post' ) );
73
+		add_action('save_post_' . self::POST_TYPE, array($this, 'save_post'));
74 74
 
75
-		add_action( 'post_submitbox_misc_actions', array( $this, 'post_submitbox_misc_actions' ) );
75
+		add_action('post_submitbox_misc_actions', array($this, 'post_submitbox_misc_actions'));
76 76
 	}
77 77
 
78 78
 	/**
@@ -81,23 +81,23 @@  discard block
 block discarded – undo
81 81
 	public function register_post_type() {
82 82
 		register_post_type(
83 83
 			self::POST_TYPE, array(
84
-				'label'              => __( 'Payment Forms', 'pronamic_ideal' ),
84
+				'label'              => __('Payment Forms', 'pronamic_ideal'),
85 85
 				'labels'             => array(
86
-					'name'                  => __( 'Payment Forms', 'pronamic_ideal' ),
87
-					'singular_name'         => __( 'Payment Form', 'pronamic_ideal' ),
88
-					'add_new'               => __( 'Add New', 'pronamic_ideal' ),
89
-					'add_new_item'          => __( 'Add New Payment Form', 'pronamic_ideal' ),
90
-					'edit_item'             => __( 'Edit Payment Form', 'pronamic_ideal' ),
91
-					'new_item'              => __( 'New Payment Form', 'pronamic_ideal' ),
92
-					'all_items'             => __( 'All Payment Forms', 'pronamic_ideal' ),
93
-					'view_item'             => __( 'View Payment Form', 'pronamic_ideal' ),
94
-					'search_items'          => __( 'Search Payment Forms', 'pronamic_ideal' ),
95
-					'not_found'             => __( 'No payment forms found.', 'pronamic_ideal' ),
96
-					'not_found_in_trash'    => __( 'No payment forms found in Trash.', 'pronamic_ideal' ),
97
-					'menu_name'             => __( 'Payment Forms', 'pronamic_ideal' ),
98
-					'filter_items_list'     => __( 'Filter payment forms list', 'pronamic_ideal' ),
99
-					'items_list_navigation' => __( 'Payment forms list navigation', 'pronamic_ideal' ),
100
-					'items_list'            => __( 'Payment forms list', 'pronamic_ideal' ),
86
+					'name'                  => __('Payment Forms', 'pronamic_ideal'),
87
+					'singular_name'         => __('Payment Form', 'pronamic_ideal'),
88
+					'add_new'               => __('Add New', 'pronamic_ideal'),
89
+					'add_new_item'          => __('Add New Payment Form', 'pronamic_ideal'),
90
+					'edit_item'             => __('Edit Payment Form', 'pronamic_ideal'),
91
+					'new_item'              => __('New Payment Form', 'pronamic_ideal'),
92
+					'all_items'             => __('All Payment Forms', 'pronamic_ideal'),
93
+					'view_item'             => __('View Payment Form', 'pronamic_ideal'),
94
+					'search_items'          => __('Search Payment Forms', 'pronamic_ideal'),
95
+					'not_found'             => __('No payment forms found.', 'pronamic_ideal'),
96
+					'not_found_in_trash'    => __('No payment forms found in Trash.', 'pronamic_ideal'),
97
+					'menu_name'             => __('Payment Forms', 'pronamic_ideal'),
98
+					'filter_items_list'     => __('Filter payment forms list', 'pronamic_ideal'),
99
+					'items_list_navigation' => __('Payment forms list navigation', 'pronamic_ideal'),
100
+					'items_list'            => __('Payment forms list', 'pronamic_ideal'),
101 101
 				),
102 102
 				'public'             => true,
103 103
 				'publicly_queryable' => true,
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 					'revisions',
111 111
 				),
112 112
 				'rewrite'            => array(
113
-					'slug' => _x( 'payment-forms', 'slug', 'pronamic_ideal' ),
113
+					'slug' => _x('payment-forms', 'slug', 'pronamic_ideal'),
114 114
 				),
115 115
 				'query_var'          => false,
116 116
 				'capabilities'       => FormPostType::get_capabilities(),
@@ -125,15 +125,15 @@  discard block
 block discarded – undo
125 125
 	 * @param array $columns Edit columns.
126 126
 	 * @return array
127 127
 	 */
128
-	public function edit_columns( $columns ) {
128
+	public function edit_columns($columns) {
129 129
 		$columns = array(
130 130
 			'cb'                              => '<input type="checkbox" />',
131
-			'title'                           => __( 'Title', 'pronamic_ideal' ),
132
-			'pronamic_payment_form_gateway'   => __( 'Gateway', 'pronamic_ideal' ),
133
-			'pronamic_payment_form_payments'  => __( 'Payments', 'pronamic_ideal' ),
134
-			'pronamic_payment_form_earnings'  => __( 'Earnings', 'pronamic_ideal' ),
135
-			'pronamic_payment_form_shortcode' => __( 'Shortcode', 'pronamic_ideal' ),
136
-			'date'                            => __( 'Date', 'pronamic_ideal' ),
131
+			'title'                           => __('Title', 'pronamic_ideal'),
132
+			'pronamic_payment_form_gateway'   => __('Gateway', 'pronamic_ideal'),
133
+			'pronamic_payment_form_payments'  => __('Payments', 'pronamic_ideal'),
134
+			'pronamic_payment_form_earnings'  => __('Earnings', 'pronamic_ideal'),
135
+			'pronamic_payment_form_shortcode' => __('Shortcode', 'pronamic_ideal'),
136
+			'date'                            => __('Date', 'pronamic_ideal'),
137 137
 		);
138 138
 
139 139
 		return $columns;
@@ -145,15 +145,15 @@  discard block
 block discarded – undo
145 145
 	 * @param string $column  Column.
146 146
 	 * @param string $post_id Post ID.
147 147
 	 */
148
-	public function custom_columns( $column, $post_id ) {
148
+	public function custom_columns($column, $post_id) {
149 149
 		global $post;
150 150
 
151
-		switch ( $column ) {
151
+		switch ($column) {
152 152
 			case 'pronamic_payment_form_gateway':
153
-				$config_id = get_post_meta( $post_id, '_pronamic_payment_form_config_id', true );
153
+				$config_id = get_post_meta($post_id, '_pronamic_payment_form_config_id', true);
154 154
 
155
-				if ( ! empty( $config_id ) ) {
156
-					echo get_the_title( $config_id );
155
+				if ( ! empty($config_id)) {
156
+					echo get_the_title($config_id);
157 157
 				} else {
158 158
 					echo '—';
159 159
 				}
@@ -191,9 +191,9 @@  discard block
 block discarded – undo
191 191
 					$post_id
192 192
 				);
193 193
 
194
-				$value = $wpdb->get_var( $query ); // WPCS: unprepared SQL ok.
194
+				$value = $wpdb->get_var($query); // WPCS: unprepared SQL ok.
195 195
 
196
-				echo esc_html( number_format_i18n( $value ) );
196
+				echo esc_html(number_format_i18n($value));
197 197
 
198 198
 				break;
199 199
 			case 'pronamic_payment_form_earnings':
@@ -228,15 +228,15 @@  discard block
 block discarded – undo
228 228
 					$post_id
229 229
 				);
230 230
 
231
-				$value = $wpdb->get_var( $query ); // WPCS: unprepared SQL ok.
231
+				$value = $wpdb->get_var($query); // WPCS: unprepared SQL ok.
232 232
 
233
-				echo esc_html( \Pronamic\WordPress\Pay\Util::format_price( $value ) );
233
+				echo esc_html(\Pronamic\WordPress\Pay\Util::format_price($value));
234 234
 
235 235
 				break;
236 236
 			case 'pronamic_payment_form_shortcode':
237 237
 				printf(
238 238
 					'<input onclick="this.setSelectionRange( 0, this.value.length )" type="text" class="pronamic-pay-shortcode-input" readonly="" value="%s" />',
239
-					esc_attr( $this->get_shortcode( $post_id ) )
239
+					esc_attr($this->get_shortcode($post_id))
240 240
 				);
241 241
 
242 242
 				break;
@@ -248,12 +248,12 @@  discard block
 block discarded – undo
248 248
 	 *
249 249
 	 * @param string $post_type Post Type.
250 250
 	 */
251
-	public function add_meta_boxes( $post_type ) {
252
-		if ( self::POST_TYPE === $post_type ) {
251
+	public function add_meta_boxes($post_type) {
252
+		if (self::POST_TYPE === $post_type) {
253 253
 			add_meta_box(
254 254
 				'pronamic_payment_form_options',
255
-				__( 'Form Options', 'pronamic_ideal' ),
256
-				array( $this, 'meta_box_form_options' ),
255
+				__('Form Options', 'pronamic_ideal'),
256
+				array($this, 'meta_box_form_options'),
257 257
 				$post_type,
258 258
 				'normal',
259 259
 				'high'
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
 	 *
267 267
 	 * @param WP_Post $post The object for the current post/page.
268 268
 	 */
269
-	public function meta_box_form_options( $post ) {
269
+	public function meta_box_form_options($post) {
270 270
 		include \Pronamic\WordPress\Pay\Plugin::$dirname . '/admin/meta-box-form-options.php';
271 271
 	}
272 272
 
@@ -275,21 +275,21 @@  discard block
 block discarded – undo
275 275
 	 *
276 276
 	 * @param int $post_id The ID of the post being saved.
277 277
 	 */
278
-	public function save_post( $post_id ) {
278
+	public function save_post($post_id) {
279 279
 		// Check if our nonce is set.
280
-		if ( ! filter_has_var( INPUT_POST, 'pronamic_pay_nonce' ) ) {
280
+		if ( ! filter_has_var(INPUT_POST, 'pronamic_pay_nonce')) {
281 281
 			return $post_id;
282 282
 		}
283 283
 
284
-		$nonce = filter_input( INPUT_POST, 'pronamic_pay_nonce', FILTER_SANITIZE_STRING );
284
+		$nonce = filter_input(INPUT_POST, 'pronamic_pay_nonce', FILTER_SANITIZE_STRING);
285 285
 
286 286
 		// Verify that the nonce is valid.
287
-		if ( ! wp_verify_nonce( $nonce, 'pronamic_pay_save_form_options' ) ) {
287
+		if ( ! wp_verify_nonce($nonce, 'pronamic_pay_save_form_options')) {
288 288
 			return $post_id;
289 289
 		}
290 290
 
291 291
 		// If this is an autosave, our form has not been submitted, so we don't want to do anything.
292
-		if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
292
+		if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
293 293
 			return $post_id;
294 294
 		}
295 295
 
@@ -304,22 +304,22 @@  discard block
 block discarded – undo
304 304
 			),
305 305
 		);
306 306
 
307
-		$data = filter_input_array( INPUT_POST, $definition );
307
+		$data = filter_input_array(INPUT_POST, $definition);
308 308
 
309 309
 		// Convert amount choices to cents.
310
-		if ( isset( $data['_pronamic_payment_form_amount_choices'] ) ) {
311
-			foreach ( $data['_pronamic_payment_form_amount_choices'] as $i => $amount ) {
312
-				$amount = \Pronamic\WordPress\Pay\Core\Util::string_to_amount( $amount );
310
+		if (isset($data['_pronamic_payment_form_amount_choices'])) {
311
+			foreach ($data['_pronamic_payment_form_amount_choices'] as $i => $amount) {
312
+				$amount = \Pronamic\WordPress\Pay\Core\Util::string_to_amount($amount);
313 313
 
314
-				$data['_pronamic_payment_form_amount_choices'][ $i ] = \Pronamic\WordPress\Pay\Core\Util::amount_to_cents( $amount );
314
+				$data['_pronamic_payment_form_amount_choices'][$i] = \Pronamic\WordPress\Pay\Core\Util::amount_to_cents($amount);
315 315
 			}
316 316
 
317 317
 			// Remove empty choices.
318
-			$data['_pronamic_payment_form_amount_choices'] = array_filter( $data['_pronamic_payment_form_amount_choices'] );
318
+			$data['_pronamic_payment_form_amount_choices'] = array_filter($data['_pronamic_payment_form_amount_choices']);
319 319
 		}
320 320
 
321 321
 		// Update post meta data.
322
-		pronamic_pay_update_post_meta_data( $post_id, $data );
322
+		pronamic_pay_update_post_meta_data($post_id, $data);
323 323
 	}
324 324
 
325 325
 	/**
@@ -328,10 +328,10 @@  discard block
 block discarded – undo
328 328
 	 * @param string $post_id Post ID.
329 329
 	 * @return string
330 330
 	 */
331
-	private function get_shortcode( $post_id = null ) {
332
-		$post_id = ( null === $post_id ) ? get_the_ID() : $post_id;
331
+	private function get_shortcode($post_id = null) {
332
+		$post_id = (null === $post_id) ? get_the_ID() : $post_id;
333 333
 
334
-		$shortcode = sprintf( '[pronamic_payment_form id="%s"]', esc_attr( $post_id ) );
334
+		$shortcode = sprintf('[pronamic_payment_form id="%s"]', esc_attr($post_id));
335 335
 
336 336
 		return $shortcode;
337 337
 	}
@@ -340,15 +340,15 @@  discard block
 block discarded – undo
340 340
 	 * Post submit box miscellaneous actions.
341 341
 	 */
342 342
 	public function post_submitbox_misc_actions() {
343
-		if ( self::POST_TYPE !== get_post_type() ) {
343
+		if (self::POST_TYPE !== get_post_type()) {
344 344
 			return false;
345 345
 		}
346 346
 
347 347
 		?>
348 348
 <div class="misc-pub-section">
349
-	<label for="pronamic-pay-shortcode"><?php esc_html_e( 'Shortcode:', 'pronamic_ideal' ); ?></label>
349
+	<label for="pronamic-pay-shortcode"><?php esc_html_e('Shortcode:', 'pronamic_ideal'); ?></label>
350 350
 
351
-	<input id="pronamic-pay-shortcode" class="pronamic-pay-shortcode-input" onClick="this.setSelectionRange( 0, this.value.length )" type="text" class="shortcode-input" readonly value="<?php echo esc_attr( $this->get_shortcode() ); ?>" />
351
+	<input id="pronamic-pay-shortcode" class="pronamic-pay-shortcode-input" onClick="this.setSelectionRange( 0, this.value.length )" type="text" class="shortcode-input" readonly value="<?php echo esc_attr($this->get_shortcode()); ?>" />
352 352
 </div>
353 353
 <?php
354 354
 	}
Please login to merge, or discard this patch.
classes/Forms/FormsModule.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -26,25 +26,25 @@  discard block
 block discarded – undo
26 26
 	 *
27 27
 	 * @param Plugin $plugin Plugin.
28 28
 	 */
29
-	public function __construct( $plugin ) {
29
+	public function __construct($plugin) {
30 30
 		$this->plugin = $plugin;
31 31
 
32 32
 		// Form Post Type.
33 33
 		$this->form_post_type = new FormPostType();
34 34
 
35 35
 		// Processor.
36
-		$this->processor = new FormProcessor( $plugin );
36
+		$this->processor = new FormProcessor($plugin);
37 37
 
38 38
 		// Scripts.
39
-		$this->scripts = new FormScripts( $plugin );
39
+		$this->scripts = new FormScripts($plugin);
40 40
 
41 41
 		// Shortcode.
42
-		$this->shortcode = new FormShortcode( $this );
42
+		$this->shortcode = new FormShortcode($this);
43 43
 
44 44
 		// Actions.
45
-		add_filter( 'the_content', array( $this, 'maybe_add_form_to_content' ) );
45
+		add_filter('the_content', array($this, 'maybe_add_form_to_content'));
46 46
 
47
-		add_filter( 'pronamic_payment_source_text_payment_form', array( $this, 'source_text' ), 10, 2 );
47
+		add_filter('pronamic_payment_source_text_payment_form', array($this, 'source_text'), 10, 2);
48 48
 	}
49 49
 
50 50
 	/**
@@ -54,9 +54,9 @@  discard block
 block discarded – undo
54 54
 	 * @param string $content Post content to maybe extend with a payment form.
55 55
 	 * @return string
56 56
 	 */
57
-	public function maybe_add_form_to_content( $content ) {
58
-		if ( is_singular( 'pronamic_pay_form' ) && 'pronamic_pay_form' === get_post_type() ) {
59
-			$content .= $this->get_form_output( get_the_ID() );
57
+	public function maybe_add_form_to_content($content) {
58
+		if (is_singular('pronamic_pay_form') && 'pronamic_pay_form' === get_post_type()) {
59
+			$content .= $this->get_form_output(get_the_ID());
60 60
 		}
61 61
 
62 62
 		return $content;
@@ -68,8 +68,8 @@  discard block
 block discarded – undo
68 68
 	 * @param string $id Form ID.
69 69
 	 * @return string
70 70
 	 */
71
-	public function get_form_output( $id ) {
72
-		$file = plugin_dir_path( Plugin::$file ) . 'templates/form.php';
71
+	public function get_form_output($id) {
72
+		$file = plugin_dir_path(Plugin::$file) . 'templates/form.php';
73 73
 
74 74
 		ob_start();
75 75
 
@@ -87,12 +87,12 @@  discard block
 block discarded – undo
87 87
 	 * @param Payment $payment The payment for the specified source text.
88 88
 	 * @return string
89 89
 	 */
90
-	public function source_text( $text, Payment $payment ) {
91
-		$text = __( 'Payment Form', 'pronamic_ideal' ) . '<br />';
90
+	public function source_text($text, Payment $payment) {
91
+		$text = __('Payment Form', 'pronamic_ideal') . '<br />';
92 92
 
93 93
 		$text .= sprintf(
94 94
 			'<a href="%s">%s</a>',
95
-			get_edit_post_link( $payment->source_id ),
95
+			get_edit_post_link($payment->source_id),
96 96
 			$payment->source_id
97 97
 		);
98 98
 
Please login to merge, or discard this patch.
classes/Forms/FormProcessor.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -23,11 +23,11 @@  discard block
 block discarded – undo
23 23
 	 *
24 24
 	 * @param Plugin $plugin Plugin.
25 25
 	 */
26
-	public function __construct( $plugin ) {
26
+	public function __construct($plugin) {
27 27
 		$this->plugin = $plugin;
28 28
 
29 29
 		// Actions.
30
-		add_action( 'init', array( $this, 'init' ) );
30
+		add_action('init', array($this, 'init'));
31 31
 	}
32 32
 
33 33
 	/**
@@ -39,58 +39,58 @@  discard block
 block discarded – undo
39 39
 		$pronamic_pay_errors = array();
40 40
 
41 41
 		// Nonce.
42
-		if ( ! filter_has_var( INPUT_POST, 'pronamic_pay_nonce' ) ) {
42
+		if ( ! filter_has_var(INPUT_POST, 'pronamic_pay_nonce')) {
43 43
 			return;
44 44
 		}
45 45
 
46
-		$nonce = filter_input( INPUT_POST, 'pronamic_pay_nonce', FILTER_SANITIZE_STRING );
46
+		$nonce = filter_input(INPUT_POST, 'pronamic_pay_nonce', FILTER_SANITIZE_STRING);
47 47
 
48
-		if ( ! wp_verify_nonce( $nonce, 'pronamic_pay' ) ) {
48
+		if ( ! wp_verify_nonce($nonce, 'pronamic_pay')) {
49 49
 			return;
50 50
 		}
51 51
 
52 52
 		// Validate.
53 53
 		$valid = $this->validate();
54 54
 
55
-		if ( ! $valid ) {
55
+		if ( ! $valid) {
56 56
 			return;
57 57
 		}
58 58
 
59 59
 		// Gateway.
60
-		$id = filter_input( INPUT_POST, 'pronamic_pay_form_id', FILTER_VALIDATE_INT );
60
+		$id = filter_input(INPUT_POST, 'pronamic_pay_form_id', FILTER_VALIDATE_INT);
61 61
 
62
-		$config_id = get_post_meta( $id, '_pronamic_payment_form_config_id', true );
62
+		$config_id = get_post_meta($id, '_pronamic_payment_form_config_id', true);
63 63
 
64
-		$gateway = \Pronamic\WordPress\Pay\Plugin::get_gateway( $config_id );
64
+		$gateway = \Pronamic\WordPress\Pay\Plugin::get_gateway($config_id);
65 65
 
66
-		if ( ! $gateway ) {
66
+		if ( ! $gateway) {
67 67
 			return;
68 68
 		}
69 69
 
70 70
 		// Data.
71 71
 		$data = new PaymentFormData();
72 72
 
73
-		$payment = \Pronamic\WordPress\Pay\Plugin::start( $config_id, $gateway, $data );
73
+		$payment = \Pronamic\WordPress\Pay\Plugin::start($config_id, $gateway, $data);
74 74
 
75 75
 		$error = $gateway->get_error();
76 76
 
77
-		if ( is_wp_error( $error ) ) {
78
-			\Pronamic\WordPress\Pay\Plugin::render_errors( $error );
77
+		if (is_wp_error($error)) {
78
+			\Pronamic\WordPress\Pay\Plugin::render_errors($error);
79 79
 
80 80
 			exit;
81 81
 		}
82 82
 
83 83
 		// @see https://github.com/WordImpress/Give/blob/1.1/includes/payments/functions.php#L172-L178.
84 84
 		// @see https://github.com/woothemes/woocommerce/blob/2.4.3/includes/wc-user-functions.php#L36-L118.
85
-		$first_name = filter_input( INPUT_POST, 'pronamic_pay_first_name', FILTER_SANITIZE_STRING );
86
-		$last_name  = filter_input( INPUT_POST, 'pronamic_pay_last_name', FILTER_SANITIZE_STRING );
87
-		$email      = filter_input( INPUT_POST, 'pronamic_pay_email', FILTER_VALIDATE_EMAIL );
85
+		$first_name = filter_input(INPUT_POST, 'pronamic_pay_first_name', FILTER_SANITIZE_STRING);
86
+		$last_name  = filter_input(INPUT_POST, 'pronamic_pay_last_name', FILTER_SANITIZE_STRING);
87
+		$email      = filter_input(INPUT_POST, 'pronamic_pay_email', FILTER_VALIDATE_EMAIL);
88 88
 
89
-		$user = get_user_by( 'email', $email );
89
+		$user = get_user_by('email', $email);
90 90
 
91
-		if ( ! $user ) {
91
+		if ( ! $user) {
92 92
 			// Make a random string for password.
93
-			$password = wp_generate_password( 10 );
93
+			$password = wp_generate_password(10);
94 94
 
95 95
 			// Make a user with the username as the email.
96 96
 			$user_id = wp_insert_user(
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 			);
106 106
 
107 107
 			// User.
108
-			$user = new \WP_User( $user_id );
108
+			$user = new \WP_User($user_id);
109 109
 		}
110 110
 
111 111
 		wp_update_post(
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 			)
116 116
 		);
117 117
 
118
-		$gateway->redirect( $payment );
118
+		$gateway->redirect($payment);
119 119
 
120 120
 		exit;
121 121
 	}
@@ -129,19 +129,19 @@  discard block
 block discarded – undo
129 129
 		global $pronamic_pay_errors;
130 130
 
131 131
 		// First Name.
132
-		$first_name = filter_input( INPUT_POST, 'pronamic_pay_first_name', FILTER_SANITIZE_STRING );
132
+		$first_name = filter_input(INPUT_POST, 'pronamic_pay_first_name', FILTER_SANITIZE_STRING);
133 133
 
134
-		if ( empty( $first_name ) ) {
135
-			$pronamic_pay_errors['first_name'] = __( 'Please enter your first name', 'pronamic_ideal' );
134
+		if (empty($first_name)) {
135
+			$pronamic_pay_errors['first_name'] = __('Please enter your first name', 'pronamic_ideal');
136 136
 		}
137 137
 
138 138
 		// E-mail.
139
-		$email = filter_input( INPUT_POST, 'pronamic_pay_email', FILTER_VALIDATE_EMAIL );
139
+		$email = filter_input(INPUT_POST, 'pronamic_pay_email', FILTER_VALIDATE_EMAIL);
140 140
 
141
-		if ( empty( $email ) ) {
142
-			$pronamic_pay_errors['email'] = __( 'Please enter a valid email address', 'pronamic_ideal' );
141
+		if (empty($email)) {
142
+			$pronamic_pay_errors['email'] = __('Please enter a valid email address', 'pronamic_ideal');
143 143
 		}
144 144
 
145
-		return empty( $pronamic_pay_errors );
145
+		return empty($pronamic_pay_errors);
146 146
 	}
147 147
 }
Please login to merge, or discard this patch.