WordPress.org

Making WordPress.org

Changeset 4610


Ignore:
Timestamp:
01/05/2017 11:16:27 PM (4 years ago)
Author:
coffee2code
Message:

Support Forums: For closed forums, adds a notice to privileged users indicating that the though the reply form is available, the forum is closed.

Fixes #2353.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-hooks.php

    r4330 r4610  
    2222        add_filter( 'embed_oembed_discover', '__return_false' );
    2323
     24        // Disable inline terms and mentions.
    2425        add_action( 'plugins_loaded', array( $this, 'disable_inline_terms' ) );
     26
     27        // Add notice to reply forms for privileged users in closed forums.
     28        add_action( 'bbp_template_notices', array( $this, 'closed_forum_notice_for_moderators' ), 1 );
    2529    }
    2630
     
    9195    }
    9296
     97    /**
     98     * For closed forums, adds a notice to privileged users indicating that
     99     * though the reply form is available, the forum is closed.
     100     *
     101     * Otherwise, unless the topic itself is closed, there is no indication that
     102     * the reply form is only available because of their privileged capabilities.
     103     */
     104    public function closed_forum_notice_for_moderators() {
     105        if (
     106            is_single()
     107            &&
     108            bbp_current_user_can_access_create_reply_form()
     109            &&
     110            bbp_is_forum_closed( bbp_get_topic_forum_id() )
     111            &&
     112            ! bbp_is_reply_edit()
     113        ) {
     114            $err_msg = sprintf( esc_html__(
     115                'The forum ‘%s’ is closed to new topics and replies, however your posting capabilities still allow you to do so.',
     116                'wporg-forums'),
     117                bbp_get_forum_title( bbp_get_topic_forum_id() )
     118            );
     119
     120            bbp_add_error( 'bbp_forum_is_closed', $err_msg, 'message' );
     121        }
     122    }
    93123
    94124}
Note: See TracChangeset for help on using the changeset viewer.