Making WordPress.org

Changeset 4969


Ignore:
Timestamp:
02/21/2017 11:26:35 AM (8 years ago)
Author:
SergeyBiryukov
Message:

Support Theme: Display Topic Admin sidebar section if the current user can stick a topic to a plugin or theme forum.

Fixes #2519.

Location:
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-support
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-support/functions.php

    r4910 r4969  
    300300add_filter( 'bbp_topic_admin_links', 'wporg_support_change_super_sticky_text' );
    301301
     302/**
     303 * Check if the current user can stick a topic to a plugin or theme forum.
     304 *
     305 * @param int $topic_id Topic ID.
     306 * @return bool True if the user can stick the topic, false otherwise.
     307 */
     308function wporg_support_current_user_can_stick( $topic_id ) {
     309    if ( ! class_exists( 'WordPressdotorg\Forums\Plugin' ) ) {
     310        return false;
     311    }
     312
     313    $user_can_stick  = false;
     314    $stickies        = null;
     315    $plugin_instance = WordPressdotorg\Forums\Plugin::get_instance();
     316
     317    if ( ! empty( $plugin_instance->plugins->stickies ) ) {
     318        $stickies = $plugin_instance->plugins->stickies;
     319    } elseif ( ! empty( $plugin_instance->themes->stickies ) ) {
     320        $stickies = $plugin_instance->themes->stickies;
     321    }
     322
     323    if ( $stickies ) {
     324        $user_can_stick = $stickies->user_can_stick( get_current_user_id(), $stickies->term->term_id, $topic_id );
     325    }
     326
     327    return $user_can_stick;
     328}
     329 
    302330/**
    303331 * Correct reply URLs for pending posts.
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-support/sidebar.php

    r4956 r4969  
    7474            </div-->
    7575
    76             <?php if ( current_user_can( 'moderate', bbp_get_topic_id() ) ) : ?>
     76            <?php if ( current_user_can( 'moderate', bbp_get_topic_id() ) || wporg_support_current_user_can_stick( bbp_get_topic_id() ) ) : ?>
    7777
    7878                <div>
Note: See TracChangeset for help on using the changeset viewer.