Skip to:
Content

bbPress.org

Changeset 6877


Ignore:
Timestamp:
12/04/2018 06:50:43 PM (3 years ago)
Author:
johnjamesjacoby
Message:

Engagements: demystify strategy sanitization.

This change ensures that invalid/unavailable strategies are never used, and also allows for custom strategies to exist (custom table, etc...) without requiring strategy registration.

See #3211.

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bbpress.php

    r6876 r6877  
    795795    public function setup_engagements() {
    796796
    797         // Default (always exists)
    798         $default    = "BBP_User_Engagements_Meta";
    799 
    800         // Configured (Might not exist)
     797        // Setup the class name
    801798        $strategy   = ucwords( bbp_engagements_strategy() );
    802799        $class_name = "BBP_User_Engagements_{$strategy}";
    803800
    804801        // Setup the engagements interface
    805         $this->engagements = class_exists( $class_name )
    806             ? new $class_name
    807             : new $default;
     802        $this->engagements = new $class_name;
    808803    }
    809804
  • trunk/src/includes/core/options.php

    r6876 r6877  
    732732    $integration = get_option( '_bbp_engagements_strategy', $default );
    733733
     734    // Check that class exists, or fallback
     735    $class_name  = 'BBP_User_Engagements_' . ucwords( $integration );
     736
    734737    // Fallback to 'meta' if invalid
    735     if ( ! in_array( $integration, array( 'meta', 'user', 'term' ), true ) ) {
     738    if ( ! class_exists( $class_name ) ) {
    736739        $integration = 'meta';
    737740    }
Note: See TracChangeset for help on using the changeset viewer.