Skip to:
Content

bbPress.org

Changeset 6918


Ignore:
Timestamp:
11/05/2019 08:28:43 PM (2 weeks 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.

Location:
trunk/src/includes
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/admin/metaboxes.php

    r6914 r6918  
    732732
    733733/**
    734  * See who subscribed to a topic
     734 * See who is subscribed to a topic
    735735 *
    736736 * @since 2.6.0 bbPress (r6197)
     
    772772
    773773/**
    774  * See who subscribed to a forum
     774 * See who is subscribed to a forum
    775775 *
    776776 * @since 2.6.0 bbPress (r6197)
  • 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        }
  • 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.