Passed
Push — master ( bba4c5...886ed1 )
by Remco
04:49 queued 02:31
created

Pronamic_WP_Pay_Gateways_Mollie_Settings::fields()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 38
Code Lines 26

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 1
Metric Value
c 3
b 0
f 1
dl 0
loc 38
rs 8.8571
cc 1
eloc 26
nc 1
nop 1
1
<?php
2
3
namespace Pronamic\WordPress\Pay\Gateways\Mollie;
4
5
use Pronamic\WordPress\Pay\Core\GatewaySettings;
6
7
/**
8
 * Title: Mollie gateway settings
9
 * Description:
10
 * Copyright: Copyright (c) 2005 - 2018
11
 * Company: Pronamic
12
 *
13
 * @author  Remco Tolsma
14
 * @version 2.0.0
15
 * @since   1.0.0
16
 */
17
class Settings extends GatewaySettings {
18
	/**
19
	 * Settings constructor.
20
	 */
21
	public function __construct() {
22
		add_filter( 'pronamic_pay_gateway_sections', array( $this, 'sections' ) );
0 ignored issues
show
Bug introduced by
The function add_filter was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

22
		/** @scrutinizer ignore-call */ 
23
  add_filter( 'pronamic_pay_gateway_sections', array( $this, 'sections' ) );
Loading history...
23
		add_filter( 'pronamic_pay_gateway_fields', array( $this, 'fields' ) );
24
	}
25
26
	/**
27
	 * Settings sections.
28
	 *
29
	 * @param array $sections Sections.
30
	 *
31
	 * @return array
32
	 */
33
	public function sections( array $sections ) {
34
		// General.
35
		$sections['mollie'] = array(
36
			'title'       => __( 'Mollie', 'pronamic_ideal' ),
0 ignored issues
show
Bug introduced by
The function __ was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

36
			'title'       => /** @scrutinizer ignore-call */ __( 'Mollie', 'pronamic_ideal' ),
Loading history...
37
			'methods'     => array( 'mollie' ),
38
			'description' => __( 'Account details are provided by the payment provider after registration. These settings need to match with the payment provider dashboard.', 'pronamic_ideal' ),
39
		);
40
41
		// Transaction feedback.
42
		$sections['mollie_feedback'] = array(
43
			'title'       => __( 'Transaction feedback', 'pronamic_ideal' ),
44
			'methods'     => array( 'mollie' ),
45
			'description' => __( 'Payment status updates will be processed without any additional configuration. The <em>Webhook URL</em> is being used to receive the status updates.', 'pronamic_ideal' ),
46
		);
47
48
		return $sections;
49
	}
50
51
	/**
52
	 * Settings fields.
53
	 *
54
	 * @param array $fields Fields.
55
	 *
56
	 * @return array
57
	 */
58
	public function fields( array $fields ) {
59
		// API Key.
60
		$fields[] = array(
61
			'filter'   => FILTER_SANITIZE_STRING,
62
			'section'  => 'mollie',
63
			'meta_key' => '_pronamic_gateway_mollie_api_key',
64
			'title'    => _x( 'API Key', 'mollie', 'pronamic_ideal' ),
0 ignored issues
show
Bug introduced by
The function _x was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

64
			'title'    => /** @scrutinizer ignore-call */ _x( 'API Key', 'mollie', 'pronamic_ideal' ),
Loading history...
65
			'type'     => 'text',
66
			'classes'  => array( 'regular-text', 'code' ),
67
			'methods'  => array( 'mollie' ),
68
			'tooltip'  => __( 'API key as mentioned in the payment provider dashboard', 'pronamic_ideal' ),
0 ignored issues
show
Bug introduced by
The function __ was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

68
			'tooltip'  => /** @scrutinizer ignore-call */ __( 'API key as mentioned in the payment provider dashboard', 'pronamic_ideal' ),
Loading history...
69
		);
70
71
		// Transaction feedback.
72
		$fields[] = array(
73
			'section' => 'mollie',
74
			'title'   => __( 'Transaction feedback', 'pronamic_ideal' ),
75
			'type'    => 'description',
76
			'html'    => sprintf(
77
				'<span class="dashicons dashicons-yes"></span> %s',
78
				__( 'Payment status updates will be processed without any additional configuration.', 'pronamic_ideal' )
79
			),
80
		);
81
82
		// Webhook.
83
		$fields[] = array(
84
			'section'  => 'mollie_feedback',
85
			'title'    => __( 'Webhook URL', 'pronamic_ideal' ),
86
			'type'     => 'text',
87
			'classes'  => array( 'large-text', 'code' ),
88
			'value'    => add_query_arg( 'mollie_webhook', '', home_url( '/' ) ),
0 ignored issues
show
Bug introduced by
The function home_url was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

88
			'value'    => add_query_arg( 'mollie_webhook', '', /** @scrutinizer ignore-call */ home_url( '/' ) ),
Loading history...
Bug introduced by
The function add_query_arg was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

88
			'value'    => /** @scrutinizer ignore-call */ add_query_arg( 'mollie_webhook', '', home_url( '/' ) ),
Loading history...
89
			'readonly' => true,
90
			'methods'  => array( 'mollie' ),
91
			'tooltip'  => __( 'The Webhook URL as sent with each transaction to receive automatic payment status updates on.', 'pronamic_ideal' ),
92
		);
93
94
		return $fields;
95
	}
96
}
97