WordPress.org

Ready to get started?Download WordPress

Forums

Better WordPress Minify
[resolved] Not working for Buddypress components (11 posts)

  1. carlla
    Member
    Posted 3 months ago #

    Hi,

    First would like to thanks for the great plugin! =)

    For urls like home, blog, 404 and static pages, the plugin works well.

    I use Buddypress and I wrote some custom plugins to extend Buddypress functionalities. Buddypress components has its own urls, which are neither page or post. For those, no css or js file is been combined nor minified.

    These plugins are using wp_enqueue_style and wp_enqueue_script as well.

    What could be done to fix it?

    https://wordpress.org/plugins/bwp-minify/

  2. Khang Minh
    Member
    Plugin Author

    Posted 3 months ago #

    Are your custom plugins' CSS/JS files not minified or both yours and BuddyPress's default CSS/JS files?

    Are you plugins available somewhere do I can take a look?

  3. carlla
    Member
    Posted 3 months ago #

    Thanks for quick reply!

    Both! My custom plugins' CSS/JS and the Buddypress's default CSS/JS.

    Only Messages and XProfile components are active. Groups and Activity components aren't.

    My custom component has a root directory (Sorry, but it is not available anywhere to download), and no css/js files is been minified on neither /my-component nor /my-component/component-item

    The plugins are on a wordpress multisite with subdirectory setup. Could this be a problem? I have tried to activate the bwp-minify on the multisite's painel and on a single site's painel but it did no difference.

    The user profile page is using my custom css and js files, not Buddypress's default CSS/JS files. But since this are using wp_enqueue_style() and wp_enqueue_script() it shouldn't be a problem, should?

  4. carlla
    Member
    Posted 3 months ago #

    I'm using the beta version 1.3.0rc1 of btw-minify. The current version 1.2.3 didn't work.

  5. carlla
    Member
    Posted 3 months ago #

    I guess that I found out the problem.

    bwp-minify is using the "template_redirect" action to attach its actions and filters.

    Buddypress use the same action to attach "bp_screens" hook, which usually load a template and then exits. So functions that are attached to 'template_redirect' with higher priority then "bp_screens" will never be called, as well the "add_conditional_hooks" method won't be called

    Just change the hook priority to 1 to be sure the bwp-minify actions will be attached before bp_screens hook finds a template. This change worked for me.

    bwp-minify/includes/class-bwp-minify.php #822
    add_action('template_redirect', array($this, 'add_conditional_hooks'), 1);

  6. Khang Minh
    Member
    Plugin Author

    Posted 3 months ago #

    Ah, good catch. I will add this patch to the plugin after some more testings.

    Thanks Carlia.

  7. Khang Minh
    Member
    Plugin Author

    Posted 3 months ago #

    Hi Carlia, can you help me with one thing?

    I would like to know which page (e.g. members/username/mentions) doesn't have its css/js files combined when:
    1. your custom plugins are active
    2. your custom plugins are inactive

    Although setting the priority to 1 fixes the issue, something is still not right.

  8. carlla
    Member
    Posted 2 months ago #

    Sorry, I did understand what you want to do. What problem did you have?

  9. Khang Minh
    Member
    Plugin Author

    Posted 2 months ago #

    Even when I'm not setting priority to 1 as suggested, I still get BuddyPress's JS and CSS files (the default ones) combined and minified correctly, so something is still not right if default BuddyPress's files are not minified for you (you said that both default ones and custom ones are not minified).

  10. carlla
    Member
    Posted 2 months ago #

    As I mention before, only Messages and Xprofile components are active right now. Can't say if this occurs to Activity, Groups or other Buddypress component. My current theme has no template to test it. I'll try to activate buddypress default theme to test it.

    About the custom components, I usually set up custom pages using the bp_screen hook to test the current permalink and then call bp_core_load_template() to load the template. So that makes sense for me that setting priority to 1 fixes the problem.

    Some informations that could do difference:
    - it is a wp multisite on a subdirectory install
    - root profiles is enabled (BP_ENABLE_ROOT_PROFILES)
    - buddypress multiblog support is enabled (BP_ENABLE_MULTIBLOG)
    - wordpress has it own directory
    - wp-content was renamed and is out of wordpress directory
    - wp-content/plugins was renamed

    Could this be useful? If I discover anything else I'll let you know.

  11. Khang Minh
    Member
    Plugin Author

    Posted 2 months ago #

    That's pretty detailed carlia, thank you very much.

Reply

You must log in to post.

About this Plugin

About this Topic