Changeset 11662 for sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-bbp-term-subscription/inc/class-plugin.php
- Timestamp:
- 03/10/2022 01:58:09 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-bbp-term-subscription/inc/class-plugin.php
r11653 r11662 161 161 $term_id = $term->term_id; 162 162 $auth = 'nonce'; 163 $user_id = get_current_user_id();163 $user_id = isset( $_REQUEST['user_id'] ) ? $_REQUEST['user_id'] : get_current_user_id(); // Must pass nonce check below. 164 164 165 165 // If a user_id + token is provided, verify the request and maybe use the provided user_id. … … 191 191 esc_attr( $_SERVER['REQUEST_URI'] ), 192 192 esc_attr__( 'Yes, unsubscribe me', 'wporg-forums' ), 193 get_term_link( $term),194 sprintf(193 esc_url( get_term_link( $term ) ), 194 esc_attr( sprintf( 195 195 /* translators: 1: Plugin, Theme, or Tag name. */ 196 esc_attr__( 'No, take me to the %s forum.', 'wporg-forums' ),196 __( 'No, take me to the %s forum.', 'wporg-forums' ), 197 197 $term->name 198 ) 198 ) ) 199 199 ) 200 200 ); … … 209 209 210 210 // Check nonce. 211 } elseif ( ' nonce' === $auth && ! bbp_verify_nonce_request( 'toggle-term-subscription_' . $user_id . '_' . $term_id . '_' . $this->taxonomy ) ) {211 } elseif ( 'token' !== $auth && ! bbp_verify_nonce_request( 'toggle-term-subscription_' . $user_id . '_' . $term_id . '_' . $this->taxonomy ) ) { 212 212 bbp_add_error( 'wporg_bbp_subscribe_nonce', __( '<strong>ERROR</strong>: Are you sure you wanted to do that?', 'wporg-forums' ) ); 213 213 214 // Check user's ability to spectate .215 } elseif ( ! user_can( $user_id, 'spectate' ) ) {214 // Check user's ability to spectate if attempting to subscribe to a term. 215 } elseif ( ! user_can( $user_id, 'spectate' ) && 'wporg_bbp_subscribe_term' === $action ) { 216 216 bbp_add_error( 'wporg_bbp_subscribe_permissions', __( '<strong>ERROR</strong>: You don\'t have permission to do this!', 'wporg-forums' ) ); 217 217 } … … 625 625 echo '<p id="bbp-term-' . esc_attr( $this->taxonomy ) . '">' . "\n"; 626 626 foreach ( $terms as $term ) { 627 $unsub_url = self::get_subscription_url( $user_id, $term->term_id, $this->taxonomy ); 627 628 echo '<a href="' . esc_url( get_term_link( $term->term_id ) ) . '">' . esc_html( $term->name ) . '</a>'; 628 if ( get_current_user_id() == $user_id ) { 629 $url = self::get_subscription_url( $user_id, $term->term_id, $this->taxonomy ); 630 echo ' (<a href="' . esc_url( $url ) . '">' . esc_html( 'Unsubscribe', 'wporg-forums' ) . '</a>)'; 631 } 629 echo ' (<a href="' . esc_url( $unsub_url ) . '">' . esc_html( 'Unsubscribe', 'wporg-forums' ) . '</a>)'; 632 630 echo "</br>\n"; 633 631 } … … 794 792 ); 795 793 794 if ( $user_id != get_current_user_id() ) { 795 $url = add_query_arg( 'user_id', $user_id, $url ); 796 } 797 796 798 return esc_url( $url ); 797 799 }
Note: See TracChangeset
for help on using the changeset viewer.