Skip to:
Content

bbPress.org


Ignore:
Timestamp:
11/05/2019 08:28:43 PM (4 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/replies/functions.php

    r6855 r6918  
    826826    // Handle Subscription Checkbox
    827827    if ( bbp_is_subscriptions_active() && ! empty( $author_id ) && ! empty( $topic_id ) ) {
     828
     829        // Check if subscribed
    828830        $subscribed = bbp_is_user_subscribed( $author_id, $topic_id );
    829         $subscheck  = ( ! empty( $_POST['bbp_topic_subscription'] ) && ( 'bbp_subscribe' === $_POST['bbp_topic_subscription'] ) ) ? true : false;
     831
     832        // Check for action
     833        $subscheck  = ( ! empty( $_POST['bbp_topic_subscription'] ) && ( 'bbp_subscribe' === $_POST['bbp_topic_subscription'] ) )
     834            ? true
     835            : false;
    830836
    831837        // Subscribed and unsubscribing
    832         if ( true === $subscribed && false === $subscheck ) {
     838        if ( ( true === $subscribed ) && ( false === $subscheck ) ) {
    833839            bbp_remove_user_subscription( $author_id, $topic_id );
    834840
    835         // Subscribing
    836         } elseif ( false === $subscribed && true === $subscheck ) {
     841        // Not subscribed and subscribing
     842        } elseif ( ( false === $subscribed ) && ( true === $subscheck ) ) {
    837843            bbp_add_user_subscription( $author_id, $topic_id );
    838844        }
Note: See TracChangeset for help on using the changeset viewer.