• Hello
    I used to merging plugins with themes which I designed via copying the plugin dir to theme dir and using include once.
    It improves the admin dashboard performance with not checking which plugins are activated or not.
    I use this code in functions.php to integrate (for example wpDiscuz plugin):

    <?php
    define( 'MY_WPDZ_PATH', get_stylesheet_directory() . '/includes/wpdiscuz/' );
    define( 'MY_WPDZ_URL', get_stylesheet_directory() . '/includes/wpdiscuz/' );
    include_once( MY_WPDZ_PATH . 'class.WpdiscuzCore.php' );
    ?>

    it works fine and I don’t need the wpDiscuz plugin in my plugin directory any more.
    it is now in my theme directory.
    but some times (and always in some other plugins) I get the errors like this:

    Failed to load plugin url: https://domain.com/wp-content/plugins/home/admin/domains/domain.com/public_html/wp-content/themes/theme-name/includes/wpdiscuz/assets/js/wpdiscuz-shortcode-tinymce.js
    Failed to load plugin url: https://domain.com/wp-content/plugins/home/admin/domains/domain.com/public_html/wp-content/themes/theme-name/includes/wpdiscuz/assets/js/wpdiscuz-shortcode-tinymce.js

    as you see it is repeated twice
    so what is the problem and how can I solve it?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    Before I tell you how to fix this, I need to stress this is a very short-sighted idea that will leave you at risk.

    Your plugins will never get updated.

    It improves the admin dashboard performance with not checking which plugins are activated or not.

    Yes, and by not checking for updates. So you just improved speed by maybe a second, while putting your personal risk astronomically high. Not worth it.

    Now. How come it’s broken?

    Look more closely. It’s not that it’s being repeated, it’s WHAT is being repeated.

    First you have this:

    https://domain.com/wp-content/plugins/

    and then this:

    home/admin/domains/domain.com/public_html/wp-content/themes/theme-name/includes/wpdiscuz/assets/js/wpdiscuz-shortcode-tinymce.js

    So you’re getting a repeat of wp-content and on, but before that you get your home server path.

    That is because you’re truing to use get_stylesheet_directory() which is the directory PATH (that /home… stuff). You need get_stylesheet_directory_uri()

    But… This is a terrible idea, don’t do it.

    Thread Starter SaeedTJ

    (@saeedtj)

    Thank you very much my friend.
    I agree and also I am aware of it.
    I change the code to this and the problem did not solve:

    <?php
    define( 'MY_WPDZ_PATH', get_stylesheet_directory() . '/includes/wpdiscuz/' );
    define( 'MY_WPDZ_URL', get_stylesheet_directory_uri() . '/includes/wpdiscuz/' );
    include_once( MY_WPDZ_PATH . 'class.WpdiscuzCore.php' );
    ?>

    but the question is that, where I should use MY_WPDZ_URL ?

    • This reply was modified 3 years, 1 month ago by SaeedTJ.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Problem with joining some plugins to themes with include_once’ is closed to new replies.