Skip to:
Content

BuddyPress.org

Changeset 13291


Ignore:
Timestamp:
07/06/2022 09:35:00 AM (2 years ago)
Author:
imath
Message:

Check Akismet is active before trying to get the WP API key

Doing so avoids a database query if Akismet is not active.

Props shawfactor, oztaser.

Closes https://github.com/buddypress/buddypress/pull/18
Fixes #8478 (trunk)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-activity/classes/class-bp-activity-component.php

    r13144 r13291  
    6666
    6767        // Load Akismet support if Akismet is configured.
    68         $akismet_key = bp_get_option( 'wordpress_api_key' );
    69 
    70         /** This filter is documented in bp-activity/bp-activity-akismet.php */
    71         if ( defined( 'AKISMET_VERSION' ) && class_exists( 'Akismet' ) && ( ! empty( $akismet_key ) || defined( 'WPCOM_API_KEY' ) ) && apply_filters( 'bp_activity_use_akismet', bp_is_akismet_active() ) ) {
    72             $includes[] = 'akismet';
     68        if ( defined( 'AKISMET_VERSION' ) && class_exists( 'Akismet' ) ) {
     69            $akismet_key = bp_get_option( 'wordpress_api_key' );
     70
     71            /** This filter is documented in bp-activity/bp-activity-akismet.php */
     72            if ( ( ! empty( $akismet_key ) || defined( 'WPCOM_API_KEY' ) ) && apply_filters( 'bp_activity_use_akismet', bp_is_akismet_active() ) ) {
     73                $includes[] = 'akismet';
     74            }
    7375        }
    7476
Note: See TracChangeset for help on using the changeset viewer.