Skip to:
Content

bbPress.org


Ignore:
Timestamp:
09/10/2011 10:27:19 PM (13 years ago)
Author:
johnjamesjacoby
Message:

API adjustments:

  • Refactor _status_ vars into callable functions.
  • Audit usage of $bbp global.
  • Perform get_class() checks on extensions to avoid errors if global $bbp is overloaded.
  • Bump DB version to 175.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/plugin/bbp-includes/bbp-extend-akismet.php

    r3498 r3505  
    7474     * @param string $post_data
    7575     *
    76      * @global bbPress $bbp
    77      *
    7876     * @uses get_userdata() To get the user data
    7977     * @uses bbp_filter_anonymous_user_data() To get anonymous user data
     
    8987     */
    9088    public function check_post( $post_data ) {
    91         global $bbp;
    9289
    9390        // Declare local variables
     
    9693
    9794        // Post is not published
    98         if ( 'publish' != $post_data['post_status'] )
     95        if ( bbp_get_public_status_id() != $post_data['post_status'] )
    9996            return $post_data;
    10097
     
    167164
    168165            // This is spam
    169             $post_data['post_status'] = $bbp->spam_status_id;
     166            $post_data['post_status'] = bbp_get_spam_status_id();
    170167
    171168            // We don't want your spam tags here
     
    192189     * @param int $post_id
    193190     *
    194      * @global bbPress $bbp
    195191     * @global WP_Query $wpdb
    196192     * @global string $akismet_api_host
     
    214210     */
    215211    public function submit_post( $post_id = 0 ) {
    216         global $bbp, $wpdb, $akismet_api_host, $akismet_api_port, $current_user, $current_site;
     212        global $wpdb, $akismet_api_host, $akismet_api_port, $current_user, $current_site;
    217213
    218214        // Innocent until proven guilty
     
    251247
    252248        // Bail if we're spamming, but the post_status isn't spam
    253         if ( ( 'spam' == $request_type ) && ( $bbp->spam_status_id != $post->post_status ) )
     249        if ( ( 'spam' == $request_type ) && ( bbp_get_spam_status_id() != $post->post_status ) )
    254250            return;
    255251
     
    404400     * @param object $post
    405401     *
    406      * @global bbPress $bbp
    407402     * @global object $this->last_post
    408403     *
     
    414409     */
    415410    public function update_post_meta( $post_id = 0, $post = false ) {
    416         global $bbp;
    417411
    418412        // Define local variable(s)
     
    452446
    453447                    // If post_status isn't the spam status, as expected, leave a note
    454                     if ( $post->post_status != $bbp->spam_status_id ) {
     448                    if ( $post->post_status != bbp_get_spam_status_id() ) {
    455449                        $this->update_post_history( $post_id, sprintf( __( 'Post status was changed to %s', 'bbpress' ), $post->post_status ), 'status-changed-' . $post->post_status );
    456450                    }
     
    464458
    465459                    // If post_status is the spam status, which isn't expected, leave a note
    466                     if ( $post->post_status == $bbp->spam_status_id ) {
     460                    if ( $post->post_status == bbp_get_spam_status_id() ) {
    467461
    468462                        // @todo Use wp_blacklist_check()
     
    554548     * @param int $reply_id
    555549     *
    556      * @global bbPress $bbp
    557      *
    558550     * @uses bbp_get_reply_id() To get the reply_id
    559551     * @uses bbp_get_topic_id() To get the topic_id
     
    564556     */
    565557    public function filter_post_terms( $terms = '', $topic_id = 0, $reply_id = 0 ) {
    566         global $bbp;
    567558
    568559        // Validate the reply_id and topic_id
     
    696687    if ( !defined( 'AKISMET_VERSION' ) ) return;
    697688
     689    // Bail if bbPress is not loaded
     690    if ( 'bbPress' !== get_class( $bbp ) ) return;
     691
    698692    // Instantiate Akismet for bbPress
    699693    $bbp->extend->akismet = new BBP_Akismet();
Note: See TracChangeset for help on using the changeset viewer.