@@ -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 | } |
@@ -167,21 +167,21 @@ discard block |
||
167 | 167 | |
168 | 168 | // @todo Move to init, or AJAXify, but make sure that the entry is in the View before allowing |
169 | 169 | if ( $entry = $this->maybe_unsubscribe( $entry ) ) { |
170 | - if ( $entry['payment_status'] !== $status ) { |
|
170 | + if ( $entry[ 'payment_status' ] !== $status ) { |
|
171 | 171 | // @todo Probably __( 'Unsubscribed', 'gravityview' ); |
172 | - return $entry['payment_status']; |
|
172 | + return $entry[ 'payment_status' ]; |
|
173 | 173 | } |
174 | 174 | } |
175 | 175 | |
176 | - if ( strtolower( $entry['payment_status'] ) !== 'active' ) { |
|
176 | + if ( strtolower( $entry[ 'payment_status' ] ) !== 'active' ) { |
|
177 | 177 | return $output; |
178 | 178 | } |
179 | 179 | |
180 | 180 | global $wp; |
181 | 181 | $current_url = add_query_arg( $wp->query_string, '', home_url( $wp->request ) ); |
182 | 182 | |
183 | - $link = add_query_arg( 'unsubscribe', wp_create_nonce( 'unsubscribe_' . $entry['id'] ), $current_url ); |
|
184 | - $link = add_query_arg( 'uid', urlencode( $entry['id'] ), $link ); |
|
183 | + $link = add_query_arg( 'unsubscribe', wp_create_nonce( 'unsubscribe_' . $entry[ 'id' ] ), $current_url ); |
|
184 | + $link = add_query_arg( 'uid', urlencode( $entry[ 'id' ] ), $link ); |
|
185 | 185 | |
186 | 186 | return sprintf( '<a href="%s">%s</a>', $link, __( 'Unsubscribe', 'gravityview' ) ); |
187 | 187 | } |
@@ -199,11 +199,11 @@ discard block |
||
199 | 199 | * @return \GV\Entry $entry The entry |
200 | 200 | */ |
201 | 201 | private function maybe_unsubscribe( $entry ) { |
202 | - if ( ! wp_verify_nonce( \GV\Utils::_REQUEST( 'unsubscribe' ), 'unsubscribe_' . $entry['id'] ) ) { |
|
202 | + if ( ! wp_verify_nonce( \GV\Utils::_REQUEST( 'unsubscribe' ), 'unsubscribe_' . $entry[ 'id' ] ) ) { |
|
203 | 203 | return $entry; |
204 | 204 | } |
205 | 205 | |
206 | - if ( ( ! $uid = \GV\Utils::_REQUEST( 'uid' ) ) || ! is_numeric( $uid ) || ( intval( $uid ) !== intval( $entry['id'] ) ) ) { |
|
206 | + if ( ( ! $uid = \GV\Utils::_REQUEST( 'uid' ) ) || ! is_numeric( $uid ) || ( intval( $uid ) !== intval( $entry[ 'id' ] ) ) ) { |
|
207 | 207 | return $entry; |
208 | 208 | } |
209 | 209 | |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | if ( ( $feed = $subscription_addons[ $slug ]->get_feed( $feed_id ) ) && \GV\Utils::get( $feed, 'meta/transactionType' ) === 'subscription' ) { |
232 | 232 | if ( $subscription_addons[ $slug ]->cancel( $entry, $feed ) ) { |
233 | 233 | $subscription_addons[ $slug ]->cancel_subscription( $entry, $feed ); |
234 | - return \GFAPI::get_entry( $entry['id'] ); |
|
234 | + return \GFAPI::get_entry( $entry[ 'id' ] ); |
|
235 | 235 | } |
236 | 236 | } |
237 | 237 | } |