@@ -23,11 +23,11 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -23,22 +23,22 @@ discard block |
||
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 | - add_action( 'wp_enqueue_scripts', array( $this, 'register' ) ); |
|
30 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue' ) ); |
|
29 | + add_action('wp_enqueue_scripts', array($this, 'register')); |
|
30 | + add_action('wp_enqueue_scripts', array($this, 'enqueue')); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
34 | 34 | * Register. |
35 | 35 | */ |
36 | 36 | public function register() { |
37 | - $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
37 | + $min = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
38 | 38 | |
39 | 39 | wp_register_style( |
40 | 40 | 'pronamic-pay-forms', |
41 | - plugins_url( 'css/forms' . $min . '.css', \Pronamic\WordPress\Pay\Plugin::$file ), |
|
41 | + plugins_url('css/forms' . $min . '.css', \Pronamic\WordPress\Pay\Plugin::$file), |
|
42 | 42 | array(), |
43 | 43 | $this->plugin->get_version() |
44 | 44 | ); |
@@ -54,11 +54,11 @@ discard block |
||
54 | 54 | $post = get_post(); |
55 | 55 | |
56 | 56 | if ( |
57 | - is_object( $post ) && has_shortcode( $post->post_content, 'pronamic_payment_form' ) |
|
57 | + is_object($post) && has_shortcode($post->post_content, 'pronamic_payment_form') |
|
58 | 58 | || |
59 | - is_singular( 'pronamic_pay_form' ) |
|
59 | + is_singular('pronamic_pay_form') |
|
60 | 60 | ) { |
61 | - wp_enqueue_style( 'pronamic-pay-forms' ); |
|
61 | + wp_enqueue_style('pronamic-pay-forms'); |
|
62 | 62 | } |
63 | 63 | } |
64 | 64 | } |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * @return string |
47 | 47 | */ |
48 | 48 | public function get_source_id() { |
49 | - return filter_input( INPUT_POST, 'pronamic_pay_form_id', FILTER_VALIDATE_INT ); |
|
49 | + return filter_input(INPUT_POST, 'pronamic_pay_form_id', FILTER_VALIDATE_INT); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * @return string |
57 | 57 | */ |
58 | 58 | public function get_description() { |
59 | - return sprintf( __( 'Payment Form %s', 'pronamic_ideal' ), $this->get_order_id() ); |
|
59 | + return sprintf(__('Payment Form %s', 'pronamic_ideal'), $this->get_order_id()); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -80,25 +80,25 @@ discard block |
||
80 | 80 | $items = new Items(); |
81 | 81 | |
82 | 82 | // Amount. |
83 | - $amount_method = get_post_meta( $this->get_source_id(), '_pronamic_payment_form_amount_method', true ); |
|
84 | - $amount = filter_input( INPUT_POST, 'pronamic_pay_amount', FILTER_SANITIZE_STRING ); |
|
83 | + $amount_method = get_post_meta($this->get_source_id(), '_pronamic_payment_form_amount_method', true); |
|
84 | + $amount = filter_input(INPUT_POST, 'pronamic_pay_amount', FILTER_SANITIZE_STRING); |
|
85 | 85 | |
86 | - if ( 'other' === $amount ) { |
|
87 | - $amount = filter_input( INPUT_POST, 'pronamic_pay_amount_other', FILTER_SANITIZE_STRING ); |
|
86 | + if ('other' === $amount) { |
|
87 | + $amount = filter_input(INPUT_POST, 'pronamic_pay_amount_other', FILTER_SANITIZE_STRING); |
|
88 | 88 | |
89 | - $amount = Core_util::string_to_amount( $amount ); |
|
90 | - } elseif ( in_array( $amount_method, array( FormPostType::AMOUNT_METHOD_CHOICES_ONLY, FormPostType::AMOUNT_METHOD_CHOICES_AND_INPUT ), true ) ) { |
|
89 | + $amount = Core_util::string_to_amount($amount); |
|
90 | + } elseif (in_array($amount_method, array(FormPostType::AMOUNT_METHOD_CHOICES_ONLY, FormPostType::AMOUNT_METHOD_CHOICES_AND_INPUT), true)) { |
|
91 | 91 | $amount /= 100; |
92 | 92 | } |
93 | 93 | |
94 | 94 | // Item. |
95 | 95 | $item = new Item(); |
96 | - $item->setNumber( $this->get_order_id() ); |
|
97 | - $item->setDescription( sprintf( __( 'Payment %s', 'pronamic_ideal' ), $this->get_order_id() ) ); |
|
98 | - $item->setPrice( $amount ); |
|
99 | - $item->setQuantity( 1 ); |
|
96 | + $item->setNumber($this->get_order_id()); |
|
97 | + $item->setDescription(sprintf(__('Payment %s', 'pronamic_ideal'), $this->get_order_id())); |
|
98 | + $item->setPrice($amount); |
|
99 | + $item->setQuantity(1); |
|
100 | 100 | |
101 | - $items->addItem( $item ); |
|
101 | + $items->addItem($item); |
|
102 | 102 | |
103 | 103 | return $items; |
104 | 104 | } |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | * @return string |
120 | 120 | */ |
121 | 121 | public function get_email() { |
122 | - return filter_input( INPUT_POST, 'pronamic_pay_email', FILTER_SANITIZE_EMAIL ); |
|
122 | + return filter_input(INPUT_POST, 'pronamic_pay_email', FILTER_SANITIZE_EMAIL); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
@@ -128,8 +128,8 @@ discard block |
||
128 | 128 | * @return string |
129 | 129 | */ |
130 | 130 | public function get_customer_name() { |
131 | - $first_name = filter_input( INPUT_POST, 'pronamic_pay_first_name', FILTER_SANITIZE_STRING ); |
|
132 | - $last_name = filter_input( INPUT_POST, 'pronamic_pay_last_name', FILTER_SANITIZE_STRING ); |
|
131 | + $first_name = filter_input(INPUT_POST, 'pronamic_pay_first_name', FILTER_SANITIZE_STRING); |
|
132 | + $last_name = filter_input(INPUT_POST, 'pronamic_pay_last_name', FILTER_SANITIZE_STRING); |
|
133 | 133 | |
134 | 134 | return $first_name . ' ' . $last_name; |
135 | 135 | } |
@@ -42,11 +42,11 @@ discard block |
||
42 | 42 | * |
43 | 43 | * @param AdminModule $admin Admin Module. |
44 | 44 | */ |
45 | - public function __construct( AdminModule $admin ) { |
|
45 | + public function __construct(AdminModule $admin) { |
|
46 | 46 | $this->admin = $admin; |
47 | 47 | |
48 | 48 | // Actions. |
49 | - add_action( 'admin_init', array( $this, 'admin_init' ), 5 ); |
|
49 | + add_action('admin_init', array($this, 'admin_init'), 5); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
@@ -56,15 +56,15 @@ discard block |
||
56 | 56 | // Install. |
57 | 57 | global $pronamic_pay_version; |
58 | 58 | |
59 | - if ( get_option( 'pronamic_pay_version' ) !== $pronamic_pay_version ) { |
|
59 | + if (get_option('pronamic_pay_version') !== $pronamic_pay_version) { |
|
60 | 60 | $this->install(); |
61 | 61 | } |
62 | 62 | |
63 | 63 | // Maybe update database. |
64 | - if ( filter_has_var( INPUT_GET, 'pronamic_pay_update_db' ) && wp_verify_nonce( filter_input( INPUT_GET, 'pronamic_pay_nonce', FILTER_SANITIZE_STRING ), 'pronamic_pay_update_db' ) ) { |
|
64 | + if (filter_has_var(INPUT_GET, 'pronamic_pay_update_db') && wp_verify_nonce(filter_input(INPUT_GET, 'pronamic_pay_nonce', FILTER_SANITIZE_STRING), 'pronamic_pay_update_db')) { |
|
65 | 65 | $this->update_db(); |
66 | 66 | |
67 | - $this->admin->notices->remove_notice( 'update_db' ); |
|
67 | + $this->admin->notices->remove_notice('update_db'); |
|
68 | 68 | |
69 | 69 | $this->redirect_to_about(); |
70 | 70 | } |
@@ -85,52 +85,52 @@ discard block |
||
85 | 85 | // Database update. |
86 | 86 | $version = $pronamic_pay_version; |
87 | 87 | |
88 | - $parts = explode( '.', $version ); |
|
88 | + $parts = explode('.', $version); |
|
89 | 89 | |
90 | - $major_version = implode( '.', array_slice( $parts, 0, 1 ) ); |
|
91 | - $minor_version = implode( '.', array_slice( $parts, 0, 2 ) ); |
|
90 | + $major_version = implode('.', array_slice($parts, 0, 1)); |
|
91 | + $minor_version = implode('.', array_slice($parts, 0, 2)); |
|
92 | 92 | |
93 | - $current_version = get_option( 'pronamic_pay_version', null ); |
|
94 | - $current_db_version = get_option( 'pronamic_pay_db_version', null ); |
|
93 | + $current_version = get_option('pronamic_pay_version', null); |
|
94 | + $current_db_version = get_option('pronamic_pay_db_version', null); |
|
95 | 95 | |
96 | 96 | if ( |
97 | 97 | $current_db_version |
98 | 98 | && |
99 | 99 | ( |
100 | 100 | // Check for old database version notation without dots, for example `366`. |
101 | - false === strpos( $current_db_version, '.' ) |
|
101 | + false === strpos($current_db_version, '.') |
|
102 | 102 | || |
103 | - version_compare( $current_db_version, max( $this->db_updates ), '<' ) |
|
103 | + version_compare($current_db_version, max($this->db_updates), '<') |
|
104 | 104 | ) |
105 | 105 | ) { |
106 | - $this->admin->notices->add_notice( 'update_db' ); |
|
106 | + $this->admin->notices->add_notice('update_db'); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | // Redirect. |
110 | - if ( null === $current_version ) { |
|
110 | + if (null === $current_version) { |
|
111 | 111 | // No version? This is a new install :). |
112 | 112 | $url = add_query_arg( |
113 | 113 | array( |
114 | 114 | 'page' => 'pronamic-pay-about', |
115 | 115 | 'tab' => 'getting-started', |
116 | - ), admin_url( 'index.php' ) |
|
116 | + ), admin_url('index.php') |
|
117 | 117 | ); |
118 | 118 | |
119 | - set_transient( 'pronamic_pay_admin_redirect', $url, 3600 ); |
|
120 | - } elseif ( version_compare( $current_version, $minor_version, '<' ) ) { |
|
119 | + set_transient('pronamic_pay_admin_redirect', $url, 3600); |
|
120 | + } elseif (version_compare($current_version, $minor_version, '<')) { |
|
121 | 121 | // Show welcome screen for minor updates only. |
122 | 122 | $url = add_query_arg( |
123 | 123 | array( |
124 | 124 | 'page' => 'pronamic-pay-about', |
125 | 125 | 'tab' => 'new', |
126 | - ), admin_url( 'index.php' ) |
|
126 | + ), admin_url('index.php') |
|
127 | 127 | ); |
128 | 128 | |
129 | - set_transient( 'pronamic_pay_admin_redirect', $url, 3600 ); |
|
129 | + set_transient('pronamic_pay_admin_redirect', $url, 3600); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | // Update version. |
133 | - update_option( 'pronamic_pay_version', $version ); |
|
133 | + update_option('pronamic_pay_version', $version); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | /** |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | private function create_roles() { |
144 | 144 | // Payer role. |
145 | 145 | add_role( |
146 | - 'payer', __( 'Payer', 'pronamic_ideal' ), array( |
|
146 | + 'payer', __('Payer', 'pronamic_ideal'), array( |
|
147 | 147 | 'read' => true, |
148 | 148 | ) |
149 | 149 | ); |
@@ -154,18 +154,18 @@ discard block |
||
154 | 154 | // Payments. |
155 | 155 | $payment_capabilities = PaymentPostType::get_capabilities(); |
156 | 156 | |
157 | - unset( $payment_capabilities['publish_posts'] ); |
|
158 | - unset( $payment_capabilities['create_posts'] ); |
|
157 | + unset($payment_capabilities['publish_posts']); |
|
158 | + unset($payment_capabilities['create_posts']); |
|
159 | 159 | |
160 | - foreach ( $payment_capabilities as $capability ) { |
|
161 | - $roles->add_cap( 'administrator', $capability ); |
|
160 | + foreach ($payment_capabilities as $capability) { |
|
161 | + $roles->add_cap('administrator', $capability); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | // Forms. |
165 | 165 | $form_capabilities = FormPostType::get_capabilities(); |
166 | 166 | |
167 | - foreach ( $form_capabilities as $capability ) { |
|
168 | - $roles->add_cap( 'administrator', $capability ); |
|
167 | + foreach ($form_capabilities as $capability) { |
|
168 | + $roles->add_cap('administrator', $capability); |
|
169 | 169 | } |
170 | 170 | } |
171 | 171 | |
@@ -175,32 +175,32 @@ discard block |
||
175 | 175 | public function update_db() { |
176 | 176 | global $pronamic_pay_version; |
177 | 177 | |
178 | - $current_db_version = get_option( 'pronamic_pay_db_version', null ); |
|
178 | + $current_db_version = get_option('pronamic_pay_db_version', null); |
|
179 | 179 | |
180 | - if ( $current_db_version ) { |
|
181 | - foreach ( $this->db_updates as $version ) { |
|
182 | - if ( ! version_compare( $current_db_version, $version, '<' ) ) { |
|
180 | + if ($current_db_version) { |
|
181 | + foreach ($this->db_updates as $version) { |
|
182 | + if ( ! version_compare($current_db_version, $version, '<')) { |
|
183 | 183 | continue; |
184 | 184 | } |
185 | 185 | |
186 | - $file = plugin_dir_path( Plugin::$file ) . 'includes/updates/update-' . $version . '.php'; |
|
186 | + $file = plugin_dir_path(Plugin::$file) . 'includes/updates/update-' . $version . '.php'; |
|
187 | 187 | |
188 | - if ( is_readable( $file ) ) { |
|
188 | + if (is_readable($file)) { |
|
189 | 189 | include $file; |
190 | 190 | |
191 | - update_option( 'pronamic_pay_db_version', $version ); |
|
191 | + update_option('pronamic_pay_db_version', $version); |
|
192 | 192 | } |
193 | 193 | } |
194 | 194 | } |
195 | 195 | |
196 | - update_option( 'pronamic_pay_db_version', $pronamic_pay_version ); |
|
196 | + update_option('pronamic_pay_db_version', $pronamic_pay_version); |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | /** |
200 | 200 | * Redirect to about. |
201 | 201 | */ |
202 | 202 | private function redirect_to_about() { |
203 | - wp_safe_redirect( admin_url( 'index.php?page=pronamic-pay-about' ) ); |
|
203 | + wp_safe_redirect(admin_url('index.php?page=pronamic-pay-about')); |
|
204 | 204 | |
205 | 205 | exit; |
206 | 206 | } |
@@ -36,29 +36,29 @@ discard block |
||
36 | 36 | * Constructs and initializes an admin payment post type object. |
37 | 37 | */ |
38 | 38 | public function __construct() { |
39 | - add_filter( 'request', array( $this, 'request' ) ); |
|
39 | + add_filter('request', array($this, 'request')); |
|
40 | 40 | |
41 | - add_filter( 'manage_edit-' . self::POST_TYPE . '_columns', array( $this, 'columns' ) ); |
|
42 | - add_filter( 'manage_edit-' . self::POST_TYPE . '_sortable_columns', array( $this, 'sortable_columns' ) ); |
|
41 | + add_filter('manage_edit-' . self::POST_TYPE . '_columns', array($this, 'columns')); |
|
42 | + add_filter('manage_edit-' . self::POST_TYPE . '_sortable_columns', array($this, 'sortable_columns')); |
|
43 | 43 | |
44 | - add_action( 'manage_' . self::POST_TYPE . '_posts_custom_column', array( $this, 'custom_columns' ), 10, 2 ); |
|
44 | + add_action('manage_' . self::POST_TYPE . '_posts_custom_column', array($this, 'custom_columns'), 10, 2); |
|
45 | 45 | |
46 | - add_action( 'load-post.php', array( $this, 'maybe_check_status' ) ); |
|
46 | + add_action('load-post.php', array($this, 'maybe_check_status')); |
|
47 | 47 | |
48 | - add_action( 'admin_notices', array( $this, 'admin_notices' ) ); |
|
48 | + add_action('admin_notices', array($this, 'admin_notices')); |
|
49 | 49 | |
50 | - add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) ); |
|
50 | + add_action('add_meta_boxes', array($this, 'add_meta_boxes')); |
|
51 | 51 | |
52 | - add_filter( 'post_row_actions', array( $this, 'post_row_actions' ), 10, 2 ); |
|
52 | + add_filter('post_row_actions', array($this, 'post_row_actions'), 10, 2); |
|
53 | 53 | |
54 | - add_action( 'pre_get_posts', array( $this, 'pre_get_posts' ) ); |
|
54 | + add_action('pre_get_posts', array($this, 'pre_get_posts')); |
|
55 | 55 | |
56 | - add_filter( 'default_hidden_columns', array( $this, 'default_hidden_columns' ) ); |
|
56 | + add_filter('default_hidden_columns', array($this, 'default_hidden_columns')); |
|
57 | 57 | |
58 | - add_filter( 'post_updated_messages', array( $this, 'post_updated_messages' ) ); |
|
58 | + add_filter('post_updated_messages', array($this, 'post_updated_messages')); |
|
59 | 59 | |
60 | 60 | // Transition Post Status. |
61 | - add_action( 'transition_post_status', array( $this, 'transition_post_status' ), 10, 3 ); |
|
61 | + add_action('transition_post_status', array($this, 'transition_post_status'), 10, 3); |
|
62 | 62 | |
63 | 63 | // Bulk Actions. |
64 | 64 | $this->bulk_actions = new PaymentBulkActions(); |
@@ -72,12 +72,12 @@ discard block |
||
72 | 72 | * @param array $vars Request variables. |
73 | 73 | * @return array |
74 | 74 | */ |
75 | - public function request( $vars ) { |
|
75 | + public function request($vars) { |
|
76 | 76 | $screen = get_current_screen(); |
77 | 77 | |
78 | - if ( self::POST_TYPE === $screen->post_type ) { |
|
79 | - if ( ! isset( $vars['post_status'] ) ) { |
|
80 | - $vars['post_status'] = array_keys( \Pronamic\WordPress\Pay\Plugin::get_payment_states() ); |
|
78 | + if (self::POST_TYPE === $screen->post_type) { |
|
79 | + if ( ! isset($vars['post_status'])) { |
|
80 | + $vars['post_status'] = array_keys(\Pronamic\WordPress\Pay\Plugin::get_payment_states()); |
|
81 | 81 | |
82 | 82 | $vars['post_status'][] = 'publish'; |
83 | 83 | } |
@@ -91,27 +91,27 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public function maybe_check_status() { |
93 | 93 | // Current user. |
94 | - if ( ! current_user_can( 'edit_payments' ) ) { |
|
94 | + if ( ! current_user_can('edit_payments')) { |
|
95 | 95 | return; |
96 | 96 | } |
97 | 97 | |
98 | 98 | // Screen. |
99 | 99 | $screen = get_current_screen(); |
100 | 100 | |
101 | - if ( ! ( 'post' === $screen->base && 'pronamic_payment' === $screen->post_type ) ) { |
|
101 | + if ( ! ('post' === $screen->base && 'pronamic_payment' === $screen->post_type)) { |
|
102 | 102 | return; |
103 | 103 | } |
104 | 104 | |
105 | - $post_id = filter_input( INPUT_GET, 'post', FILTER_SANITIZE_NUMBER_INT ); |
|
105 | + $post_id = filter_input(INPUT_GET, 'post', FILTER_SANITIZE_NUMBER_INT); |
|
106 | 106 | |
107 | - if ( filter_has_var( INPUT_GET, 'pronamic_pay_check_status' ) && check_admin_referer( 'pronamic_payment_check_status_' . $post_id ) ) { |
|
108 | - $payment = get_pronamic_payment( $post_id ); |
|
107 | + if (filter_has_var(INPUT_GET, 'pronamic_pay_check_status') && check_admin_referer('pronamic_payment_check_status_' . $post_id)) { |
|
108 | + $payment = get_pronamic_payment($post_id); |
|
109 | 109 | |
110 | - \Pronamic\WordPress\Pay\Plugin::update_payment( $payment, false ); |
|
110 | + \Pronamic\WordPress\Pay\Plugin::update_payment($payment, false); |
|
111 | 111 | |
112 | 112 | $this->admin_notices[] = array( |
113 | 113 | 'type' => 'info', |
114 | - 'message' => __( 'Payment status updated.', 'pronamic_ideal' ), |
|
114 | + 'message' => __('Payment status updated.', 'pronamic_ideal'), |
|
115 | 115 | ); |
116 | 116 | } |
117 | 117 | } |
@@ -120,11 +120,11 @@ discard block |
||
120 | 120 | * Admin notices. |
121 | 121 | */ |
122 | 122 | public function admin_notices() { |
123 | - foreach ( $this->admin_notices as $notice ) { |
|
123 | + foreach ($this->admin_notices as $notice) { |
|
124 | 124 | printf( |
125 | 125 | '<div class="notice notice-%1$s"><p>%2$s</p></div>', |
126 | - esc_attr( $notice['type'] ), |
|
127 | - esc_html( $notice['message'] ) |
|
126 | + esc_attr($notice['type']), |
|
127 | + esc_html($notice['message']) |
|
128 | 128 | ); |
129 | 129 | } |
130 | 130 | } |
@@ -134,10 +134,10 @@ discard block |
||
134 | 134 | * |
135 | 135 | * @param WP_Query $query WordPress query. |
136 | 136 | */ |
137 | - public function pre_get_posts( $query ) { |
|
138 | - if ( 'pronamic_payment_amount' === $query->get( 'orderby' ) ) { |
|
139 | - $query->set( 'meta_key', '_pronamic_payment_amount' ); |
|
140 | - $query->set( 'orderby', 'meta_value_num' ); |
|
137 | + public function pre_get_posts($query) { |
|
138 | + if ('pronamic_payment_amount' === $query->get('orderby')) { |
|
139 | + $query->set('meta_key', '_pronamic_payment_amount'); |
|
140 | + $query->set('orderby', 'meta_value_num'); |
|
141 | 141 | } |
142 | 142 | } |
143 | 143 | |
@@ -147,26 +147,26 @@ discard block |
||
147 | 147 | * @param array $columns Columns. |
148 | 148 | * @return array |
149 | 149 | */ |
150 | - public function columns( $columns ) { |
|
150 | + public function columns($columns) { |
|
151 | 151 | $columns = array( |
152 | 152 | 'cb' => '<input type="checkbox" />', |
153 | 153 | 'pronamic_payment_status' => sprintf( |
154 | 154 | '<span class="pronamic-pay-tip pronamic-pay-icon" title="%s">%s</span>', |
155 | - esc_html__( 'Status', 'pronamic_ideal' ), |
|
156 | - esc_html__( 'Status', 'pronamic_ideal' ) |
|
155 | + esc_html__('Status', 'pronamic_ideal'), |
|
156 | + esc_html__('Status', 'pronamic_ideal') |
|
157 | 157 | ), |
158 | 158 | 'pronamic_payment_subscription' => sprintf( |
159 | 159 | '<span class="pronamic-pay-tip pronamic-pay-icon pronamic-pay-icon-recurring" title="%s">%s</span>', |
160 | - esc_html__( 'Subscription', 'pronamic_ideal' ), |
|
161 | - esc_html__( 'Subscription', 'pronamic_ideal' ) |
|
160 | + esc_html__('Subscription', 'pronamic_ideal'), |
|
161 | + esc_html__('Subscription', 'pronamic_ideal') |
|
162 | 162 | ), |
163 | - 'pronamic_payment_title' => __( 'Payment', 'pronamic_ideal' ), |
|
164 | - 'pronamic_payment_transaction' => __( 'Transaction', 'pronamic_ideal' ), |
|
165 | - 'pronamic_payment_gateway' => __( 'Gateway', 'pronamic_ideal' ), |
|
166 | - 'pronamic_payment_description' => __( 'Description', 'pronamic_ideal' ), |
|
167 | - 'pronamic_payment_customer' => __( 'Customer', 'pronamic_ideal' ), |
|
168 | - 'pronamic_payment_amount' => __( 'Amount', 'pronamic_ideal' ), |
|
169 | - 'pronamic_payment_date' => __( 'Date', 'pronamic_ideal' ), |
|
163 | + 'pronamic_payment_title' => __('Payment', 'pronamic_ideal'), |
|
164 | + 'pronamic_payment_transaction' => __('Transaction', 'pronamic_ideal'), |
|
165 | + 'pronamic_payment_gateway' => __('Gateway', 'pronamic_ideal'), |
|
166 | + 'pronamic_payment_description' => __('Description', 'pronamic_ideal'), |
|
167 | + 'pronamic_payment_customer' => __('Customer', 'pronamic_ideal'), |
|
168 | + 'pronamic_payment_amount' => __('Amount', 'pronamic_ideal'), |
|
169 | + 'pronamic_payment_date' => __('Date', 'pronamic_ideal'), |
|
170 | 170 | ); |
171 | 171 | |
172 | 172 | return $columns; |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | * @param array $hidden Default hidden columns. |
179 | 179 | * @return array |
180 | 180 | */ |
181 | - public function default_hidden_columns( $hidden ) { |
|
181 | + public function default_hidden_columns($hidden) { |
|
182 | 182 | $hidden[] = 'pronamic_payment_gateway'; |
183 | 183 | $hidden[] = 'pronamic_payment_description'; |
184 | 184 | |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | * @param array $sortable_columns Sortable columns. |
192 | 192 | * @return array |
193 | 193 | */ |
194 | - public function sortable_columns( $sortable_columns ) { |
|
194 | + public function sortable_columns($sortable_columns) { |
|
195 | 195 | $sortable_columns['pronamic_payment_title'] = 'ID'; |
196 | 196 | $sortable_columns['pronamic_payment_amount'] = 'pronamic_payment_amount'; |
197 | 197 | $sortable_columns['pronamic_payment_date'] = 'date'; |
@@ -205,52 +205,52 @@ discard block |
||
205 | 205 | * @param string $column Column. |
206 | 206 | * @param string $post_id Post ID. |
207 | 207 | */ |
208 | - public function custom_columns( $column, $post_id ) { |
|
209 | - $payment = get_pronamic_payment( $post_id ); |
|
208 | + public function custom_columns($column, $post_id) { |
|
209 | + $payment = get_pronamic_payment($post_id); |
|
210 | 210 | |
211 | - switch ( $column ) { |
|
211 | + switch ($column) { |
|
212 | 212 | case 'pronamic_payment_status': |
213 | - $post_status = get_post_status( $post_id ); |
|
213 | + $post_status = get_post_status($post_id); |
|
214 | 214 | |
215 | - $label = __( 'Unknown', 'pronamic_ideal' ); |
|
215 | + $label = __('Unknown', 'pronamic_ideal'); |
|
216 | 216 | |
217 | - if ( 'trash' === $post_status ) { |
|
218 | - $post_status = get_post_meta( $post_id, '_wp_trash_meta_status', true ); |
|
217 | + if ('trash' === $post_status) { |
|
218 | + $post_status = get_post_meta($post_id, '_wp_trash_meta_status', true); |
|
219 | 219 | } |
220 | 220 | |
221 | - $status_object = get_post_status_object( $post_status ); |
|
221 | + $status_object = get_post_status_object($post_status); |
|
222 | 222 | |
223 | - if ( isset( $status_object, $status_object->label ) ) { |
|
223 | + if (isset($status_object, $status_object->label)) { |
|
224 | 224 | $label = $status_object->label; |
225 | 225 | } |
226 | 226 | |
227 | 227 | printf( |
228 | 228 | '<span class="pronamic-pay-tip pronamic-pay-icon %s" title="%s">%s</span>', |
229 | - esc_attr( AdminModule::get_post_status_icon_class( $post_status ) ), |
|
230 | - esc_attr( $label ), |
|
231 | - esc_html( $label ) |
|
229 | + esc_attr(AdminModule::get_post_status_icon_class($post_status)), |
|
230 | + esc_attr($label), |
|
231 | + esc_html($label) |
|
232 | 232 | ); |
233 | 233 | |
234 | 234 | break; |
235 | 235 | case 'pronamic_payment_subscription': |
236 | - $subscription_id = get_post_meta( $post_id, '_pronamic_payment_subscription_id', true ); |
|
236 | + $subscription_id = get_post_meta($post_id, '_pronamic_payment_subscription_id', true); |
|
237 | 237 | |
238 | - if ( $subscription_id ) { |
|
239 | - $label = __( 'Recurring payment', 'pronamic_ideal' ); |
|
238 | + if ($subscription_id) { |
|
239 | + $label = __('Recurring payment', 'pronamic_ideal'); |
|
240 | 240 | $class = 'pronamic-pay-icon-recurring'; |
241 | 241 | |
242 | - $recurring = get_post_meta( $post_id, '_pronamic_payment_recurring', true ); |
|
242 | + $recurring = get_post_meta($post_id, '_pronamic_payment_recurring', true); |
|
243 | 243 | |
244 | - if ( ! $recurring ) { |
|
245 | - $label = __( 'First of recurring payment', 'pronamic_ideal' ); |
|
244 | + if ( ! $recurring) { |
|
245 | + $label = __('First of recurring payment', 'pronamic_ideal'); |
|
246 | 246 | $class = ' pronamic-pay-icon-recurring-first'; |
247 | 247 | } |
248 | 248 | |
249 | 249 | printf( |
250 | 250 | '<span class="pronamic-pay-tip pronamic-pay-icon %s" title="%s">%s</span>', |
251 | - esc_attr( $class ), |
|
252 | - esc_attr( $label ), |
|
253 | - esc_attr( $label ) |
|
251 | + esc_attr($class), |
|
252 | + esc_attr($label), |
|
253 | + esc_attr($label) |
|
254 | 254 | ); |
255 | 255 | } |
256 | 256 | |
@@ -264,21 +264,21 @@ discard block |
||
264 | 264 | |
265 | 265 | $source_link = $payment->get_source_link(); |
266 | 266 | |
267 | - if ( null !== $source_link ) { |
|
267 | + if (null !== $source_link) { |
|
268 | 268 | $source_id_text = sprintf( |
269 | 269 | '<a href="%s">%s</a>', |
270 | - esc_url( $source_link ), |
|
270 | + esc_url($source_link), |
|
271 | 271 | $source_id_text |
272 | 272 | ); |
273 | 273 | } |
274 | 274 | |
275 | 275 | echo wp_kses( |
276 | 276 | sprintf( |
277 | - __( '%1$s for %2$s %3$s', 'pronamic_ideal' ), |
|
277 | + __('%1$s for %2$s %3$s', 'pronamic_ideal'), |
|
278 | 278 | sprintf( |
279 | 279 | '<a href="%s" class="row-title"><strong>#%s</strong></a>', |
280 | - esc_url( get_edit_post_link( $post_id ) ), |
|
281 | - esc_html( $post_id ) |
|
280 | + esc_url(get_edit_post_link($post_id)), |
|
281 | + esc_html($post_id) |
|
282 | 282 | ), |
283 | 283 | $source_description, |
284 | 284 | $source_id_text |
@@ -294,58 +294,58 @@ discard block |
||
294 | 294 | |
295 | 295 | break; |
296 | 296 | case 'pronamic_payment_gateway': |
297 | - $config_id = get_post_meta( $post_id, '_pronamic_payment_config_id', true ); |
|
297 | + $config_id = get_post_meta($post_id, '_pronamic_payment_config_id', true); |
|
298 | 298 | |
299 | - if ( ! empty( $config_id ) ) { |
|
300 | - echo get_the_title( $config_id ); |
|
299 | + if ( ! empty($config_id)) { |
|
300 | + echo get_the_title($config_id); |
|
301 | 301 | } else { |
302 | 302 | echo '—'; |
303 | 303 | } |
304 | 304 | |
305 | 305 | break; |
306 | 306 | case 'pronamic_payment_transaction': |
307 | - $transaction_id = get_post_meta( $post_id, '_pronamic_payment_transaction_id', true ); |
|
307 | + $transaction_id = get_post_meta($post_id, '_pronamic_payment_transaction_id', true); |
|
308 | 308 | |
309 | 309 | $url = $payment->get_provider_link(); |
310 | 310 | |
311 | - if ( empty( $url ) ) { |
|
312 | - echo esc_html( $transaction_id ); |
|
311 | + if (empty($url)) { |
|
312 | + echo esc_html($transaction_id); |
|
313 | 313 | } else { |
314 | 314 | printf( |
315 | 315 | '<a href="%s">%s</a>', |
316 | - esc_url( $url ), |
|
317 | - esc_html( $transaction_id ) |
|
316 | + esc_url($url), |
|
317 | + esc_html($transaction_id) |
|
318 | 318 | ); |
319 | 319 | } |
320 | 320 | |
321 | 321 | break; |
322 | 322 | case 'pronamic_payment_description': |
323 | - echo esc_html( get_post_meta( $post_id, '_pronamic_payment_description', true ) ); |
|
323 | + echo esc_html(get_post_meta($post_id, '_pronamic_payment_description', true)); |
|
324 | 324 | |
325 | 325 | break; |
326 | 326 | case 'pronamic_payment_amount': |
327 | - $currency = get_post_meta( $post_id, '_pronamic_payment_currency', true ); |
|
328 | - $amount = get_post_meta( $post_id, '_pronamic_payment_amount', true ); |
|
327 | + $currency = get_post_meta($post_id, '_pronamic_payment_currency', true); |
|
328 | + $amount = get_post_meta($post_id, '_pronamic_payment_amount', true); |
|
329 | 329 | |
330 | - echo esc_html( \Pronamic\WordPress\Pay\Util::format_price( $amount, $currency ) ); |
|
330 | + echo esc_html(\Pronamic\WordPress\Pay\Util::format_price($amount, $currency)); |
|
331 | 331 | |
332 | 332 | break; |
333 | 333 | case 'pronamic_payment_date': |
334 | - echo esc_html( get_the_time( __( 'D j M Y \a\t H:i', 'pronamic_ideal' ), $post_id ) ); |
|
334 | + echo esc_html(get_the_time(__('D j M Y \a\t H:i', 'pronamic_ideal'), $post_id)); |
|
335 | 335 | |
336 | 336 | break; |
337 | 337 | case 'pronamic_payment_consumer': |
338 | - echo esc_html( get_post_meta( $post_id, '_pronamic_payment_consumer_name', true ) ); |
|
338 | + echo esc_html(get_post_meta($post_id, '_pronamic_payment_consumer_name', true)); |
|
339 | 339 | echo '<br />'; |
340 | - echo esc_html( get_post_meta( $post_id, '_pronamic_payment_consumer_account_number', true ) ); |
|
341 | - echo esc_html( get_post_meta( $post_id, '_pronamic_payment_consumer_iban', true ) ); |
|
342 | - echo esc_html( get_post_meta( $post_id, '_pronamic_payment_consumer_bic', true ) ); |
|
340 | + echo esc_html(get_post_meta($post_id, '_pronamic_payment_consumer_account_number', true)); |
|
341 | + echo esc_html(get_post_meta($post_id, '_pronamic_payment_consumer_iban', true)); |
|
342 | + echo esc_html(get_post_meta($post_id, '_pronamic_payment_consumer_bic', true)); |
|
343 | 343 | echo '<br />'; |
344 | - echo esc_html( get_post_meta( $post_id, '_pronamic_payment_consumer_city', true ) ); |
|
344 | + echo esc_html(get_post_meta($post_id, '_pronamic_payment_consumer_city', true)); |
|
345 | 345 | |
346 | 346 | break; |
347 | 347 | case 'pronamic_payment_customer': |
348 | - echo esc_html( get_post_meta( $post_id, '_pronamic_payment_customer_name', true ) ); |
|
348 | + echo esc_html(get_post_meta($post_id, '_pronamic_payment_customer_name', true)); |
|
349 | 349 | |
350 | 350 | break; |
351 | 351 | case 'pronamic_payment_source': |
@@ -360,12 +360,12 @@ discard block |
||
360 | 360 | * |
361 | 361 | * @param string $post_type Post Type. |
362 | 362 | */ |
363 | - public function add_meta_boxes( $post_type ) { |
|
364 | - if ( self::POST_TYPE === $post_type ) { |
|
363 | + public function add_meta_boxes($post_type) { |
|
364 | + if (self::POST_TYPE === $post_type) { |
|
365 | 365 | add_meta_box( |
366 | 366 | 'pronamic_payment', |
367 | - __( 'Payment', 'pronamic_ideal' ), |
|
368 | - array( $this, 'meta_box_info' ), |
|
367 | + __('Payment', 'pronamic_ideal'), |
|
368 | + array($this, 'meta_box_info'), |
|
369 | 369 | $post_type, |
370 | 370 | 'normal', |
371 | 371 | 'high' |
@@ -373,8 +373,8 @@ discard block |
||
373 | 373 | |
374 | 374 | add_meta_box( |
375 | 375 | 'pronamic_payment_subscription', |
376 | - __( 'Subscription', 'pronamic_ideal' ), |
|
377 | - array( $this, 'meta_box_subscription' ), |
|
376 | + __('Subscription', 'pronamic_ideal'), |
|
377 | + array($this, 'meta_box_subscription'), |
|
378 | 378 | $post_type, |
379 | 379 | 'normal', |
380 | 380 | 'high' |
@@ -382,8 +382,8 @@ discard block |
||
382 | 382 | |
383 | 383 | add_meta_box( |
384 | 384 | 'pronamic_payment_log', |
385 | - __( 'Log', 'pronamic_ideal' ), |
|
386 | - array( $this, 'meta_box_log' ), |
|
385 | + __('Log', 'pronamic_ideal'), |
|
386 | + array($this, 'meta_box_log'), |
|
387 | 387 | $post_type, |
388 | 388 | 'normal', |
389 | 389 | 'high' |
@@ -391,15 +391,15 @@ discard block |
||
391 | 391 | |
392 | 392 | add_meta_box( |
393 | 393 | 'pronamic_payment_update', |
394 | - __( 'Update', 'pronamic_ideal' ), |
|
395 | - array( $this, 'meta_box_update' ), |
|
394 | + __('Update', 'pronamic_ideal'), |
|
395 | + array($this, 'meta_box_update'), |
|
396 | 396 | $post_type, |
397 | 397 | 'side', |
398 | 398 | 'high' |
399 | 399 | ); |
400 | 400 | |
401 | 401 | // @see http://kovshenin.com/2012/how-to-remove-the-publish-box-from-a-post-type/. |
402 | - remove_meta_box( 'submitdiv', $post_type, 'side' ); |
|
402 | + remove_meta_box('submitdiv', $post_type, 'side'); |
|
403 | 403 | } |
404 | 404 | } |
405 | 405 | |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | * |
409 | 409 | * @param WP_Post $post The object for the current post/page. |
410 | 410 | */ |
411 | - public function meta_box_info( $post ) { |
|
411 | + public function meta_box_info($post) { |
|
412 | 412 | include \Pronamic\WordPress\Pay\Plugin::$dirname . '/admin/meta-box-payment-info.php'; |
413 | 413 | } |
414 | 414 | |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | * |
418 | 418 | * @param WP_Post $post The object for the current post/page. |
419 | 419 | */ |
420 | - public function meta_box_log( $post ) { |
|
420 | + public function meta_box_log($post) { |
|
421 | 421 | include \Pronamic\WordPress\Pay\Plugin::$dirname . '/admin/meta-box-payment-log.php'; |
422 | 422 | } |
423 | 423 | |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | * |
427 | 427 | * @param WP_Post $post The object for the current post/page. |
428 | 428 | */ |
429 | - public function meta_box_subscription( $post ) { |
|
429 | + public function meta_box_subscription($post) { |
|
430 | 430 | include \Pronamic\WordPress\Pay\Plugin::$dirname . '/admin/meta-box-payment-subscription.php'; |
431 | 431 | } |
432 | 432 | |
@@ -435,8 +435,8 @@ discard block |
||
435 | 435 | * |
436 | 436 | * @param WP_Post $post The object for the current post/page. |
437 | 437 | */ |
438 | - public function meta_box_update( $post ) { |
|
439 | - wp_nonce_field( 'pronamic_payment_update', 'pronamic_payment_update_nonce' ); |
|
438 | + public function meta_box_update($post) { |
|
439 | + wp_nonce_field('pronamic_payment_update', 'pronamic_payment_update_nonce'); |
|
440 | 440 | |
441 | 441 | include \Pronamic\WordPress\Pay\Plugin::$dirname . '/admin/meta-box-payment-update.php'; |
442 | 442 | } |
@@ -448,8 +448,8 @@ discard block |
||
448 | 448 | * @param \WP_Post $post WordPress post. |
449 | 449 | * @return array |
450 | 450 | */ |
451 | - public function post_row_actions( $actions, $post ) { |
|
452 | - if ( self::POST_TYPE === $post->post_type ) { |
|
451 | + public function post_row_actions($actions, $post) { |
|
452 | + if (self::POST_TYPE === $post->post_type) { |
|
453 | 453 | return array(); |
454 | 454 | } |
455 | 455 | |
@@ -462,8 +462,8 @@ discard block |
||
462 | 462 | * @param string $post_status Post status. |
463 | 463 | * @return string |
464 | 464 | */ |
465 | - private function translate_post_status_to_meta_status( $post_status ) { |
|
466 | - switch ( $post_status ) { |
|
465 | + private function translate_post_status_to_meta_status($post_status) { |
|
466 | + switch ($post_status) { |
|
467 | 467 | case 'payment_pending': |
468 | 468 | return \Pronamic\WordPress\Pay\Core\Statuses::OPEN; |
469 | 469 | case 'payment_processing': |
@@ -490,26 +490,26 @@ discard block |
||
490 | 490 | * @param string $old_status Old status. |
491 | 491 | * @param \WP_Post $post WordPress post. |
492 | 492 | */ |
493 | - public function transition_post_status( $new_status, $old_status, $post ) { |
|
493 | + public function transition_post_status($new_status, $old_status, $post) { |
|
494 | 494 | if ( |
495 | - filter_has_var( INPUT_POST, 'pronamic_payment_update_nonce' ) |
|
495 | + filter_has_var(INPUT_POST, 'pronamic_payment_update_nonce') |
|
496 | 496 | && |
497 | - check_admin_referer( 'pronamic_payment_update', 'pronamic_payment_update_nonce' ) |
|
497 | + check_admin_referer('pronamic_payment_update', 'pronamic_payment_update_nonce') |
|
498 | 498 | && |
499 | - 'pronamic_payment' === get_post_type( $post ) |
|
499 | + 'pronamic_payment' === get_post_type($post) |
|
500 | 500 | ) { |
501 | 501 | $can_redirect = false; |
502 | 502 | |
503 | - $old_status_meta = $this->translate_post_status_to_meta_status( $old_status ); |
|
504 | - $new_status_meta = $this->translate_post_status_to_meta_status( $new_status ); |
|
503 | + $old_status_meta = $this->translate_post_status_to_meta_status($old_status); |
|
504 | + $new_status_meta = $this->translate_post_status_to_meta_status($new_status); |
|
505 | 505 | |
506 | - update_post_meta( $post->ID, '_pronamic_payment_status', $new_status_meta ); |
|
506 | + update_post_meta($post->ID, '_pronamic_payment_status', $new_status_meta); |
|
507 | 507 | |
508 | - $payment = get_pronamic_payment( $post->ID ); |
|
508 | + $payment = get_pronamic_payment($post->ID); |
|
509 | 509 | |
510 | - do_action( 'pronamic_payment_status_update_' . $payment->source . '_' . strtolower( $old_status_meta ) . '_to_' . strtolower( $new_status_meta ), $payment, $can_redirect ); |
|
511 | - do_action( 'pronamic_payment_status_update_' . $payment->source, $payment, $can_redirect ); |
|
512 | - do_action( 'pronamic_payment_status_update', $payment, $can_redirect ); |
|
510 | + do_action('pronamic_payment_status_update_' . $payment->source . '_' . strtolower($old_status_meta) . '_to_' . strtolower($new_status_meta), $payment, $can_redirect); |
|
511 | + do_action('pronamic_payment_status_update_' . $payment->source, $payment, $can_redirect); |
|
512 | + do_action('pronamic_payment_status_update', $payment, $can_redirect); |
|
513 | 513 | } |
514 | 514 | } |
515 | 515 | |
@@ -522,34 +522,34 @@ discard block |
||
522 | 522 | * @param array $messages Message. |
523 | 523 | * @return array |
524 | 524 | */ |
525 | - public function post_updated_messages( $messages ) { |
|
525 | + public function post_updated_messages($messages) { |
|
526 | 526 | global $post; |
527 | 527 | |
528 | 528 | // @see https://translate.wordpress.org/projects/wp/4.4.x/admin/nl/default?filters[status]=either&filters[original_id]=2352797&filters[translation_id]=37948900 |
529 | - $scheduled_date = date_i18n( __( 'M j, Y @ H:i', 'pronamic_ideal' ), strtotime( $post->post_date ) ); |
|
529 | + $scheduled_date = date_i18n(__('M j, Y @ H:i', 'pronamic_ideal'), strtotime($post->post_date)); |
|
530 | 530 | |
531 | - $messages[ self::POST_TYPE ] = array( |
|
531 | + $messages[self::POST_TYPE] = array( |
|
532 | 532 | 0 => '', // Unused. Messages start at index 1. |
533 | - 1 => __( 'Payment updated.', 'pronamic_ideal' ), |
|
533 | + 1 => __('Payment updated.', 'pronamic_ideal'), |
|
534 | 534 | // @see https://translate.wordpress.org/projects/wp/4.4.x/admin/nl/default?filters[status]=either&filters[original_id]=2352799&filters[translation_id]=37947229. |
535 | 535 | 2 => $messages['post'][2], |
536 | 536 | // @see https://translate.wordpress.org/projects/wp/4.4.x/admin/nl/default?filters[status]=either&filters[original_id]=2352800&filters[translation_id]=37947870. |
537 | 537 | 3 => $messages['post'][3], |
538 | 538 | // @see https://translate.wordpress.org/projects/wp/4.4.x/admin/nl/default?filters[status]=either&filters[original_id]=2352798&filters[translation_id]=37947230. |
539 | - 4 => __( 'Payment updated.', 'pronamic_ideal' ), |
|
539 | + 4 => __('Payment updated.', 'pronamic_ideal'), |
|
540 | 540 | // @see https://translate.wordpress.org/projects/wp/4.4.x/admin/nl/default?filters[status]=either&filters[original_id]=2352801&filters[translation_id]=37947231. |
541 | 541 | // translators: %s: date and time of the revision |
542 | - 5 => isset( $_GET['revision'] ) ? sprintf( __( 'Payment restored to revision from %s.', 'pronamic_ideal' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, // WPCS: CSRF ok. |
|
542 | + 5 => isset($_GET['revision']) ? sprintf(__('Payment restored to revision from %s.', 'pronamic_ideal'), wp_post_revision_title((int) $_GET['revision'], false)) : false, // WPCS: CSRF ok. |
|
543 | 543 | // @see https://translate.wordpress.org/projects/wp/4.4.x/admin/nl/default?filters[status]=either&filters[original_id]=2352802&filters[translation_id]=37949178. |
544 | - 6 => __( 'Payment published.', 'pronamic_ideal' ), |
|
544 | + 6 => __('Payment published.', 'pronamic_ideal'), |
|
545 | 545 | // @see https://translate.wordpress.org/projects/wp/4.4.x/admin/nl/default?filters[status]=either&filters[original_id]=2352803&filters[translation_id]=37947232. |
546 | - 7 => __( 'Payment saved.', 'pronamic_ideal' ), |
|
546 | + 7 => __('Payment saved.', 'pronamic_ideal'), |
|
547 | 547 | // @see https://translate.wordpress.org/projects/wp/4.4.x/admin/nl/default?filters[status]=either&filters[original_id]=2352804&filters[translation_id]=37949303. |
548 | - 8 => __( 'Payment submitted.', 'pronamic_ideal' ), |
|
548 | + 8 => __('Payment submitted.', 'pronamic_ideal'), |
|
549 | 549 | // @see https://translate.wordpress.org/projects/wp/4.4.x/admin/nl/default?filters[status]=either&filters[original_id]=2352805&filters[translation_id]=37949302. |
550 | - 9 => sprintf( __( 'Payment scheduled for: %s.', 'pronamic_ideal' ), '<strong>' . $scheduled_date . '</strong>' ), |
|
550 | + 9 => sprintf(__('Payment scheduled for: %s.', 'pronamic_ideal'), '<strong>' . $scheduled_date . '</strong>'), |
|
551 | 551 | // @https://translate.wordpress.org/projects/wp/4.4.x/admin/nl/default?filters[status]=either&filters[original_id]=2352806&filters[translation_id]=37949301. |
552 | - 10 => __( 'Payment draft updated.', 'pronamic_ideal' ), |
|
552 | + 10 => __('Payment draft updated.', 'pronamic_ideal'), |
|
553 | 553 | ); |
554 | 554 | |
555 | 555 | return $messages; |
@@ -27,19 +27,19 @@ discard block |
||
27 | 27 | * Constructs and initializes an admin payment post type object. |
28 | 28 | */ |
29 | 29 | public function __construct() { |
30 | - add_filter( 'request', array( $this, 'request' ) ); |
|
30 | + add_filter('request', array($this, 'request')); |
|
31 | 31 | |
32 | - add_filter( 'manage_edit-' . self::POST_TYPE . '_columns', array( $this, 'columns' ) ); |
|
33 | - add_filter( 'manage_edit-' . self::POST_TYPE . '_sortable_columns', array( $this, 'sortable_columns' ) ); |
|
32 | + add_filter('manage_edit-' . self::POST_TYPE . '_columns', array($this, 'columns')); |
|
33 | + add_filter('manage_edit-' . self::POST_TYPE . '_sortable_columns', array($this, 'sortable_columns')); |
|
34 | 34 | |
35 | - add_action( 'manage_' . self::POST_TYPE . '_posts_custom_column', array( $this, 'custom_columns' ), 10, 2 ); |
|
35 | + add_action('manage_' . self::POST_TYPE . '_posts_custom_column', array($this, 'custom_columns'), 10, 2); |
|
36 | 36 | |
37 | - add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) ); |
|
37 | + add_action('add_meta_boxes', array($this, 'add_meta_boxes')); |
|
38 | 38 | |
39 | - add_filter( 'post_row_actions', array( $this, 'post_row_actions' ), 10, 2 ); |
|
39 | + add_filter('post_row_actions', array($this, 'post_row_actions'), 10, 2); |
|
40 | 40 | |
41 | 41 | // Transition post status. |
42 | - add_action( 'transition_post_status', array( $this, 'transition_post_status' ), 10, 3 ); |
|
42 | + add_action('transition_post_status', array($this, 'transition_post_status'), 10, 3); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
@@ -50,12 +50,12 @@ discard block |
||
50 | 50 | * @param array $vars Request variables. |
51 | 51 | * @return array |
52 | 52 | */ |
53 | - public function request( $vars ) { |
|
53 | + public function request($vars) { |
|
54 | 54 | $screen = get_current_screen(); |
55 | 55 | |
56 | - if ( self::POST_TYPE === $screen->post_type ) { |
|
57 | - if ( ! isset( $vars['post_status'] ) ) { |
|
58 | - $vars['post_status'] = array_keys( \Pronamic\WordPress\Pay\Plugin::get_subscription_states() ); |
|
56 | + if (self::POST_TYPE === $screen->post_type) { |
|
57 | + if ( ! isset($vars['post_status'])) { |
|
58 | + $vars['post_status'] = array_keys(\Pronamic\WordPress\Pay\Plugin::get_subscription_states()); |
|
59 | 59 | |
60 | 60 | $vars['post_status'][] = 'publish'; |
61 | 61 | } |
@@ -70,19 +70,19 @@ discard block |
||
70 | 70 | * @param array $columns Columns. |
71 | 71 | * @return array |
72 | 72 | */ |
73 | - public function columns( $columns ) { |
|
73 | + public function columns($columns) { |
|
74 | 74 | $columns = array( |
75 | 75 | 'cb' => '<input type="checkbox" />', |
76 | 76 | 'pronamic_subscription_status' => sprintf( |
77 | 77 | '<span class="pronamic-pay-tip pronamic-pay-icon" title="%s">%s</span>', |
78 | - esc_html__( 'Status', 'pronamic_ideal' ), |
|
79 | - esc_html__( 'Status', 'pronamic_ideal' ) |
|
78 | + esc_html__('Status', 'pronamic_ideal'), |
|
79 | + esc_html__('Status', 'pronamic_ideal') |
|
80 | 80 | ), |
81 | - 'pronamic_subscription_title' => __( 'Subscription', 'pronamic_ideal' ), |
|
82 | - 'pronamic_subscription_customer' => __( 'Customer', 'pronamic_ideal' ), |
|
83 | - 'pronamic_subscription_amount' => __( 'Amount', 'pronamic_ideal' ), |
|
84 | - 'pronamic_subscription_recurring' => __( 'Recurrence', 'pronamic_ideal' ), |
|
85 | - 'pronamic_subscription_date' => __( 'Date', 'pronamic_ideal' ), |
|
81 | + 'pronamic_subscription_title' => __('Subscription', 'pronamic_ideal'), |
|
82 | + 'pronamic_subscription_customer' => __('Customer', 'pronamic_ideal'), |
|
83 | + 'pronamic_subscription_amount' => __('Amount', 'pronamic_ideal'), |
|
84 | + 'pronamic_subscription_recurring' => __('Recurrence', 'pronamic_ideal'), |
|
85 | + 'pronamic_subscription_date' => __('Date', 'pronamic_ideal'), |
|
86 | 86 | ); |
87 | 87 | |
88 | 88 | return $columns; |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | * @param array $sortable_columns Sortable columns. |
95 | 95 | * @return array |
96 | 96 | */ |
97 | - public function sortable_columns( $sortable_columns ) { |
|
97 | + public function sortable_columns($sortable_columns) { |
|
98 | 98 | $sortable_columns['pronamic_subscription_title'] = 'ID'; |
99 | 99 | $sortable_columns['pronamic_subscription_date'] = 'date'; |
100 | 100 | |
@@ -107,30 +107,30 @@ discard block |
||
107 | 107 | * @param string $column Column. |
108 | 108 | * @param string $post_id Post ID. |
109 | 109 | */ |
110 | - public function custom_columns( $column, $post_id ) { |
|
111 | - $subscription = get_pronamic_subscription( $post_id ); |
|
110 | + public function custom_columns($column, $post_id) { |
|
111 | + $subscription = get_pronamic_subscription($post_id); |
|
112 | 112 | |
113 | - switch ( $column ) { |
|
113 | + switch ($column) { |
|
114 | 114 | case 'pronamic_subscription_status': |
115 | - $post_status = get_post_status( $post_id ); |
|
115 | + $post_status = get_post_status($post_id); |
|
116 | 116 | |
117 | - $label = __( 'Unknown', 'pronamic_ideal' ); |
|
117 | + $label = __('Unknown', 'pronamic_ideal'); |
|
118 | 118 | |
119 | - if ( 'trash' === $post_status ) { |
|
120 | - $post_status = get_post_meta( $post_id, '_wp_trash_meta_status', true ); |
|
119 | + if ('trash' === $post_status) { |
|
120 | + $post_status = get_post_meta($post_id, '_wp_trash_meta_status', true); |
|
121 | 121 | } |
122 | 122 | |
123 | - $status_object = get_post_status_object( $post_status ); |
|
123 | + $status_object = get_post_status_object($post_status); |
|
124 | 124 | |
125 | - if ( isset( $status_object, $status_object->label ) ) { |
|
125 | + if (isset($status_object, $status_object->label)) { |
|
126 | 126 | $label = $status_object->label; |
127 | 127 | } |
128 | 128 | |
129 | 129 | printf( |
130 | 130 | '<span class="pronamic-pay-tip pronamic-pay-icon %s" title="%s">%s</span>', |
131 | - esc_attr( AdminModule::get_post_status_icon_class( $post_status ) ), |
|
132 | - esc_attr( $label ), |
|
133 | - esc_html( $label ) |
|
131 | + esc_attr(AdminModule::get_post_status_icon_class($post_status)), |
|
132 | + esc_attr($label), |
|
133 | + esc_html($label) |
|
134 | 134 | ); |
135 | 135 | |
136 | 136 | break; |
@@ -143,21 +143,21 @@ discard block |
||
143 | 143 | |
144 | 144 | $source_link = $subscription->get_source_link(); |
145 | 145 | |
146 | - if ( null !== $source_link ) { |
|
146 | + if (null !== $source_link) { |
|
147 | 147 | $source_id_text = sprintf( |
148 | 148 | '<a href="%s">%s</a>', |
149 | - esc_url( $source_link ), |
|
149 | + esc_url($source_link), |
|
150 | 150 | $source_id_text |
151 | 151 | ); |
152 | 152 | } |
153 | 153 | |
154 | 154 | echo wp_kses( |
155 | 155 | sprintf( |
156 | - __( '%1$s for %2$s %3$s', 'pronamic_ideal' ), |
|
156 | + __('%1$s for %2$s %3$s', 'pronamic_ideal'), |
|
157 | 157 | sprintf( |
158 | 158 | '<a href="%s" class="row-title"><strong>#%s</strong></a>', |
159 | - esc_url( get_edit_post_link( $post_id ) ), |
|
160 | - esc_html( $post_id ) |
|
159 | + esc_url(get_edit_post_link($post_id)), |
|
160 | + esc_html($post_id) |
|
161 | 161 | ), |
162 | 162 | $source_description, |
163 | 163 | $source_id_text |
@@ -173,75 +173,75 @@ discard block |
||
173 | 173 | |
174 | 174 | break; |
175 | 175 | case 'pronamic_subscription_gateway': |
176 | - $payment = get_pronamic_payment_by_meta( '_pronamic_payment_subscription_id', $post_id ); |
|
176 | + $payment = get_pronamic_payment_by_meta('_pronamic_payment_subscription_id', $post_id); |
|
177 | 177 | |
178 | - if ( $payment ) { |
|
179 | - $config_id = get_post_meta( $payment->get_id(), '_pronamic_payment_config_id', true ); |
|
178 | + if ($payment) { |
|
179 | + $config_id = get_post_meta($payment->get_id(), '_pronamic_payment_config_id', true); |
|
180 | 180 | } |
181 | 181 | |
182 | - if ( isset( $config_id ) && ! empty( $config_id ) ) { |
|
183 | - echo get_the_title( $config_id ); |
|
182 | + if (isset($config_id) && ! empty($config_id)) { |
|
183 | + echo get_the_title($config_id); |
|
184 | 184 | } else { |
185 | 185 | echo '—'; |
186 | 186 | } |
187 | 187 | |
188 | 188 | break; |
189 | 189 | case 'pronamic_subscription_description': |
190 | - echo esc_html( get_post_meta( $post_id, '_pronamic_subscription_description', true ) ); |
|
190 | + echo esc_html(get_post_meta($post_id, '_pronamic_subscription_description', true)); |
|
191 | 191 | |
192 | 192 | break; |
193 | 193 | case 'pronamic_subscription_amount': |
194 | - $currency = get_post_meta( $post_id, '_pronamic_subscription_currency', true ); |
|
195 | - $amount = get_post_meta( $post_id, '_pronamic_subscription_amount', true ); |
|
194 | + $currency = get_post_meta($post_id, '_pronamic_subscription_currency', true); |
|
195 | + $amount = get_post_meta($post_id, '_pronamic_subscription_amount', true); |
|
196 | 196 | |
197 | - echo esc_html( \Pronamic\WordPress\Pay\Util::format_price( $amount, $currency ) ); |
|
197 | + echo esc_html(\Pronamic\WordPress\Pay\Util::format_price($amount, $currency)); |
|
198 | 198 | |
199 | 199 | break; |
200 | 200 | case 'pronamic_subscription_interval': |
201 | - echo esc_html( \Pronamic\WordPress\Pay\Util::format_interval( $subscription->get_interval(), $subscription->get_interval_period() ) ); |
|
201 | + echo esc_html(\Pronamic\WordPress\Pay\Util::format_interval($subscription->get_interval(), $subscription->get_interval_period())); |
|
202 | 202 | |
203 | 203 | break; |
204 | 204 | case 'pronamic_subscription_frequency': |
205 | - echo esc_html( \Pronamic\WordPress\Pay\Util::format_frequency( $subscription->get_frequency() ) ); |
|
205 | + echo esc_html(\Pronamic\WordPress\Pay\Util::format_frequency($subscription->get_frequency())); |
|
206 | 206 | |
207 | 207 | break; |
208 | 208 | case 'pronamic_subscription_recurring': |
209 | - echo esc_html( \Pronamic\WordPress\Pay\Util::format_interval( $subscription->get_interval(), $subscription->get_interval_period() ) ); |
|
209 | + echo esc_html(\Pronamic\WordPress\Pay\Util::format_interval($subscription->get_interval(), $subscription->get_interval_period())); |
|
210 | 210 | echo '<br />'; |
211 | - echo esc_html( \Pronamic\WordPress\Pay\Util::format_frequency( $subscription->get_frequency() ) ); |
|
211 | + echo esc_html(\Pronamic\WordPress\Pay\Util::format_frequency($subscription->get_frequency())); |
|
212 | 212 | |
213 | 213 | break; |
214 | 214 | case 'pronamic_subscription_date': |
215 | - the_time( __( 'D j M Y \a\t H:i', 'pronamic_ideal' ) ); |
|
215 | + the_time(__('D j M Y \a\t H:i', 'pronamic_ideal')); |
|
216 | 216 | |
217 | 217 | break; |
218 | 218 | case 'pronamic_subscription_source': |
219 | - $payment = get_pronamic_payment_by_meta( '_pronamic_payment_subscription_id', $post_id ); |
|
219 | + $payment = get_pronamic_payment_by_meta('_pronamic_payment_subscription_id', $post_id); |
|
220 | 220 | |
221 | - if ( $payment ) { |
|
221 | + if ($payment) { |
|
222 | 222 | echo $payment->get_source_text(); // WPCS: XSS ok. |
223 | 223 | } else { |
224 | - $source = get_post_meta( $post_id, '_pronamic_subscription_source', true ); |
|
225 | - $source_id = get_post_meta( $post_id, '_pronamic_subscription_source_id', true ); |
|
224 | + $source = get_post_meta($post_id, '_pronamic_subscription_source', true); |
|
225 | + $source_id = get_post_meta($post_id, '_pronamic_subscription_source_id', true); |
|
226 | 226 | |
227 | 227 | printf( |
228 | 228 | '%s<br />%s', // WPCS: XSS ok. |
229 | - esc_html( $source ), |
|
230 | - esc_html( $source_id ) |
|
229 | + esc_html($source), |
|
230 | + esc_html($source_id) |
|
231 | 231 | ); |
232 | 232 | } |
233 | 233 | |
234 | 234 | break; |
235 | 235 | case 'pronamic_subscription_consumer': |
236 | - echo esc_html( get_post_meta( $post_id, '_pronamic_subscription_consumer_name', true ) ); |
|
236 | + echo esc_html(get_post_meta($post_id, '_pronamic_subscription_consumer_name', true)); |
|
237 | 237 | echo '<br />'; |
238 | - echo esc_html( get_post_meta( $post_id, '_pronamic_subscription_consumer_iban', true ) ); |
|
238 | + echo esc_html(get_post_meta($post_id, '_pronamic_subscription_consumer_iban', true)); |
|
239 | 239 | echo '<br />'; |
240 | - echo esc_html( get_post_meta( $post_id, '_pronamic_subscription_consumer_bic', true ) ); |
|
240 | + echo esc_html(get_post_meta($post_id, '_pronamic_subscription_consumer_bic', true)); |
|
241 | 241 | |
242 | 242 | break; |
243 | 243 | case 'pronamic_subscription_customer': |
244 | - echo esc_html( get_post_meta( $post_id, '_pronamic_subscription_customer_name', true ) ); |
|
244 | + echo esc_html(get_post_meta($post_id, '_pronamic_subscription_customer_name', true)); |
|
245 | 245 | |
246 | 246 | break; |
247 | 247 | } |
@@ -252,12 +252,12 @@ discard block |
||
252 | 252 | * |
253 | 253 | * @param string $post_type Post Type. |
254 | 254 | */ |
255 | - public function add_meta_boxes( $post_type ) { |
|
256 | - if ( self::POST_TYPE === $post_type ) { |
|
255 | + public function add_meta_boxes($post_type) { |
|
256 | + if (self::POST_TYPE === $post_type) { |
|
257 | 257 | add_meta_box( |
258 | 258 | 'pronamic_subscription', |
259 | - __( 'Subscription', 'pronamic_ideal' ), |
|
260 | - array( $this, 'meta_box_info' ), |
|
259 | + __('Subscription', 'pronamic_ideal'), |
|
260 | + array($this, 'meta_box_info'), |
|
261 | 261 | $post_type, |
262 | 262 | 'normal', |
263 | 263 | 'high' |
@@ -265,8 +265,8 @@ discard block |
||
265 | 265 | |
266 | 266 | add_meta_box( |
267 | 267 | 'pronamic_subscription_payments', |
268 | - __( 'Payments', 'pronamic_ideal' ), |
|
269 | - array( $this, 'meta_box_payments' ), |
|
268 | + __('Payments', 'pronamic_ideal'), |
|
269 | + array($this, 'meta_box_payments'), |
|
270 | 270 | $post_type, |
271 | 271 | 'normal', |
272 | 272 | 'high' |
@@ -274,8 +274,8 @@ discard block |
||
274 | 274 | |
275 | 275 | add_meta_box( |
276 | 276 | 'pronamic_subscription_log', |
277 | - __( 'Log', 'pronamic_ideal' ), |
|
278 | - array( $this, 'meta_box_log' ), |
|
277 | + __('Log', 'pronamic_ideal'), |
|
278 | + array($this, 'meta_box_log'), |
|
279 | 279 | $post_type, |
280 | 280 | 'normal', |
281 | 281 | 'high' |
@@ -283,15 +283,15 @@ discard block |
||
283 | 283 | |
284 | 284 | add_meta_box( |
285 | 285 | 'pronamic_subscription_update', |
286 | - __( 'Update', 'pronamic_ideal' ), |
|
287 | - array( $this, 'meta_box_update' ), |
|
286 | + __('Update', 'pronamic_ideal'), |
|
287 | + array($this, 'meta_box_update'), |
|
288 | 288 | $post_type, |
289 | 289 | 'side', |
290 | 290 | 'high' |
291 | 291 | ); |
292 | 292 | |
293 | 293 | // @see http://kovshenin.com/2012/how-to-remove-the-publish-box-from-a-post-type/. |
294 | - remove_meta_box( 'submitdiv', $post_type, 'side' ); |
|
294 | + remove_meta_box('submitdiv', $post_type, 'side'); |
|
295 | 295 | } |
296 | 296 | } |
297 | 297 | |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | * |
301 | 301 | * @param WP_Post $post The object for the current post/page. |
302 | 302 | */ |
303 | - public function meta_box_info( $post ) { |
|
303 | + public function meta_box_info($post) { |
|
304 | 304 | include \Pronamic\WordPress\Pay\Plugin::$dirname . '/admin/meta-box-subscription-info.php'; |
305 | 305 | } |
306 | 306 | |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | * |
310 | 310 | * @param WP_Post $post The object for the current post/page. |
311 | 311 | */ |
312 | - public function meta_box_log( $post ) { |
|
312 | + public function meta_box_log($post) { |
|
313 | 313 | include \Pronamic\WordPress\Pay\Plugin::$dirname . '/admin/meta-box-subscription-log.php'; |
314 | 314 | } |
315 | 315 | |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | * |
319 | 319 | * @param WP_Post $post The object for the current post/page. |
320 | 320 | */ |
321 | - public function meta_box_payments( $post ) { |
|
321 | + public function meta_box_payments($post) { |
|
322 | 322 | include \Pronamic\WordPress\Pay\Plugin::$dirname . '/admin/meta-box-subscription-payments.php'; |
323 | 323 | } |
324 | 324 | |
@@ -327,8 +327,8 @@ discard block |
||
327 | 327 | * |
328 | 328 | * @param WP_Post $post The object for the current post/page. |
329 | 329 | */ |
330 | - public function meta_box_update( $post ) { |
|
331 | - wp_nonce_field( 'pronamic_subscription_update', 'pronamic_subscription_update_nonce' ); |
|
330 | + public function meta_box_update($post) { |
|
331 | + wp_nonce_field('pronamic_subscription_update', 'pronamic_subscription_update_nonce'); |
|
332 | 332 | |
333 | 333 | include \Pronamic\WordPress\Pay\Plugin::$dirname . '/admin/meta-box-subscription-update.php'; |
334 | 334 | } |
@@ -340,8 +340,8 @@ discard block |
||
340 | 340 | * @param \WP_Post $post WordPress post. |
341 | 341 | * @return array |
342 | 342 | */ |
343 | - public function post_row_actions( $actions, $post ) { |
|
344 | - if ( self::POST_TYPE === $post->post_type ) { |
|
343 | + public function post_row_actions($actions, $post) { |
|
344 | + if (self::POST_TYPE === $post->post_type) { |
|
345 | 345 | return array(); |
346 | 346 | } |
347 | 347 | |
@@ -354,8 +354,8 @@ discard block |
||
354 | 354 | * @param string $post_status Post status. |
355 | 355 | * @return string |
356 | 356 | */ |
357 | - private function translate_post_status_to_meta_status( $post_status ) { |
|
358 | - switch ( $post_status ) { |
|
357 | + private function translate_post_status_to_meta_status($post_status) { |
|
358 | + switch ($post_status) { |
|
359 | 359 | case 'subscr_pending': |
360 | 360 | return \Pronamic\WordPress\Pay\Core\Statuses::OPEN; |
361 | 361 | case 'subscr_cancelled': |
@@ -378,36 +378,36 @@ discard block |
||
378 | 378 | * @param string $old_status Old status. |
379 | 379 | * @param \WP_Post $post WordPress post. |
380 | 380 | */ |
381 | - public function transition_post_status( $new_status, $old_status, $post ) { |
|
381 | + public function transition_post_status($new_status, $old_status, $post) { |
|
382 | 382 | if ( |
383 | - filter_has_var( INPUT_POST, 'pronamic_subscription_update_nonce' ) |
|
383 | + filter_has_var(INPUT_POST, 'pronamic_subscription_update_nonce') |
|
384 | 384 | && |
385 | - check_admin_referer( 'pronamic_subscription_update', 'pronamic_subscription_update_nonce' ) |
|
385 | + check_admin_referer('pronamic_subscription_update', 'pronamic_subscription_update_nonce') |
|
386 | 386 | && |
387 | - 'pronamic_pay_subscr' === get_post_type( $post ) |
|
387 | + 'pronamic_pay_subscr' === get_post_type($post) |
|
388 | 388 | ) { |
389 | 389 | $can_redirect = false; |
390 | 390 | |
391 | - $old_status_meta = $this->translate_post_status_to_meta_status( $old_status ); |
|
392 | - $new_status_meta = $this->translate_post_status_to_meta_status( $new_status ); |
|
391 | + $old_status_meta = $this->translate_post_status_to_meta_status($old_status); |
|
392 | + $new_status_meta = $this->translate_post_status_to_meta_status($new_status); |
|
393 | 393 | |
394 | - $subscription = get_pronamic_subscription( $post->ID ); |
|
394 | + $subscription = get_pronamic_subscription($post->ID); |
|
395 | 395 | |
396 | 396 | // Update subscription status. |
397 | - remove_action( 'transition_post_status', array( $this, 'transition_post_status' ), 10, 3 ); |
|
397 | + remove_action('transition_post_status', array($this, 'transition_post_status'), 10, 3); |
|
398 | 398 | |
399 | 399 | $can_redirect = false; |
400 | 400 | |
401 | - $subscription->update_status( $new_status_meta ); |
|
401 | + $subscription->update_status($new_status_meta); |
|
402 | 402 | |
403 | - \Pronamic\WordPress\Pay\Plugin::update_subscription( $subscription, $can_redirect ); |
|
403 | + \Pronamic\WordPress\Pay\Plugin::update_subscription($subscription, $can_redirect); |
|
404 | 404 | |
405 | - add_action( 'transition_post_status', array( $this, 'transition_post_status' ), 10, 3 ); |
|
405 | + add_action('transition_post_status', array($this, 'transition_post_status'), 10, 3); |
|
406 | 406 | |
407 | 407 | // Do subscription status update actions. |
408 | - do_action( 'pronamic_subscription_status_update_' . $subscription->source . '_' . strtolower( $old_status_meta ) . '_to_' . strtolower( $new_status_meta ), $subscription, $can_redirect ); |
|
409 | - do_action( 'pronamic_subscription_status_update_' . $subscription->source, $subscription, $can_redirect ); |
|
410 | - do_action( 'pronamic_subscription_status_update', $subscription, $can_redirect ); |
|
408 | + do_action('pronamic_subscription_status_update_' . $subscription->source . '_' . strtolower($old_status_meta) . '_to_' . strtolower($new_status_meta), $subscription, $can_redirect); |
|
409 | + do_action('pronamic_subscription_status_update_' . $subscription->source, $subscription, $can_redirect); |
|
410 | + do_action('pronamic_subscription_status_update', $subscription, $can_redirect); |
|
411 | 411 | } |
412 | 412 | } |
413 | 413 | } |
@@ -25,28 +25,28 @@ discard block |
||
25 | 25 | * |
26 | 26 | * @param Plugin $plugin Plugin. |
27 | 27 | */ |
28 | - public function __construct( Plugin $plugin ) { |
|
28 | + public function __construct(Plugin $plugin) { |
|
29 | 29 | $this->plugin = $plugin; |
30 | 30 | |
31 | - $this->install = new Install( $this ); |
|
31 | + $this->install = new Install($this); |
|
32 | 32 | |
33 | 33 | // Actions. |
34 | - add_action( 'admin_init', array( $this, 'admin_init' ) ); |
|
35 | - add_action( 'admin_menu', array( $this, 'admin_menu' ) ); |
|
34 | + add_action('admin_init', array($this, 'admin_init')); |
|
35 | + add_action('admin_menu', array($this, 'admin_menu')); |
|
36 | 36 | |
37 | - add_action( 'load-post.php', array( $this, 'maybe_test_payment' ) ); |
|
37 | + add_action('load-post.php', array($this, 'maybe_test_payment')); |
|
38 | 38 | |
39 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); |
|
39 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts')); |
|
40 | 40 | |
41 | - add_filter( 'pronamic_pay_gateway_settings', array( $this, 'gateway_settings' ) ); |
|
41 | + add_filter('pronamic_pay_gateway_settings', array($this, 'gateway_settings')); |
|
42 | 42 | |
43 | 43 | // Modules. |
44 | - $this->settings = new AdminSettings( $plugin ); |
|
45 | - $this->about = new AdminAboutPage( $plugin, $this ); |
|
46 | - $this->dashboard = new AdminDashboard( $plugin ); |
|
47 | - $this->notices = new AdminNotices( $plugin ); |
|
48 | - $this->reports = new AdminReports( $plugin, $this ); |
|
49 | - $this->tour = new AdminTour( $plugin ); |
|
44 | + $this->settings = new AdminSettings($plugin); |
|
45 | + $this->about = new AdminAboutPage($plugin, $this); |
|
46 | + $this->dashboard = new AdminDashboard($plugin); |
|
47 | + $this->notices = new AdminNotices($plugin); |
|
48 | + $this->reports = new AdminReports($plugin, $this); |
|
49 | + $this->tour = new AdminTour($plugin); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
@@ -62,15 +62,15 @@ discard block |
||
62 | 62 | $this->maybe_redirect(); |
63 | 63 | |
64 | 64 | // Post types. |
65 | - new GatewayPostType( $this ); |
|
65 | + new GatewayPostType($this); |
|
66 | 66 | new PaymentPostType(); |
67 | 67 | new SubscriptionPostType(); |
68 | 68 | |
69 | 69 | // Gateway settings. |
70 | 70 | $this->gateway_settings = new GatewaySettings(); |
71 | 71 | |
72 | - if ( ! wp_next_scheduled( 'pronamic_pay_license_check' ) ) { |
|
73 | - wp_schedule_event( time(), 'daily', 'pronamic_pay_license_check' ); |
|
72 | + if ( ! wp_next_scheduled('pronamic_pay_license_check')) { |
|
73 | + wp_schedule_event(time(), 'daily', 'pronamic_pay_license_check'); |
|
74 | 74 | } |
75 | 75 | } |
76 | 76 | |
@@ -81,33 +81,33 @@ discard block |
||
81 | 81 | * @see https://github.com/woothemes/woocommerce/blob/2.4.4/includes/admin/class-wc-admin.php#L96-L122 |
82 | 82 | */ |
83 | 83 | public function maybe_redirect() { |
84 | - $redirect = get_transient( 'pronamic_pay_admin_redirect' ); |
|
84 | + $redirect = get_transient('pronamic_pay_admin_redirect'); |
|
85 | 85 | |
86 | 86 | // Check. |
87 | 87 | if ( |
88 | 88 | false === $redirect |
89 | 89 | || |
90 | - defined( 'DOING_AJAX' ) && DOING_AJAX |
|
90 | + defined('DOING_AJAX') && DOING_AJAX |
|
91 | 91 | || |
92 | - defined( 'DOING_CRON' ) && DOING_CRON |
|
92 | + defined('DOING_CRON') && DOING_CRON |
|
93 | 93 | || |
94 | 94 | is_network_admin() |
95 | 95 | || |
96 | - filter_has_var( INPUT_GET, 'activate-multi' ) |
|
96 | + filter_has_var(INPUT_GET, 'activate-multi') |
|
97 | 97 | || |
98 | - ! current_user_can( 'manage_options' ) |
|
98 | + ! current_user_can('manage_options') |
|
99 | 99 | ) { |
100 | 100 | return; |
101 | 101 | } |
102 | 102 | |
103 | 103 | // Update. |
104 | - set_transient( 'pronamic_pay_admin_redirect', false ); |
|
104 | + set_transient('pronamic_pay_admin_redirect', false); |
|
105 | 105 | |
106 | 106 | // Delete. |
107 | - delete_transient( 'pronamic_pay_admin_redirect' ); |
|
107 | + delete_transient('pronamic_pay_admin_redirect'); |
|
108 | 108 | |
109 | 109 | // Redirect. |
110 | - wp_safe_redirect( $redirect ); |
|
110 | + wp_safe_redirect($redirect); |
|
111 | 111 | |
112 | 112 | exit; |
113 | 113 | } |
@@ -117,37 +117,37 @@ discard block |
||
117 | 117 | * |
118 | 118 | * @param array $args Arguments. |
119 | 119 | */ |
120 | - public static function input_checkbox( $args ) { |
|
120 | + public static function input_checkbox($args) { |
|
121 | 121 | $defaults = array( |
122 | 122 | 'label_for' => '', |
123 | 123 | 'type' => 'text', |
124 | 124 | 'label' => '', |
125 | 125 | ); |
126 | 126 | |
127 | - $args = wp_parse_args( $args, $defaults ); |
|
127 | + $args = wp_parse_args($args, $defaults); |
|
128 | 128 | |
129 | 129 | $id = $args['label_for']; |
130 | - $value = get_option( $id ); |
|
130 | + $value = get_option($id); |
|
131 | 131 | |
132 | 132 | $legend = sprintf( |
133 | 133 | '<legend class="screen-reader-text"><span>%s</span></legend>', |
134 | - esc_html( $args['label'] ) |
|
134 | + esc_html($args['label']) |
|
135 | 135 | ); |
136 | 136 | |
137 | 137 | $input = sprintf( |
138 | 138 | '<input name="%s" id="%s" type="%s" value="%s" %s />', |
139 | - esc_attr( $id ), |
|
140 | - esc_attr( $id ), |
|
141 | - esc_attr( 'checkbox' ), |
|
142 | - esc_attr( '1' ), |
|
143 | - checked( $value, true, false ) |
|
139 | + esc_attr($id), |
|
140 | + esc_attr($id), |
|
141 | + esc_attr('checkbox'), |
|
142 | + esc_attr('1'), |
|
143 | + checked($value, true, false) |
|
144 | 144 | ); |
145 | 145 | |
146 | 146 | $label = sprintf( |
147 | 147 | '<label for="%s">%s %s</label>', |
148 | - esc_attr( $id ), |
|
148 | + esc_attr($id), |
|
149 | 149 | $input, |
150 | - esc_html( $args['label'] ) |
|
150 | + esc_html($args['label']) |
|
151 | 151 | ); |
152 | 152 | |
153 | 153 | printf( // WPCS: XSS ok. |
@@ -163,8 +163,8 @@ discard block |
||
163 | 163 | * @param mixed $value Value. |
164 | 164 | * @return boolean |
165 | 165 | */ |
166 | - public static function sanitize_boolean( $value ) { |
|
167 | - return filter_var( $value, FILTER_VALIDATE_BOOLEAN ); |
|
166 | + public static function sanitize_boolean($value) { |
|
167 | + return filter_var($value, FILTER_VALIDATE_BOOLEAN); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | /** |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | * @param array $args Arguments. |
174 | 174 | * @return string |
175 | 175 | */ |
176 | - public static function dropdown_configs( $args ) { |
|
176 | + public static function dropdown_configs($args) { |
|
177 | 177 | $defaults = array( |
178 | 178 | 'name' => 'pronamic_pay_config_id', |
179 | 179 | 'echo' => true, |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | 'payment_method' => null, |
182 | 182 | ); |
183 | 183 | |
184 | - $args = wp_parse_args( $args, $defaults ); |
|
184 | + $args = wp_parse_args($args, $defaults); |
|
185 | 185 | |
186 | 186 | // Output. |
187 | 187 | $output = ''; |
@@ -191,31 +191,31 @@ discard block |
||
191 | 191 | $name = $args['name']; |
192 | 192 | $selected = $args['selected']; |
193 | 193 | |
194 | - if ( false === $selected ) { |
|
195 | - $selected = get_option( $id ); |
|
194 | + if (false === $selected) { |
|
195 | + $selected = get_option($id); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | $output .= sprintf( |
199 | 199 | '<select id="%s" name="%s">', |
200 | - esc_attr( $id ), |
|
201 | - esc_attr( $name ) |
|
200 | + esc_attr($id), |
|
201 | + esc_attr($name) |
|
202 | 202 | ); |
203 | 203 | |
204 | - $options = \Pronamic\WordPress\Pay\Plugin::get_config_select_options( $args['payment_method'] ); |
|
204 | + $options = \Pronamic\WordPress\Pay\Plugin::get_config_select_options($args['payment_method']); |
|
205 | 205 | |
206 | - foreach ( $options as $value => $name ) { |
|
206 | + foreach ($options as $value => $name) { |
|
207 | 207 | $output .= sprintf( |
208 | 208 | '<option value="%s" %s>%s</option>', |
209 | - esc_attr( $value ), |
|
210 | - selected( $value, $selected, false ), |
|
211 | - esc_html( $name ) |
|
209 | + esc_attr($value), |
|
210 | + selected($value, $selected, false), |
|
211 | + esc_html($name) |
|
212 | 212 | ); |
213 | 213 | } |
214 | 214 | |
215 | - $output .= sprintf( '</select>' ); |
|
215 | + $output .= sprintf('</select>'); |
|
216 | 216 | |
217 | 217 | // Return or echo. |
218 | - if ( $args['echo'] ) { |
|
218 | + if ($args['echo']) { |
|
219 | 219 | echo $output; // WPCS: XSS ok. |
220 | 220 | } else { |
221 | 221 | return $output; |
@@ -228,8 +228,8 @@ discard block |
||
228 | 228 | * @param array $pages Page. |
229 | 229 | * @param string $parent Parent post ID. |
230 | 230 | */ |
231 | - private function create_pages( $pages, $parent = null ) { |
|
232 | - foreach ( $pages as $page ) { |
|
231 | + private function create_pages($pages, $parent = null) { |
|
232 | + foreach ($pages as $page) { |
|
233 | 233 | $post = array( |
234 | 234 | 'post_title' => $page['post_title'], |
235 | 235 | 'post_name' => $page['post_title'], |
@@ -239,25 +239,25 @@ discard block |
||
239 | 239 | 'comment_status' => 'closed', |
240 | 240 | ); |
241 | 241 | |
242 | - if ( isset( $parent ) ) { |
|
242 | + if (isset($parent)) { |
|
243 | 243 | $post['post_parent'] = $parent; |
244 | 244 | } |
245 | 245 | |
246 | - $result = wp_insert_post( $post, true ); |
|
246 | + $result = wp_insert_post($post, true); |
|
247 | 247 | |
248 | - if ( ! is_wp_error( $result ) ) { |
|
249 | - if ( isset( $page['post_meta'] ) ) { |
|
250 | - foreach ( $page['post_meta'] as $key => $value ) { |
|
251 | - update_post_meta( $result, $key, $value ); |
|
248 | + if ( ! is_wp_error($result)) { |
|
249 | + if (isset($page['post_meta'])) { |
|
250 | + foreach ($page['post_meta'] as $key => $value) { |
|
251 | + update_post_meta($result, $key, $value); |
|
252 | 252 | } |
253 | 253 | } |
254 | 254 | |
255 | - if ( isset( $page['option_name'] ) ) { |
|
256 | - update_option( $page['option_name'], $result ); |
|
255 | + if (isset($page['option_name'])) { |
|
256 | + update_option($page['option_name'], $result); |
|
257 | 257 | } |
258 | 258 | |
259 | - if ( isset( $page['children'] ) ) { |
|
260 | - $this->create_pages( $page['children'], $result ); |
|
259 | + if (isset($page['children'])) { |
|
260 | + $this->create_pages($page['children'], $result); |
|
261 | 261 | } |
262 | 262 | } |
263 | 263 | } |
@@ -267,63 +267,63 @@ discard block |
||
267 | 267 | * Maybe create pages. |
268 | 268 | */ |
269 | 269 | public function maybe_create_pages() { |
270 | - if ( ! filter_has_var( INPUT_POST, 'pronamic_pay_create_pages' ) ) { |
|
270 | + if ( ! filter_has_var(INPUT_POST, 'pronamic_pay_create_pages')) { |
|
271 | 271 | return; |
272 | 272 | } |
273 | 273 | |
274 | - if ( ! check_admin_referer( 'pronamic_pay_settings', 'pronamic_pay_nonce' ) ) { |
|
274 | + if ( ! check_admin_referer('pronamic_pay_settings', 'pronamic_pay_nonce')) { |
|
275 | 275 | return; |
276 | 276 | } |
277 | 277 | |
278 | 278 | $pages = array( |
279 | 279 | array( |
280 | - 'post_title' => __( 'Payment Status', 'pronamic_ideal' ), |
|
281 | - 'post_name' => __( 'payment', 'pronamic_ideal' ), |
|
280 | + 'post_title' => __('Payment Status', 'pronamic_ideal'), |
|
281 | + 'post_name' => __('payment', 'pronamic_ideal'), |
|
282 | 282 | 'post_content' => '', |
283 | 283 | 'post_meta' => array( |
284 | 284 | '_yoast_wpseo_meta-robots-noindex' => true, |
285 | 285 | ), |
286 | 286 | 'children' => array( |
287 | 287 | 'completed' => array( |
288 | - 'post_title' => __( 'Payment completed', 'pronamic_ideal' ), |
|
289 | - 'post_name' => __( 'completed', 'pronamic_ideal' ), |
|
290 | - 'post_content' => __( '<p>The payment has been successfully completed.</p>', 'pronamic_ideal' ), |
|
288 | + 'post_title' => __('Payment completed', 'pronamic_ideal'), |
|
289 | + 'post_name' => __('completed', 'pronamic_ideal'), |
|
290 | + 'post_content' => __('<p>The payment has been successfully completed.</p>', 'pronamic_ideal'), |
|
291 | 291 | 'post_meta' => array( |
292 | 292 | '_yoast_wpseo_meta-robots-noindex' => true, |
293 | 293 | ), |
294 | 294 | 'option_name' => 'pronamic_pay_completed_page_id', |
295 | 295 | ), |
296 | 296 | 'cancel' => array( |
297 | - 'post_title' => __( 'Payment cancelled', 'pronamic_ideal' ), |
|
298 | - 'post_name' => __( 'cancelled', 'pronamic_ideal' ), |
|
299 | - 'post_content' => __( '<p>You have cancelled the payment.</p>', 'pronamic_ideal' ), |
|
297 | + 'post_title' => __('Payment cancelled', 'pronamic_ideal'), |
|
298 | + 'post_name' => __('cancelled', 'pronamic_ideal'), |
|
299 | + 'post_content' => __('<p>You have cancelled the payment.</p>', 'pronamic_ideal'), |
|
300 | 300 | 'post_meta' => array( |
301 | 301 | '_yoast_wpseo_meta-robots-noindex' => true, |
302 | 302 | ), |
303 | 303 | 'option_name' => 'pronamic_pay_cancel_page_id', |
304 | 304 | ), |
305 | 305 | 'expired' => array( |
306 | - 'post_title' => __( 'Payment expired', 'pronamic_ideal' ), |
|
307 | - 'post_name' => __( 'expired', 'pronamic_ideal' ), |
|
308 | - 'post_content' => __( '<p>Your payment session has expired.</p>', 'pronamic_ideal' ), |
|
306 | + 'post_title' => __('Payment expired', 'pronamic_ideal'), |
|
307 | + 'post_name' => __('expired', 'pronamic_ideal'), |
|
308 | + 'post_content' => __('<p>Your payment session has expired.</p>', 'pronamic_ideal'), |
|
309 | 309 | 'post_meta' => array( |
310 | 310 | '_yoast_wpseo_meta-robots-noindex' => true, |
311 | 311 | ), |
312 | 312 | 'option_name' => 'pronamic_pay_expired_page_id', |
313 | 313 | ), |
314 | 314 | 'error' => array( |
315 | - 'post_title' => __( 'Payment error', 'pronamic_ideal' ), |
|
316 | - 'post_name' => __( 'error', 'pronamic_ideal' ), |
|
317 | - 'post_content' => __( '<p>An error has occurred during payment.</p>', 'pronamic_ideal' ), |
|
315 | + 'post_title' => __('Payment error', 'pronamic_ideal'), |
|
316 | + 'post_name' => __('error', 'pronamic_ideal'), |
|
317 | + 'post_content' => __('<p>An error has occurred during payment.</p>', 'pronamic_ideal'), |
|
318 | 318 | 'post_meta' => array( |
319 | 319 | '_yoast_wpseo_meta-robots-noindex' => true, |
320 | 320 | ), |
321 | 321 | 'option_name' => 'pronamic_pay_error_page_id', |
322 | 322 | ), |
323 | 323 | 'unknown' => array( |
324 | - 'post_title' => __( 'Payment status unknown', 'pronamic_ideal' ), |
|
325 | - 'post_name' => __( 'unknown', 'pronamic_ideal' ), |
|
326 | - 'post_content' => __( '<p>The payment status is unknown.</p>', 'pronamic_ideal' ), |
|
324 | + 'post_title' => __('Payment status unknown', 'pronamic_ideal'), |
|
325 | + 'post_name' => __('unknown', 'pronamic_ideal'), |
|
326 | + 'post_content' => __('<p>The payment status is unknown.</p>', 'pronamic_ideal'), |
|
327 | 327 | 'post_meta' => array( |
328 | 328 | '_yoast_wpseo_meta-robots-noindex' => true, |
329 | 329 | ), |
@@ -333,16 +333,16 @@ discard block |
||
333 | 333 | ), |
334 | 334 | ); |
335 | 335 | |
336 | - $this->create_pages( $pages ); |
|
336 | + $this->create_pages($pages); |
|
337 | 337 | |
338 | 338 | $url = add_query_arg( |
339 | 339 | array( |
340 | 340 | 'page' => 'pronamic_pay_settings', |
341 | 341 | 'message' => 'pages-generated', |
342 | - ), admin_url( 'admin.php' ) |
|
342 | + ), admin_url('admin.php') |
|
343 | 343 | ); |
344 | 344 | |
345 | - wp_redirect( $url ); |
|
345 | + wp_redirect($url); |
|
346 | 346 | |
347 | 347 | exit; |
348 | 348 | } |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | * |
353 | 353 | * @param string $hook Hook. |
354 | 354 | */ |
355 | - public function enqueue_scripts( $hook ) { |
|
355 | + public function enqueue_scripts($hook) { |
|
356 | 356 | $screen = get_current_screen(); |
357 | 357 | |
358 | 358 | $enqueue = false; |
@@ -366,17 +366,17 @@ discard block |
||
366 | 366 | ), true |
367 | 367 | ); |
368 | 368 | $enqueue |= 'dashboard' === $screen->id; |
369 | - $enqueue |= strpos( $hook, 'pronamic_pay' ) !== false; |
|
370 | - $enqueue |= strpos( $hook, 'pronamic_ideal' ) !== false; |
|
369 | + $enqueue |= strpos($hook, 'pronamic_pay') !== false; |
|
370 | + $enqueue |= strpos($hook, 'pronamic_ideal') !== false; |
|
371 | 371 | $enqueue |= 'toplevel_page_gf_edit_forms' === $screen->id; |
372 | 372 | |
373 | - if ( $enqueue ) { |
|
374 | - $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
373 | + if ($enqueue) { |
|
374 | + $min = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
375 | 375 | |
376 | 376 | // Tippy.js - https://atomiks.github.io/tippyjs/. |
377 | 377 | wp_register_script( |
378 | 378 | 'tippy.js', |
379 | - plugins_url( 'assets/tippy.js/tippy.all' . $min . '.js', \Pronamic\WordPress\Pay\Plugin::$file ), |
|
379 | + plugins_url('assets/tippy.js/tippy.all' . $min . '.js', \Pronamic\WordPress\Pay\Plugin::$file), |
|
380 | 380 | array(), |
381 | 381 | '2.2.3', |
382 | 382 | true |
@@ -385,29 +385,29 @@ discard block |
||
385 | 385 | // Pronamic. |
386 | 386 | wp_register_style( |
387 | 387 | 'pronamic-pay-icons', |
388 | - plugins_url( 'fonts/pronamic-pay-icons.css', \Pronamic\WordPress\Pay\Plugin::$file ), |
|
388 | + plugins_url('fonts/pronamic-pay-icons.css', \Pronamic\WordPress\Pay\Plugin::$file), |
|
389 | 389 | array(), |
390 | 390 | $this->plugin->get_version() |
391 | 391 | ); |
392 | 392 | |
393 | 393 | wp_register_style( |
394 | 394 | 'pronamic-pay-admin', |
395 | - plugins_url( 'css/admin' . $min . '.css', \Pronamic\WordPress\Pay\Plugin::$file ), |
|
396 | - array( 'pronamic-pay-icons' ), |
|
395 | + plugins_url('css/admin' . $min . '.css', \Pronamic\WordPress\Pay\Plugin::$file), |
|
396 | + array('pronamic-pay-icons'), |
|
397 | 397 | $this->plugin->get_version() |
398 | 398 | ); |
399 | 399 | |
400 | 400 | wp_register_script( |
401 | 401 | 'pronamic-pay-admin', |
402 | - plugins_url( 'js/admin' . $min . '.js', \Pronamic\WordPress\Pay\Plugin::$file ), |
|
403 | - array( 'jquery', 'tippy.js' ), |
|
402 | + plugins_url('js/admin' . $min . '.js', \Pronamic\WordPress\Pay\Plugin::$file), |
|
403 | + array('jquery', 'tippy.js'), |
|
404 | 404 | $this->plugin->get_version(), |
405 | 405 | true |
406 | 406 | ); |
407 | 407 | |
408 | 408 | // Enqueue. |
409 | - wp_enqueue_style( 'pronamic-pay-admin' ); |
|
410 | - wp_enqueue_script( 'pronamic-pay-admin' ); |
|
409 | + wp_enqueue_style('pronamic-pay-admin'); |
|
410 | + wp_enqueue_script('pronamic-pay-admin'); |
|
411 | 411 | } |
412 | 412 | } |
413 | 413 | |
@@ -415,12 +415,12 @@ discard block |
||
415 | 415 | * Maybe test payment. |
416 | 416 | */ |
417 | 417 | public function maybe_test_payment() { |
418 | - if ( filter_has_var( INPUT_POST, 'test_pay_gateway' ) && check_admin_referer( 'test_pay_gateway', 'pronamic_pay_test_nonce' ) ) { |
|
419 | - $id = filter_input( INPUT_POST, 'post_ID', FILTER_SANITIZE_NUMBER_INT ); |
|
418 | + if (filter_has_var(INPUT_POST, 'test_pay_gateway') && check_admin_referer('test_pay_gateway', 'pronamic_pay_test_nonce')) { |
|
419 | + $id = filter_input(INPUT_POST, 'post_ID', FILTER_SANITIZE_NUMBER_INT); |
|
420 | 420 | |
421 | - $gateway = \Pronamic\WordPress\Pay\Plugin::get_gateway( $id ); |
|
421 | + $gateway = \Pronamic\WordPress\Pay\Plugin::get_gateway($id); |
|
422 | 422 | |
423 | - if ( $gateway ) { |
|
423 | + if ($gateway) { |
|
424 | 424 | $amount = filter_input( |
425 | 425 | INPUT_POST, 'test_amount', FILTER_VALIDATE_FLOAT, array( |
426 | 426 | 'flags' => FILTER_FLAG_ALLOW_THOUSAND, |
@@ -430,21 +430,21 @@ discard block |
||
430 | 430 | ) |
431 | 431 | ); |
432 | 432 | |
433 | - $data = new \Pronamic\WordPress\Pay\Payments\PaymentTestData( wp_get_current_user(), $amount ); |
|
433 | + $data = new \Pronamic\WordPress\Pay\Payments\PaymentTestData(wp_get_current_user(), $amount); |
|
434 | 434 | |
435 | - $payment_method = filter_input( INPUT_POST, 'pronamic_pay_test_payment_method', FILTER_SANITIZE_STRING ); |
|
435 | + $payment_method = filter_input(INPUT_POST, 'pronamic_pay_test_payment_method', FILTER_SANITIZE_STRING); |
|
436 | 436 | |
437 | - $payment = \Pronamic\WordPress\Pay\Plugin::start( $id, $gateway, $data, $payment_method ); |
|
437 | + $payment = \Pronamic\WordPress\Pay\Plugin::start($id, $gateway, $data, $payment_method); |
|
438 | 438 | |
439 | 439 | $error = $gateway->get_error(); |
440 | 440 | |
441 | - if ( is_wp_error( $error ) ) { |
|
442 | - \Pronamic\WordPress\Pay\Plugin::render_errors( $error ); |
|
441 | + if (is_wp_error($error)) { |
|
442 | + \Pronamic\WordPress\Pay\Plugin::render_errors($error); |
|
443 | 443 | |
444 | 444 | exit; |
445 | 445 | } |
446 | 446 | |
447 | - $gateway->redirect( $payment ); |
|
447 | + $gateway->redirect($payment); |
|
448 | 448 | } |
449 | 449 | } |
450 | 450 | } |
@@ -454,10 +454,10 @@ discard block |
||
454 | 454 | */ |
455 | 455 | public function admin_menu() { |
456 | 456 | // @see https://github.com/woothemes/woocommerce/blob/2.3.13/includes/admin/class-wc-admin-menus.php#L145 |
457 | - $counts = wp_count_posts( 'pronamic_payment' ); |
|
457 | + $counts = wp_count_posts('pronamic_payment'); |
|
458 | 458 | |
459 | 459 | $badge = ''; |
460 | - if ( isset( $counts, $counts->payment_pending ) && $counts->payment_pending > 0 ) { |
|
460 | + if (isset($counts, $counts->payment_pending) && $counts->payment_pending > 0) { |
|
461 | 461 | $badge = sprintf( |
462 | 462 | ' <span class="awaiting-mod update-plugins count-%s"><span class="processing-count">%s</span></span>', |
463 | 463 | $counts->payment_pending, |
@@ -466,70 +466,70 @@ discard block |
||
466 | 466 | } |
467 | 467 | |
468 | 468 | add_menu_page( |
469 | - __( 'Pronamic Pay', 'pronamic_ideal' ), |
|
470 | - __( 'Pay', 'pronamic_ideal' ) . $badge, |
|
469 | + __('Pronamic Pay', 'pronamic_ideal'), |
|
470 | + __('Pay', 'pronamic_ideal') . $badge, |
|
471 | 471 | 'edit_payments', |
472 | 472 | 'pronamic_ideal', |
473 | - array( $this, 'page_dashboard' ), |
|
473 | + array($this, 'page_dashboard'), |
|
474 | 474 | 'dashicons-money' |
475 | 475 | ); |
476 | 476 | |
477 | 477 | add_submenu_page( |
478 | 478 | 'pronamic_ideal', |
479 | - __( 'Payments', 'pronamic_ideal' ), |
|
480 | - __( 'Payments', 'pronamic_ideal' ) . $badge, |
|
479 | + __('Payments', 'pronamic_ideal'), |
|
480 | + __('Payments', 'pronamic_ideal') . $badge, |
|
481 | 481 | 'edit_payments', |
482 | 482 | 'edit.php?post_type=pronamic_payment' |
483 | 483 | ); |
484 | 484 | |
485 | 485 | add_submenu_page( |
486 | 486 | 'pronamic_ideal', |
487 | - __( 'Subscriptions', 'pronamic_ideal' ), |
|
488 | - __( 'Subscriptions', 'pronamic_ideal' ), |
|
487 | + __('Subscriptions', 'pronamic_ideal'), |
|
488 | + __('Subscriptions', 'pronamic_ideal'), |
|
489 | 489 | 'edit_payments', |
490 | 490 | 'edit.php?post_type=pronamic_pay_subscr' |
491 | 491 | ); |
492 | 492 | |
493 | - do_action( 'pronamic_pay_admin_menu' ); |
|
493 | + do_action('pronamic_pay_admin_menu'); |
|
494 | 494 | |
495 | 495 | add_submenu_page( |
496 | 496 | 'pronamic_ideal', |
497 | - __( 'Payment Forms', 'pronamic_ideal' ), |
|
498 | - __( 'Forms', 'pronamic_ideal' ), |
|
497 | + __('Payment Forms', 'pronamic_ideal'), |
|
498 | + __('Forms', 'pronamic_ideal'), |
|
499 | 499 | 'edit_forms', |
500 | 500 | 'edit.php?post_type=pronamic_pay_form' |
501 | 501 | ); |
502 | 502 | |
503 | 503 | add_submenu_page( |
504 | 504 | 'pronamic_ideal', |
505 | - __( 'Configurations', 'pronamic_ideal' ), |
|
506 | - __( 'Configurations', 'pronamic_ideal' ), |
|
505 | + __('Configurations', 'pronamic_ideal'), |
|
506 | + __('Configurations', 'pronamic_ideal'), |
|
507 | 507 | 'manage_options', |
508 | 508 | 'edit.php?post_type=pronamic_gateway' |
509 | 509 | ); |
510 | 510 | |
511 | 511 | add_submenu_page( |
512 | 512 | 'pronamic_ideal', |
513 | - __( 'Settings', 'pronamic_ideal' ), |
|
514 | - __( 'Settings', 'pronamic_ideal' ), |
|
513 | + __('Settings', 'pronamic_ideal'), |
|
514 | + __('Settings', 'pronamic_ideal'), |
|
515 | 515 | 'manage_options', |
516 | 516 | 'pronamic_pay_settings', |
517 | - array( $this, 'page_settings' ) |
|
517 | + array($this, 'page_settings') |
|
518 | 518 | ); |
519 | 519 | |
520 | 520 | add_submenu_page( |
521 | 521 | 'pronamic_ideal', |
522 | - __( 'Tools', 'pronamic_ideal' ), |
|
523 | - __( 'Tools', 'pronamic_ideal' ), |
|
522 | + __('Tools', 'pronamic_ideal'), |
|
523 | + __('Tools', 'pronamic_ideal'), |
|
524 | 524 | 'manage_options', |
525 | 525 | 'pronamic_pay_tools', |
526 | - array( $this, 'page_tools' ) |
|
526 | + array($this, 'page_tools') |
|
527 | 527 | ); |
528 | 528 | |
529 | 529 | global $submenu; |
530 | 530 | |
531 | - if ( isset( $submenu['pronamic_ideal'] ) ) { |
|
532 | - $submenu['pronamic_ideal'][0][0] = __( 'Dashboard', 'pronamic_ideal' ); // WPCS: override ok. |
|
531 | + if (isset($submenu['pronamic_ideal'])) { |
|
532 | + $submenu['pronamic_ideal'][0][0] = __('Dashboard', 'pronamic_ideal'); // WPCS: override ok. |
|
533 | 533 | } |
534 | 534 | } |
535 | 535 | |
@@ -537,21 +537,21 @@ discard block |
||
537 | 537 | * Page dashboard. |
538 | 538 | */ |
539 | 539 | public function page_dashboard() { |
540 | - return $this->render_page( 'dashboard' ); |
|
540 | + return $this->render_page('dashboard'); |
|
541 | 541 | } |
542 | 542 | |
543 | 543 | /** |
544 | 544 | * Page settings. |
545 | 545 | */ |
546 | 546 | public function page_settings() { |
547 | - return $this->render_page( 'settings' ); |
|
547 | + return $this->render_page('settings'); |
|
548 | 548 | } |
549 | 549 | |
550 | 550 | /** |
551 | 551 | * Page tools. |
552 | 552 | */ |
553 | 553 | public function page_tools() { |
554 | - return $this->render_page( 'tools' ); |
|
554 | + return $this->render_page('tools'); |
|
555 | 555 | } |
556 | 556 | |
557 | 557 | /** |
@@ -560,12 +560,12 @@ discard block |
||
560 | 560 | * @param string $name Page identifier. |
561 | 561 | * @return boolean True if a page is rendered, false otherwise. |
562 | 562 | */ |
563 | - public function render_page( $name ) { |
|
563 | + public function render_page($name) { |
|
564 | 564 | $result = false; |
565 | 565 | |
566 | - $file = plugin_dir_path( \Pronamic\WordPress\Pay\Plugin::$file ) . 'admin/page-' . $name . '.php'; |
|
566 | + $file = plugin_dir_path(\Pronamic\WordPress\Pay\Plugin::$file) . 'admin/page-' . $name . '.php'; |
|
567 | 567 | |
568 | - if ( is_readable( $file ) ) { |
|
568 | + if (is_readable($file)) { |
|
569 | 569 | include $file; |
570 | 570 | |
571 | 571 | $result = true; |
@@ -579,20 +579,20 @@ discard block |
||
579 | 579 | * |
580 | 580 | * @param array $classes Classes. |
581 | 581 | */ |
582 | - public function gateway_settings( $classes ) { |
|
583 | - foreach ( $this->plugin->gateway_integrations as $integration ) { |
|
582 | + public function gateway_settings($classes) { |
|
583 | + foreach ($this->plugin->gateway_integrations as $integration) { |
|
584 | 584 | $class = $integration->get_settings_class(); |
585 | 585 | |
586 | - if ( null === $class ) { |
|
586 | + if (null === $class) { |
|
587 | 587 | continue; |
588 | 588 | } |
589 | 589 | |
590 | - if ( is_array( $class ) ) { |
|
591 | - foreach ( $class as $c ) { |
|
592 | - $classes[ $c ] = $c; |
|
590 | + if (is_array($class)) { |
|
591 | + foreach ($class as $c) { |
|
592 | + $classes[$c] = $c; |
|
593 | 593 | } |
594 | 594 | } else { |
595 | - $classes[ $class ] = $class; |
|
595 | + $classes[$class] = $class; |
|
596 | 596 | } |
597 | 597 | } |
598 | 598 | |
@@ -605,8 +605,8 @@ discard block |
||
605 | 605 | * @param string $post_status Post status. |
606 | 606 | * @return string |
607 | 607 | */ |
608 | - public static function get_post_status_icon_class( $post_status ) { |
|
609 | - switch ( $post_status ) { |
|
608 | + public static function get_post_status_icon_class($post_status) { |
|
609 | + switch ($post_status) { |
|
610 | 610 | case 'payment_pending': |
611 | 611 | case 'subscr_pending': |
612 | 612 | return 'pronamic-pay-icon-pending'; |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * Constructs and initializes an admin payment bulk actions object. |
24 | 24 | */ |
25 | 25 | public function __construct() { |
26 | - add_action( 'load-edit.php', array( $this, 'load' ) ); |
|
26 | + add_action('load-edit.php', array($this, 'load')); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
@@ -31,24 +31,24 @@ discard block |
||
31 | 31 | */ |
32 | 32 | public function load() { |
33 | 33 | // Current user. |
34 | - if ( ! current_user_can( 'edit_payments' ) ) { |
|
34 | + if ( ! current_user_can('edit_payments')) { |
|
35 | 35 | return; |
36 | 36 | } |
37 | 37 | |
38 | 38 | // Screen. |
39 | 39 | $screen = get_current_screen(); |
40 | 40 | |
41 | - if ( 'edit-pronamic_payment' !== $screen->id ) { |
|
41 | + if ('edit-pronamic_payment' !== $screen->id) { |
|
42 | 42 | return; |
43 | 43 | } |
44 | 44 | |
45 | 45 | // Bulk actions. |
46 | - add_filter( 'bulk_actions-' . $screen->id, array( $this, 'bulk_actions' ) ); |
|
46 | + add_filter('bulk_actions-' . $screen->id, array($this, 'bulk_actions')); |
|
47 | 47 | |
48 | - add_filter( 'handle_bulk_actions-' . $screen->id, array( $this, 'handle_bulk_action' ), 10, 3 ); |
|
48 | + add_filter('handle_bulk_actions-' . $screen->id, array($this, 'handle_bulk_action'), 10, 3); |
|
49 | 49 | |
50 | 50 | // Admin notices. |
51 | - add_action( 'admin_notices', array( $this, 'admin_notices' ) ); |
|
51 | + add_action('admin_notices', array($this, 'admin_notices')); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
@@ -59,12 +59,12 @@ discard block |
||
59 | 59 | * @param array $bulk_actions Bulk actions. |
60 | 60 | * @return array |
61 | 61 | */ |
62 | - public function bulk_actions( $bulk_actions ) { |
|
62 | + public function bulk_actions($bulk_actions) { |
|
63 | 63 | // Don't allow edit in bulk. |
64 | - unset( $bulk_actions['edit'] ); |
|
64 | + unset($bulk_actions['edit']); |
|
65 | 65 | |
66 | 66 | // Bulk check payment status. |
67 | - $bulk_actions['pronamic_payment_check_status'] = __( 'Check Payment Status', 'pronamic_ideal' ); |
|
67 | + $bulk_actions['pronamic_payment_check_status'] = __('Check Payment Status', 'pronamic_ideal'); |
|
68 | 68 | |
69 | 69 | return $bulk_actions; |
70 | 70 | } |
@@ -79,8 +79,8 @@ discard block |
||
79 | 79 | * @param array $post_ids Post ID's to bulk edit. |
80 | 80 | * @return string |
81 | 81 | */ |
82 | - public function handle_bulk_action( $sendback, $doaction, $post_ids ) { |
|
83 | - if ( 'pronamic_payment_check_status' !== $doaction ) { |
|
82 | + public function handle_bulk_action($sendback, $doaction, $post_ids) { |
|
83 | + if ('pronamic_payment_check_status' !== $doaction) { |
|
84 | 84 | return $sendback; |
85 | 85 | } |
86 | 86 | |
@@ -89,11 +89,11 @@ discard block |
||
89 | 89 | $unsupported_gateways = array(); |
90 | 90 | $gateways = array(); |
91 | 91 | |
92 | - foreach ( $post_ids as $post_id ) { |
|
93 | - $payment = get_pronamic_payment( $post_id ); |
|
92 | + foreach ($post_ids as $post_id) { |
|
93 | + $payment = get_pronamic_payment($post_id); |
|
94 | 94 | |
95 | 95 | // Only check status for pending payments. |
96 | - if ( \Pronamic\WordPress\Pay\Core\Statuses::OPEN !== $payment->status && '' !== $payment->status ) { |
|
96 | + if (\Pronamic\WordPress\Pay\Core\Statuses::OPEN !== $payment->status && '' !== $payment->status) { |
|
97 | 97 | $skipped_check++; |
98 | 98 | |
99 | 99 | continue; |
@@ -102,19 +102,19 @@ discard block |
||
102 | 102 | // Make sure gateway supports `payment_status_request` feature. |
103 | 103 | $config_id = $payment->config_id; |
104 | 104 | |
105 | - if ( ! isset( $gateways[ $config_id ] ) ) { |
|
106 | - $gateways[ $config_id ] = \Pronamic\WordPress\Pay\Plugin::get_gateway( $config_id ); |
|
105 | + if ( ! isset($gateways[$config_id])) { |
|
106 | + $gateways[$config_id] = \Pronamic\WordPress\Pay\Plugin::get_gateway($config_id); |
|
107 | 107 | |
108 | - if ( $gateways[ $config_id ] && ! $gateways[ $config_id ]->supports( 'payment_status_request' ) ) { |
|
108 | + if ($gateways[$config_id] && ! $gateways[$config_id]->supports('payment_status_request')) { |
|
109 | 109 | $unsupported_gateways[] = $config_id; |
110 | 110 | } |
111 | 111 | } |
112 | 112 | |
113 | - if ( in_array( $config_id, $unsupported_gateways, true ) ) { |
|
113 | + if (in_array($config_id, $unsupported_gateways, true)) { |
|
114 | 114 | continue; |
115 | 115 | } |
116 | 116 | |
117 | - \Pronamic\WordPress\Pay\Plugin::update_payment( $payment, false ); |
|
117 | + \Pronamic\WordPress\Pay\Plugin::update_payment($payment, false); |
|
118 | 118 | |
119 | 119 | $status_updated++; |
120 | 120 | } |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | array( |
124 | 124 | 'status_updated' => $status_updated, |
125 | 125 | 'skipped_check' => $skipped_check, |
126 | - 'unsupported_gateways' => implode( ',', $unsupported_gateways ), |
|
126 | + 'unsupported_gateways' => implode(',', $unsupported_gateways), |
|
127 | 127 | ), $sendback |
128 | 128 | ); |
129 | 129 | |
@@ -134,50 +134,50 @@ discard block |
||
134 | 134 | * Admin notices. |
135 | 135 | */ |
136 | 136 | public function admin_notices() { |
137 | - if ( filter_has_var( INPUT_GET, 'status_updated' ) ) { |
|
138 | - $updated = filter_input( INPUT_GET, 'status_updated', FILTER_VALIDATE_INT ); |
|
137 | + if (filter_has_var(INPUT_GET, 'status_updated')) { |
|
138 | + $updated = filter_input(INPUT_GET, 'status_updated', FILTER_VALIDATE_INT); |
|
139 | 139 | |
140 | - if ( $updated > 0 ) { |
|
141 | - $message = sprintf( _n( '%s payment updated.', '%s payments updated.', $updated, 'pronamic_ideal' ), number_format_i18n( $updated ) ); |
|
140 | + if ($updated > 0) { |
|
141 | + $message = sprintf(_n('%s payment updated.', '%s payments updated.', $updated, 'pronamic_ideal'), number_format_i18n($updated)); |
|
142 | 142 | |
143 | 143 | printf( |
144 | 144 | '<div class="notice notice-success"><p>%s</p></div>', |
145 | - esc_html( $message ) |
|
145 | + esc_html($message) |
|
146 | 146 | ); |
147 | 147 | } |
148 | 148 | } |
149 | 149 | |
150 | - if ( filter_has_var( INPUT_GET, 'skipped_check' ) ) { |
|
151 | - $updated = filter_input( INPUT_GET, 'skipped_check', FILTER_VALIDATE_INT ); |
|
150 | + if (filter_has_var(INPUT_GET, 'skipped_check')) { |
|
151 | + $updated = filter_input(INPUT_GET, 'skipped_check', FILTER_VALIDATE_INT); |
|
152 | 152 | |
153 | - if ( $updated > 0 ) { |
|
153 | + if ($updated > 0) { |
|
154 | 154 | $message = sprintf( |
155 | - _n( '%s payment is not updated because it already has a final payment status.', '%s payments are not updated because they already have a final payment status.', $updated, 'pronamic_ideal' ), |
|
156 | - number_format_i18n( $updated ) |
|
155 | + _n('%s payment is not updated because it already has a final payment status.', '%s payments are not updated because they already have a final payment status.', $updated, 'pronamic_ideal'), |
|
156 | + number_format_i18n($updated) |
|
157 | 157 | ); |
158 | 158 | |
159 | 159 | printf( |
160 | 160 | '<div class="notice notice-warning"><p>%s</p></div>', |
161 | - esc_html( $message ) |
|
161 | + esc_html($message) |
|
162 | 162 | ); |
163 | 163 | } |
164 | 164 | } |
165 | 165 | |
166 | - if ( filter_has_var( INPUT_GET, 'unsupported_gateways' ) ) { |
|
167 | - $unsupported = filter_input( INPUT_GET, 'unsupported_gateways', FILTER_SANITIZE_STRING ); |
|
166 | + if (filter_has_var(INPUT_GET, 'unsupported_gateways')) { |
|
167 | + $unsupported = filter_input(INPUT_GET, 'unsupported_gateways', FILTER_SANITIZE_STRING); |
|
168 | 168 | |
169 | - if ( '' !== $unsupported ) { |
|
170 | - $gateways = explode( ',', $unsupported ); |
|
169 | + if ('' !== $unsupported) { |
|
170 | + $gateways = explode(',', $unsupported); |
|
171 | 171 | |
172 | - foreach ( $gateways as $index => $config_id ) { |
|
173 | - $gateways[ $index ] = get_the_title( $config_id ); |
|
172 | + foreach ($gateways as $index => $config_id) { |
|
173 | + $gateways[$index] = get_the_title($config_id); |
|
174 | 174 | } |
175 | 175 | |
176 | - $message = sprintf( __( 'Requesting the current payment status is unsupported by %s.', 'pronamic_ideal' ), implode( ', ', $gateways ) ); |
|
176 | + $message = sprintf(__('Requesting the current payment status is unsupported by %s.', 'pronamic_ideal'), implode(', ', $gateways)); |
|
177 | 177 | |
178 | 178 | printf( |
179 | 179 | '<div class="notice notice-error"><p>%s</p></div>', |
180 | - esc_html( $message ) |
|
180 | + esc_html($message) |
|
181 | 181 | ); |
182 | 182 | } |
183 | 183 | } |
@@ -44,31 +44,31 @@ discard block |
||
44 | 44 | * @param Plugin $plugin Plugin. |
45 | 45 | * @param AdminModule $admin Admin. |
46 | 46 | */ |
47 | - public function __construct( Plugin $plugin, AdminModule $admin ) { |
|
47 | + public function __construct(Plugin $plugin, AdminModule $admin) { |
|
48 | 48 | $this->plugin = $plugin; |
49 | 49 | $this->admin = $admin; |
50 | 50 | |
51 | 51 | // Actions. |
52 | - add_action( 'admin_menu', array( $this, 'admin_menu' ) ); |
|
53 | - add_action( 'admin_head', array( $this, 'admin_head' ) ); |
|
52 | + add_action('admin_menu', array($this, 'admin_menu')); |
|
53 | + add_action('admin_head', array($this, 'admin_head')); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
57 | 57 | * Add admin menus/screens. |
58 | 58 | */ |
59 | 59 | public function admin_menu() { |
60 | - $page = filter_input( INPUT_GET, 'page', FILTER_SANITIZE_STRING ); |
|
60 | + $page = filter_input(INPUT_GET, 'page', FILTER_SANITIZE_STRING); |
|
61 | 61 | |
62 | - if ( 'pronamic-pay-about' === $page ) { |
|
62 | + if ('pronamic-pay-about' === $page) { |
|
63 | 63 | $hook_suffix = add_dashboard_page( |
64 | - __( 'About Pronamic Pay', 'pronamic_ideal' ), |
|
65 | - __( 'Welcome to Pronamic Pay', 'pronamic_ideal' ), |
|
64 | + __('About Pronamic Pay', 'pronamic_ideal'), |
|
65 | + __('Welcome to Pronamic Pay', 'pronamic_ideal'), |
|
66 | 66 | 'manage_options', |
67 | 67 | $page, |
68 | - array( $this, 'page_about' ) |
|
68 | + array($this, 'page_about') |
|
69 | 69 | ); |
70 | 70 | |
71 | - add_action( 'admin_print_styles-' . $hook_suffix, array( $this, 'admin_css' ) ); |
|
71 | + add_action('admin_print_styles-' . $hook_suffix, array($this, 'admin_css')); |
|
72 | 72 | } |
73 | 73 | } |
74 | 74 | |
@@ -76,18 +76,18 @@ discard block |
||
76 | 76 | * Admin head. |
77 | 77 | */ |
78 | 78 | public function admin_head() { |
79 | - remove_submenu_page( 'index.php', 'pronamic-pay-about' ); |
|
79 | + remove_submenu_page('index.php', 'pronamic-pay-about'); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
83 | 83 | * Admin CSS. |
84 | 84 | */ |
85 | 85 | public function admin_css() { |
86 | - $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
86 | + $min = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
87 | 87 | |
88 | 88 | wp_enqueue_style( |
89 | 89 | 'proanmic-pay-admin-about', |
90 | - plugins_url( 'css/admin-about' . $min . '.css', Plugin::$file ), |
|
90 | + plugins_url('css/admin-about' . $min . '.css', Plugin::$file), |
|
91 | 91 | array(), |
92 | 92 | $this->plugin->get_version() |
93 | 93 | ); |
@@ -97,6 +97,6 @@ discard block |
||
97 | 97 | * Page about. |
98 | 98 | */ |
99 | 99 | public function page_about() { |
100 | - $this->admin->render_page( 'about' ); |
|
100 | + $this->admin->render_page('about'); |
|
101 | 101 | } |
102 | 102 | } |