Skip to:
Content
Pages
Categories
Search
Top
Bottom

404 error on css and js files


  • lonelydime
    Participant

    @lonelydime

    Hello,

    I’m running a fresh install of WordPress from the bitnami helm chart using persistent storage on an NFS share. The path used by the containers is /bitnami/wordpress/wp-content/ to pull in plugins/etc. When I install bbPress, all of the css files and js files use the wrong path to include the assets.

    Here’s an example:

    <link rel='stylesheet' id='bbp-default-css' href='https://example.com/bitnami/wordpress/wp-content/plugins/bbpress/templates/default/css/bbpress.min.css'>
    
    <script type='text/javascript' src='https://example.com/bitnami/wordpress/wp-content/plugins/bbpress/templates/default/js/editor.min.js?ver=2.6.5'>

    I haven’t had any issues with other plugins thus far, but for some reason bbPress is wanting to use the full installation path instead of the web root. Is there a way of fixing this with some WP constant that I’m not setting? The installation of wordpress is in /opt/bitnami/wordpress and wp-content/ and wp-config.php are symlink’d to /bitnami/wordpress/wp-content and /bitnami/wordpress/wp-config.php.

    I have a temporary fix right now which will be wiped out when bbPress updates.

    File: wp-content/plugins/bbpress/includes/core/template-functions.php

    function bbp_enqueue_style( $handle = '', $file = '', $deps = array(), $ver = false, $media = 'all' ) {
            // Attempt to locate an enqueueable
            $located = bbp_locate_enqueueable( $file );
            //Ghetto fix
            $located = str_replace('/bitnami/wordpress', '', $located);
    function bbp_enqueue_script( $handle = '', $file = '', $deps = array(), $ver = false, $in_footer = false ) {
            // Attempt to locate an enqueueable
            $located = bbp_locate_enqueueable( $file );
            //Ghetto fix
            $located = str_replace('/bitnami/wordpress', '', $located);
Viewing 3 replies - 1 through 3 (of 3 total)

  • Robin W
    Moderator

    @robin-w

    you can dequeue from bbpress and then reload as you wish

    so for styles

    add_filter( 'bbp_default_styles', 'rew_dequeue_bbpress_css' ) ;
    
    function rew_dequeue_bbpress_css ($defaults ){
    unset ($defaults['bbp-default']) ;
    return $defaults ;
    }

    and re-enqueue it using your own function


    lonelydime
    Participant

    @lonelydime

    It’s been about 10 years since I’ve attempted anything WordPress or PHP for that matter, but while this works it feels like it’s going to break in an update.

    add_filter( 'bbp_default_styles', 'rew_dequeue_bbpress_css' );
    
    function rew_dequeue_bbpress_css ($defaults ){
    	fixed_bbp_enqueue_style("bbp-default", "css/bbpress.css", array(), bbp_get_version());
    	unset ($defaults['bbp-default']) ;
    	return $defaults ;
    }
    
    function fixed_bbp_enqueue_style( $handle = '', $file = '', $deps = array(), $ver = false, $media = 'all' ) {
            // Attempt to locate an enqueueable
            $located = bbp_locate_enqueueable( $file );
    	$located = str_replace('/bitnami/wordpress', '', $located);
    		
            // Enqueue if located
            if ( ! empty( $located ) ) {
    
                    // Make sure there is always a version
                    if ( empty( $ver ) ) {
                            $ver = bbp_get_version();
                    }
    
                    // Make path to file relative to site URL
                    $located = bbp_urlize_enqueueable( $located );
    
                    // Register the style
                    wp_register_style( $handle, $located, $deps, $ver, $media );
    
                    // Enqueue the style
                    wp_enqueue_style( $handle );
            }
    
            return $located;
    }

    From what I can tell your snippet does, it just clears out the default css object so the loop to bbp_enqueue_style skips including it and then I can inject my own function. The scripts function seem more complicated because there are many more includes than one file and they’re based on pages from what I can tell. Is what I’ve done what you were referring to?


    Robin W
    Moderator

    @robin-w

    yes that all looks good

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Skip to toolbar