@@ -48,7 +48,7 @@ |
||
48 | 48 | * |
49 | 49 | * @param array $field_options The options. |
50 | 50 | * @param string $template_id The template ID. |
51 | - * @param int|string|float $field The field ID. |
|
51 | + * @param int|string|float $field_id The field ID. |
|
52 | 52 | * @param string $context The configuration context (edit, single, etc.) |
53 | 53 | * @param string $input_type The input type. |
54 | 54 | * @param int $form_id The form ID. |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | |
19 | 19 | public function __construct() { |
20 | 20 | $this->label = esc_html__( 'Unsubscribe', 'gravityview' ); |
21 | - $this->description = esc_attr__( 'Unsubscribe from a Payment-based entry.', 'gravityview' ); |
|
21 | + $this->description = esc_attr__( 'Unsubscribe from a Payment-based entry.', 'gravityview' ); |
|
22 | 22 | |
23 | 23 | $this->add_hooks(); |
24 | 24 | |
@@ -57,13 +57,13 @@ discard block |
||
57 | 57 | */ |
58 | 58 | public function field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ) { |
59 | 59 | |
60 | - unset( $field_options['only_loggedin'] ); |
|
60 | + unset( $field_options[ 'only_loggedin' ] ); |
|
61 | 61 | |
62 | - unset( $field_options['new_window'] ); |
|
62 | + unset( $field_options[ 'new_window' ] ); |
|
63 | 63 | |
64 | - unset( $field_options['show_as_link'] ); |
|
64 | + unset( $field_options[ 'show_as_link' ] ); |
|
65 | 65 | |
66 | - $add_options['unsub_all'] = array( |
|
66 | + $add_options[ 'unsub_all' ] = array( |
|
67 | 67 | 'type' => 'checkbox', |
68 | 68 | 'label' => __( 'Allow admins to unsubscribe', 'gravityview' ), |
69 | 69 | 'desc' => __( 'Allow users with `gravityforms_edit_entries` to cancel subscriptions', 'gravityview' ), |
@@ -120,9 +120,9 @@ discard block |
||
120 | 120 | } |
121 | 121 | |
122 | 122 | foreach ( $feeds as $feed ) { |
123 | - if ( isset( $subscription_addons[ $feed['addon_slug'] ] ) && \GV\Utils::get( $feed, 'meta/transactionType' ) == 'subscription' ) { |
|
124 | - if ( ! isset( $entry_default_fields["{$this->name}"] ) && 'edit' !== $context ) { |
|
125 | - $entry_default_fields["{$this->name}"] = array( |
|
123 | + if ( isset( $subscription_addons[ $feed[ 'addon_slug' ] ] ) && \GV\Utils::get( $feed, 'meta/transactionType' ) == 'subscription' ) { |
|
124 | + if ( ! isset( $entry_default_fields[ "{$this->name}" ] ) && 'edit' !== $context ) { |
|
125 | + $entry_default_fields[ "{$this->name}" ] = array( |
|
126 | 126 | 'label' => $this->label, |
127 | 127 | 'desc' => $this->description, |
128 | 128 | 'type' => $this->name, |
@@ -153,10 +153,10 @@ discard block |
||
153 | 153 | return $output; |
154 | 154 | } |
155 | 155 | |
156 | - $can_current_user_edit = is_numeric( $entry['created_by'] ) && ( wp_get_current_user()->ID === intval( $entry['created_by'] ) ); |
|
156 | + $can_current_user_edit = is_numeric( $entry[ 'created_by' ] ) && ( wp_get_current_user()->ID === intval( $entry[ 'created_by' ] ) ); |
|
157 | 157 | |
158 | 158 | if ( ! $can_current_user_edit ) { |
159 | - if ( empty( $field_settings['unsub_all'] ) || ! \GVCommon::has_cap( 'gravityforms_edit_entries', $entry['id'] ) ) { |
|
159 | + if ( empty( $field_settings[ 'unsub_all' ] ) || ! \GVCommon::has_cap( 'gravityforms_edit_entries', $entry[ 'id' ] ) ) { |
|
160 | 160 | return $output; |
161 | 161 | } |
162 | 162 | } |
@@ -169,21 +169,21 @@ discard block |
||
169 | 169 | // @todo Also make sure we check caps if moved from here |
170 | 170 | // @todo Also make sure test_GravityView_Field_Unsubscribe_unsubscribe_permissions is rewritten |
171 | 171 | if ( $entry = $this->maybe_unsubscribe( $entry ) ) { |
172 | - if ( $entry['payment_status'] !== $status ) { |
|
172 | + if ( $entry[ 'payment_status' ] !== $status ) { |
|
173 | 173 | // @todo Probably __( 'Unsubscribed', 'gravityview' ); |
174 | - return $entry['payment_status']; |
|
174 | + return $entry[ 'payment_status' ]; |
|
175 | 175 | } |
176 | 176 | } |
177 | 177 | |
178 | - if ( strtolower( $entry['payment_status'] ) !== 'active' ) { |
|
178 | + if ( strtolower( $entry[ 'payment_status' ] ) !== 'active' ) { |
|
179 | 179 | return $output; |
180 | 180 | } |
181 | 181 | |
182 | 182 | global $wp; |
183 | 183 | $current_url = add_query_arg( $wp->query_string, '', home_url( $wp->request ) ); |
184 | 184 | |
185 | - $link = add_query_arg( 'unsubscribe', wp_create_nonce( 'unsubscribe_' . $entry['id'] ), $current_url ); |
|
186 | - $link = add_query_arg( 'uid', urlencode( $entry['id'] ), $link ); |
|
185 | + $link = add_query_arg( 'unsubscribe', wp_create_nonce( 'unsubscribe_' . $entry[ 'id' ] ), $current_url ); |
|
186 | + $link = add_query_arg( 'uid', urlencode( $entry[ 'id' ] ), $link ); |
|
187 | 187 | |
188 | 188 | return sprintf( '<a href="%s">%s</a>', $link, __( 'Unsubscribe', 'gravityview' ) ); |
189 | 189 | } |
@@ -202,11 +202,11 @@ discard block |
||
202 | 202 | * @return \GV\Entry $entry The entry |
203 | 203 | */ |
204 | 204 | private function maybe_unsubscribe( $entry ) { |
205 | - if ( ! wp_verify_nonce( \GV\Utils::_REQUEST( 'unsubscribe' ), 'unsubscribe_' . $entry['id'] ) ) { |
|
205 | + if ( ! wp_verify_nonce( \GV\Utils::_REQUEST( 'unsubscribe' ), 'unsubscribe_' . $entry[ 'id' ] ) ) { |
|
206 | 206 | return $entry; |
207 | 207 | } |
208 | 208 | |
209 | - if ( ( ! $uid = \GV\Utils::_REQUEST( 'uid' ) ) || ! is_numeric( $uid ) || ( intval( $uid ) !== intval( $entry['id'] ) ) ) { |
|
209 | + if ( ( ! $uid = \GV\Utils::_REQUEST( 'uid' ) ) || ! is_numeric( $uid ) || ( intval( $uid ) !== intval( $entry[ 'id' ] ) ) ) { |
|
210 | 210 | return $entry; |
211 | 211 | } |
212 | 212 | |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | if ( ( $feed = $subscription_addons[ $slug ]->get_feed( $feed_id ) ) && \GV\Utils::get( $feed, 'meta/transactionType' ) === 'subscription' ) { |
235 | 235 | if ( $subscription_addons[ $slug ]->cancel( $entry, $feed ) ) { |
236 | 236 | $subscription_addons[ $slug ]->cancel_subscription( $entry, $feed ); |
237 | - return \GFAPI::get_entry( $entry['id'] ); |
|
237 | + return \GFAPI::get_entry( $entry[ 'id' ] ); |
|
238 | 238 | } |
239 | 239 | } |
240 | 240 | } |