Ready to get started?Download WordPress


javascript plugin location (3 posts)

  1. Versipellis
    Posted 2 years ago #

    I've been developing plugins and happily been using:
    $pluginurl = WP_PLUGIN_URL.'/'.str_replace(basename( __FILE__),"",plugin_basename(__FILE__));

    to get to my plugin location.

    However what I am doing is using javascript to link to a location however, right now to do that I need to put in the full absolute url, is there a way to get the plugin url with javascript?



  2. David Gwyer
    Posted 2 years ago #

    You can still get your Plugin location with PHP, and then pass it to your JavaScript using localization:


  3. Versipellis
    Posted 2 years ago #

    Im not really very good at getting my js to work with php - the JS in question is in an external javascript file not in a php one

    As some people say to use a .php and then a javascript header but I can't get this to work at all
    header("content-type: application/x-javascript");

    but my javascript then doesnt work at all.

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.