BBP_Default::localize_topic_script()

Load localizations for topic script

Description

These localizations require information that may not be loaded even by init.

Source

File: bp-forums/templates/default/bbpress-functions.php

590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
public function localize_topic_script() {
 
    // Single forum
    if ( bbp_is_single_forum() ) {
        wp_localize_script( 'bbpress-forum', 'bbpForumJS', array(
            'bbp_ajaxurl'        => bbp_get_ajax_url(),
            'generic_ajax_error' => __( 'Something went wrong. Refresh your browser and try again.', 'buddyboss' ),
            'is_user_logged_in'  => is_user_logged_in(),
            'subs_nonce'         => wp_create_nonce( 'toggle-subscription_' . get_the_ID() )
        ) );
 
    // Single topic
    } elseif ( bbp_is_single_topic() ) {
        wp_localize_script( 'bbpress-topic', 'bbpTopicJS', array(
            'bbp_ajaxurl'        => bbp_get_ajax_url(),
            'generic_ajax_error' => __( 'Something went wrong. Refresh your browser and try again.', 'buddyboss' ),
            'is_user_logged_in'  => is_user_logged_in(),
            'fav_nonce'          => wp_create_nonce( 'toggle-favorite_' .     get_the_ID() ),
            'subs_nonce'         => wp_create_nonce( 'toggle-subscription_' . get_the_ID() )
        ) );
    }
}

Changelog

Changelog
Version Description
bbPress (r3732) Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.