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

Integration::get_settings()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace Pronamic\WordPress\Pay\Gateways\Mollie;
4
5
use Pronamic\WordPress\Pay\Gateways\Common\AbstractIntegration;
6
7
/**
8
 * Title: Mollie integration
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 Integration extends AbstractIntegration {
18
	/**
19
	 * Dashboard URL.
20
	 *
21
	 * @var string
22
	 */
23
	public $dashboard_url = 'http://www.mollie.nl/beheer/';
24
25
	/**
26
	 * Construct and intialize Mollie integration.
27
	 */
28
	public function __construct() {
29
		$this->id          = 'mollie';
30
		$this->name        = 'Mollie';
31
		$this->url         = 'http://www.mollie.com/en/';
32
		$this->product_url = __( 'https://www.mollie.com/en/pricing', '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

32
		$this->product_url = /** @scrutinizer ignore-call */ __( 'https://www.mollie.com/en/pricing', 'pronamic_ideal' );
Loading history...
33
		$this->provider    = 'mollie';
34
35
		// Actions
36
		$function = array( __NAMESPACE__ . '\Listener', 'listen' );
37
38
		if ( ! has_action( 'wp_loaded', $function ) ) {
0 ignored issues
show
Bug introduced by
The function has_action 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

38
		if ( ! /** @scrutinizer ignore-call */ has_action( 'wp_loaded', $function ) ) {
Loading history...
39
			add_action( 'wp_loaded', $function );
0 ignored issues
show
Bug introduced by
The function add_action 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

39
			/** @scrutinizer ignore-call */ 
40
   add_action( 'wp_loaded', $function );
Loading history...
40
		}
41
42
		if ( is_admin() ) {
0 ignored issues
show
Bug introduced by
The function is_admin 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

42
		if ( /** @scrutinizer ignore-call */ is_admin() ) {
Loading history...
43
			$function = array( __CLASS__, 'user_profile' );
44
45
			if ( ! has_action( 'show_user_profile', $function ) ) {
46
				add_action( 'show_user_profile', $function );
47
			}
48
49
			if ( ! has_action( 'edit_user_profile', $function ) ) {
50
				add_action( 'edit_user_profile', $function );
51
			}
52
		}
53
54
		add_filter( 'pronamic_payment_provider_url_mollie', array( $this, 'payment_provider_url' ), 10, 2 );
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

54
		/** @scrutinizer ignore-call */ 
55
  add_filter( 'pronamic_payment_provider_url_mollie', array( $this, 'payment_provider_url' ), 10, 2 );
Loading history...
55
	}
56
57
	public function get_config_factory_class() {
58
		return __NAMESPACE__ . '\ConfigFactory';
59
	}
60
61
	public function get_settings_class() {
62
		return __NAMESPACE__ . '\Settings';
63
	}
64
65
	/**
66
	 * Get required settings for this integration.
67
	 *
68
	 * @see https://github.com/wp-premium/gravityforms/blob/1.9.16/includes/fields/class-gf-field-multiselect.php#L21-L42
69
	 * @since 1.1.3
70
	 * @return array
71
	 */
72
	public function get_settings() {
73
		$settings = parent::get_settings();
74
75
		$settings[] = 'mollie';
76
77
		return $settings;
78
	}
79
80
	/**
81
	 * User profile.
82
	 *
83
	 * @since 1.1.6
84
	 * @see https://github.com/WordPress/WordPress/blob/4.5.2/wp-admin/user-edit.php#L578-L600
85
	 */
86
	public static function user_profile( $user ) {
87
		include dirname( __FILE__ ) . '/../views/html-admin-user-profile.php';
88
	}
89
90
	/**
91
	 * Payment provider URL.
92
	 *
93
	 * @param string  $url
94
	 * @param Payment $payment
95
	 * @return string
96
	 */
97
	public function payment_provider_url( $url, $payment ) {
98
		return sprintf(
99
			'https://www.mollie.com/dashboard/payments/%s',
100
			$payment->get_transaction_id()
101
		);
102
	}
103
}
104