WordPress.org

Forums

[resolved] [Shortcodes in Own Plugin] - Loading CSS and JS (2 posts)

  1. Luigino
    Member
    Posted 3 years ago #

    Hello everyone!!!!

    I implemented my own plugin where I added also a shortcode's function to load some content in a page from the plugin.
    I have this little issue:

    <script src="../wp-content/plugins/myownplugin/js/myscript.js" type="text/javascript"></script>

    I can see it isn't really a good solution since plugin's name could change so I tried with echo plugins_url('js/myscript'); but while debugging with Firebug I figured it didn't return the REAL path of the script but the PAGE url + /%3C?php%20echo%20plugins_url(%27js/myscript.js%27,%20dirname(%20__FILE__)%20);%20?%3E"...

    How I can get this plugins_url work?..

    thanks a lot in advance to everyone

    Ciao,
    Luigi

  2. Luigino
    Member
    Posted 3 years ago #

    Nevermind... solved by myself:

    practically BEFORE to load the contents from html/php file I call plugins_url() so I can get correctly the whole url, then I replaced with str_replace() a constant in the content with the plugin url so I can feel ok.

    Thanks again to all anyway
    Ciao,
    Luigi

Topic Closed

This topic has been closed to new replies.

About this Topic