plugins – bbPress admin_menu function

Question

I have installed bbPress plugin and I want to edit 1 line in the function

function admin_menu() {
        global $menu;
        global $wpdb;
        
        add_options_page(__('bbPress Moderation', self::TD), __('bbPress Moderation', self::TD), 
                                'manage_options', self::TD, array($this, 'options'));
        
        /*
         * Are there any pending items ?
         */
        $sql = "SELECT COUNT(*) FROM {$wpdb->posts} WHERE post_type="topic" AND post_status="pending"";
        $topic_count = $wpdb->get_var($sql);
        $sql = "SELECT COUNT(*) FROM {$wpdb->posts} WHERE post_type="reply" AND post_status="pending"";  
        //here I want to edit the $sql from the upper line with "SELECT COUNT(*) FROM ( " . get_need_verification_query() . ") t"
        $reply_count = $wpdb->get_var($sql);
        
        if ($reply_count || $topic_count) {
            /*
             * Have a quick butchers at the menu structure
             * looking for topics and replies and tack
             * on the pending bubble count. The 5th item seems
             * to be the class name
             * 
             * Bit hacky but seems to work 
             */
            foreach ($menu as $key=>$item) {
                if ($topic_count && isset($item[5]) && $item[5] == 'menu-posts-topic') {
                    $bubble="<span class="awaiting-mod count-".$topic_count.'"><span class="pending-count">'.number_format_i18n($topic_count) .'</span></span>';
                    $menu[$key][0] .= $bubble;
                }
                if ($reply_count && isset($item[5]) && $item[5] == 'menu-posts-reply') {
                    $bubble="<span class="awaiting-mod count-".$reply_count.'"><span class="pending-count">'.number_format_i18n($reply_count) .'</span></span>';
                    $menu[$key][0] .= $bubble;
                }
            }
        }
    }

This function is in wp-contentpluginsbbpressmoderationbbpressmoderation.php. How can I move this function in functions.php? Thank you!

0
Mike 6 months 2022-01-26T04:18:58-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse