Skip to:
Content

bbPress.org


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

Engagements: next pass at back-compat for pre-2.6 user strategy.

  • Renames BBP_User_Engagements_Back_Compat to BBP_User_Engagements_User so the approach is more clear.
  • Fill in get_query() method, left todo from r6844.
  • Move active strategy into a preloaded option, default to meta
  • Set active strategy to user on failed auto-upgrade to 2.6 to maintain backwards compatibility
  • Introduces sub-actions to assist with abstracting the engagement strategy setup

Fixes #3211.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/core/options.php

    r6870 r6876  
    6565            '_bbp_theme_package_id'       => 'default', // The ID for the current theme package
    6666            '_bbp_settings_integration'   => 'basic',   // How to integrate into wp-admin
     67            '_bbp_engagements_strategy'   => 'meta',    // How to interact with engagements
    6768
    6869            /** Per Page **********************************************************/
     
    690691 *
    691692 * @param bool $default Optional. Default value false
    692  * @return bool To deeply integrate settings, or not
     693 * @return string How to integrate settings
    693694 */
    694695function bbp_settings_integration( $default = 'basic' ) {
     
    704705    }
    705706
    706     // Fallback to 'none' if invalid
     707    // Fallback to 'basic' if invalid
    707708    if ( ! in_array( $integration, array( 'basic', 'deep', 'compact' ), true ) ) {
    708709        $integration = 'basic';
     
    711712    // Filter & return
    712713    return apply_filters( 'bbp_settings_integration', $integration, $default );
     714}
     715
     716/**
     717 * How to interact with engagements
     718 *
     719 * There are 3 possible strategies:
     720 * - 'meta' 2.6 and higher. Uses multiple postmeta keys.
     721 * - 'user' Pre-2.6. Uses comma-separated string of IDs in usermeta.
     722 * - 'term' Alternate. Uses taxonomy term relationships.
     723 *
     724 * @since 2.6.0 bbPress (r6875)
     725 *
     726 * @param bool $default Optional. Default value false
     727 * @return string How to interact with engagements
     728 */
     729function bbp_engagements_strategy( $default = 'meta' ) {
     730
     731    // Get the option value
     732    $integration = get_option( '_bbp_engagements_strategy', $default );
     733
     734    // Fallback to 'meta' if invalid
     735    if ( ! in_array( $integration, array( 'meta', 'user', 'term' ), true ) ) {
     736        $integration = 'meta';
     737    }
     738
     739    // Filter & return
     740    return apply_filters( 'bbp_engagements_strategy', $integration, $default );
    713741}
    714742
Note: See TracChangeset for help on using the changeset viewer.