Assuming your resource is included in your Plugin:
plugins_url()
is the URL to\wp-content\plugins\
(Codex ref)
So if you have a .js file in \wp-content\plugins\plugin-slug\file.js
:
<?php echo plugins_url() . '\plugin-slug\file.js'; ?>
BUT WAIT!!
If your purpose is actually to load a javascript file, you actually want to enqueue that file, using wp_enqueue_script()
, hooked into the wp_enqueue_scripts
hook.
And wp_enqueue_script()
uses the filepath rather than the URL, so you could use dirname(___FILE___)
if that’ what you’re comfortable with.
Related Posts:
- Adding Custom Text Patterns in the WP 4.5 Visual Editor
- How can the tinyMCE dom be manipulated (offical API does not seem to work)?
- Bridge WordPress Media API with custom tinyMCE plugin [closed]
- WP Editor Issue in Backend
- Asynchronously render shortcodes in TinyMCE visual editor
- Add a select option of shortcodes like dropdown in tinymce
- Translate MCE button text/tooltip in custom plugin
- How to close tinymce inline popup
- Add Button to TinyMCE Custom Menu
- dbDelta not creating tables
- Default table collation on plugin activation?
- How to implement color picker from wordpress in my plugin?
- Nonces can be reused multiple times? Bug / Security issue?
- How to auto-upgrade my plugin?
- Category listing with thumbnail and description on home page
- How to Add a .js file Only in one specific Page Dynamically to Head
- Missing “category_children” option when dynamically creating categories via a plugin
- Developing a plug-in to charge for
- What is the Difference between directly call a function and call a function using add_action?
- What is better way to use Bootstrap inside admin panel?
- Looking for callback function after Gutenberg is rendered?
- Updating my plugin without releasing a new version
- How to assign a WP 3.0 custom nav menu to a theme’s navigation menu location via script?
- is_page() function doesnt working
- Order properties should not be accessed directly
- How to avoid loading same script twice?
- Is there any way to check for user login and send him to login?
- Can I individually style items in the backend widget list?
- Why is my javascript not invoked in my hooks except wp_head?
- How to Create database table when Plugin installed/activated, and delete database when Plugin deleted
- Where to store the name of a custom table?
- Backbone event attachment:compat:ready can’t hook
- Add a class to a dynamic sidebar’s wrapper
- Upgrade private plugin without deleting files?
- Issue regarding $wpdb->prepare()
- Checkbox Undefined index error in Plugin
- Is there some way to provide the user a list of existing content in a CPT
- Change the look and feel of admin pages
- Issue with querying
- how to search users by ajax live search
- Generate JSON files for language translation from po file without wp-cli i18n make-json
- Is this best practice for Dynamically adding items to WordPress menus?
- There is a problem in the gutenberg block I developed. Problem is with withInstanceId
- Detect front-end pages only in init hook
- Display WordPress the_content() via data attributes
- Constraints in custom tables for plugin development – Yes or No?
- best way to make a WordPresss multisite that is secure but at the same time supporting my plugin development efforts
- How to change title tag at page after loaded post?
- Run Shortcode of post’s custom field in functions.php / Plugin
- WordPress custom taxonomy check box to dropdown
- Creating Admin Plugin – Content of a page is displayed at global scope as well
- load_plugin_textdomain doestn’t work with add_action plugins_loaded
- How to remove plugin-specific custom taxonomy terms when plugin is uninstalled?
- Fatal error: Call to a member function get_page_permastruct() on a non-object
- wp_get_post_terms Order by not working
- Naming conventions when using (PHP5) namespaces?
- Which is the better way to store images for the plugin?
- Readme.txt seems to be cached but not the version
- Issue on Checkbox with Custom Option Page
- change add to cart button link [closed]
- Encoding Method for URLs?
- Store custom meta box data as serialized array
- configuration of .htaccess for add_rewrite_rule to make sense
- How to get post meta in functions?
- AJAX request not routing through proxy
- Plugin access to average users not only admin
- Rewrite not working since upgrade to 5.9
- Why won’t this submenu page show? – My First WordPress Plugin
- How to display plugin with javascript using markup of the theme?
- Can display plugin without shortcode?
- Multiple dynamic Tax Query – pass taxonomy argument from array
- ACF Field value in wordpress login message filter
- ajax stopped working when not logged in wordpress
- Hook for validating and rejecting frontend image upload
- Overriding the template files using a plugin for all themes
- Plugin removes itself if mistake made during edit
- Using meta_key & meta_value in add_rewrite_rule
- Can’t create a blank template
- Custom Registration Form and Passwords
- Determine if the current page, is being edited
- List Table action argument not cleared
- WP Ajax on page load not working on bluehost but was working on Godaddy
- Fullwidth slider using background image Flexslider WordPress
- Return value of $wpdb->update() query in plugin is wrong
- Is there a way to tell if a shorcode’s handler is being run before or after the content formatting filter?
- Plugin files not updated (cache cleared)
- How to limit the number of posts a user can view based on status
- How to create an embedded code for wordpress shortcode?
- How to add additional field in a table row after creating a table?
- WordPress plugin tables become corrupt
- How to call a new php page inside a plugin page?
- How can i call from custom fields to the category editor?
- How do you filter get_media_items by mime type in a custom media upload tab?
- Is it possible to convert various image types from remote URLs to WebP and then serve them immediately?
- If I want to create new taxonomies (e.g. Project / Documents / Etc…) is it better to create them in the theme’s functions.php or within a plugin? [duplicate]
- Is there any other ways to replicating changes on live from staging without pushing from git
- upload image to wordpress media library failed for custom post type
- Fetch Custom Woocomerce filed data and check the data avialble in Wp-user table as nicname or username using function.php
- How to get locale within WP REST Request?
- How to add extra EXIF data when images are uploaded?