As the names suggest, plugin_dir_path()
will get the filesystem path, while plugin_dir_url
gets the URL.
A file path looks something like this /var/www/html/wp-content/plugins/my-plugin/
and can be used by PHP to find a file on the server.
A URL will look like https://www.example.com/wp-contents/plugins/my-plugin/
and is intended to be accessed over the web. If you attempt to require a file in PHP using a URL the server will need to request that file over the web, which is far far slower, and a security risk. This is why the ability to even do this is disabled by default in many setups. The error you’re seeing is telling you that this is disabled.
File paths should be used for accessing files on the server, while URLs should be used to find assets from the browser.
Related Posts:
- Making my plugin multi-site compatible
- dbDelta only creates the last table
- Checking if an attribute exists in a shortcode
- How to create a WordPress plugin for another wordpress plugin?
- use WordPress theme / plugin editor in my plugin
- What is the best way to output plugin result in certain url
- Where should my plugin POST to?
- Plugin Development: WordPress processes twice on post update. How to skip process on the first?
- WordPress widget / plugin….fields not appearing in my widget
- This doesnt work for Plugin get_template_directory_uri()
- What is $tab in `install_plugins_{$tab}` hook?
- Is it possible to upload a template file to a directory that can be used by all themes?
- WordPress hook for visiting a post
- Fatal error: Class not found in
- How do I use WordPress PHP functions in my Javascript code?
- Get all options saved by another plugin
- Creating a modal dialog without jQuery
- Language Translation is not working?
- What user roles should have wp_unique_post_slug_is_bad_flat_slug filter applied?
- Passing $this->get_field_name() to javascript
- add_action in functions.php, do_action in plugin?
- Read text defined under __()
- WordPress Plugin Page is Loading in Admin Content Container Instead of Separate Page
- Is Wrapping intval() Around esc_attr() Redundant for Escaping Input?
- Simple ajax call not working in wordpress plugin
- Plugin Options Not Saving to Database in WP 4.5
- How to save post change url youtube link?
- __callStatic method handler passed to add_action causes bug in PHP
- how to disable blockrenderAppender inside all Innerblocks?
- Redirection of users away from wp-admin (but not administrators)
- New databes tables with – WooCommerce – for developers [closed]
- Plugin-generated pages use Not Found or Pages Archive templates?
- Change commission_status paid when withdraw_status vendor is completed
- WordPress Plugin [closed]
- Proper way to replace the_content only for pages created by custom plugin
- Certain functions are undefined when called form mu-plugins
- Why is the ‘Gutenberg’ Plugin generating an ‘Inconsistent File Permissions’ error when other Plugins, with the same permissions, do not?
- Can plugin2 uninstall plugin1 at the very beginning of plugin2’s installation?
- WordPress front end AJAX. Return 0 :?
- plugin dev – minimum base css specificity?
- I changed font of wordpress dashboard but it is slow!
- Get Every Key & Value from Array then Display All in New Line
- WordPress 5.4 – How to prevent to enter only certain values in custom field
- Creating a functionality plugin to edit seriously simple podcasting
- Plugin temporary files and files to download via FTP
- DB Query not working in Plugin
- Make plugin php file called directly aware of WordPress?
- sending different email notification while registration based on user role
- How to add credit card validation check to wordpress [closed]
- Next Previous Post in wordpress with previous / next link with title?
- How to use existing hook in twentytwelve to all theme of wordpress?
- How to get a notification when the plugin is installed?
- WordPress Post HTML after Posting
- How to append new form elements in “Add New” form of Users in WordPress admin panel?
- Settings options not showing up on Sub Menu page in WordPress plugin
- How to Get Category Name When Export Products
- Remove List Bullets
- Custom Meta box change size
- Could add_query_arg() redirect user to external site?
- How to set plugin auto-update Enabled by default?
- Custom plugin activation error
- The Build menu theme is frozen with the wordpress theme
- How to capture hidden values with Gravity Forms
- How to translate to spanish wordpress hardcoded content/files?
- what functions to use to resize images and create DB metadata for them after/during upload?
- Multiple image selection custom widget
- How to Create a Learning Management Plugin in WordPress to Manage Courses [LMS]
- How to prevent redoing get_posts queries and make results available to other scripts?
- Prefix WordPress Taxonomy Tags With Hashtag Symbol Like Twitter
- Paid Membership Pro displaying a user name in PHP
- Make another copy of a plugin and install it
- Store admin page into variable
- Custom plugin giving: wp-admin/admin-ajax.php 400 (Bad Request)
- WP Plugin CSS not being applied to page
- Overwriting Plugin’s Ajax callback function from theme
- How can I get the Post ID and Post Type within a Must Use Plugin?
- Creating Nested custom fields
- Unable to sync woocommerce variations
- Can’t find variable is_single in my jQuery plugin
- WordPress Cron function is not working
- WP internationalization not loaded
- Plugin hook breaks new WP 4.0 media library grid view?
- How to get site homepage from plugin?
- Adding custom cron_schedule prior to wp_schedule_event
- Get page type to display content
- Widget redirecting to home page
- Capturing POST data
- Is an Office a custom post type [closed]
- How to add image for custom taxonomy
- I am using multi image metabox plugin but I did get how to display the images in templete?
- WordPress Hooks : Where to place callbacks that repetitively yield the same effect?
- wordpress Ajax success doesn’t return the value
- How to open author url linked to a new tab in settings page in the WordPress plugin list
- How can I properly sanitize the update_option in WordPress?
- Why is my menu page not being displayed?
- Unable to pass arguments from plugin form to filter hook using ajax, the data is transferring via ajax but unable to pass as arguments in filter hooks
- How to update changes to multiple sites at the same time
- I’m getting the following error: Fatal error: Uncaught Error: Call to undefined function oil_paint_regeneration() [closed]
- how to code activate/deactive button of custom plugin within backend?
- How to use `$order->get_discount_total()`, avoiding defoult WC decimal rounding?