Skip to:
Content

bbPress.org


Ignore:
Timestamp:
11/05/2019 08:28:43 PM (2 years ago)
Author:
johnjamesjacoby
Message:

Subscriptions: clean up code comparisons and documentation.

This commit adds some inline documentation to provide a bit more clarity around what subnscriptions checks and actions are being taken, and adds parenthesis to nested comparisons to improve code readability.

See #3235.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/topics/functions.php

    r6915 r6918  
    798798    // Handle Subscription Checkbox
    799799    if ( bbp_is_subscriptions_active() && ! empty( $author_id ) ) {
     800
     801        // Check if subscribed
    800802        $subscribed = bbp_is_user_subscribed( $author_id, $topic_id );
     803
     804        // Check for action
    801805        $subscheck  = ( ! empty( $_POST['bbp_topic_subscription'] ) && ( 'bbp_subscribe' === $_POST['bbp_topic_subscription'] ) )
    802806            ? true
     
    804808
    805809        // Subscribed and unsubscribing
    806         if ( true === $subscribed && false === $subscheck ) {
     810        if ( ( true === $subscribed ) && ( false === $subscheck ) ) {
    807811            bbp_remove_user_subscription( $author_id, $topic_id );
    808812
    809         // Subscribing
    810         } elseif ( false === $subscribed && true === $subscheck ) {
     813        // Not subscribed and subscribing
     814        } elseif ( ( false === $subscribed ) && ( true === $subscheck ) ) {
    811815            bbp_add_user_subscription( $author_id, $topic_id );
    812816        }
Note: See TracChangeset for help on using the changeset viewer.