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