Relative paths can be confusing in complex applications like WordPress. Plugin files themselves are included by the scripts that call them, and so relative locations within will be interpreted as those of the file that called them.
It’s always best practice to provide a full path using a magic constant such as __FILE__
or __DIR__
, as you’ve discovered.
Related Posts:
- What process do you use for WordPress development? [closed]
- How do I create a custom role capability?
- What is the advantage of using wp_mail?
- Where to put third party PHP library?
- Add a new tab to WordPress Plugin install Listing
- Export data as CSV in back end with proper HTTP headers
- How to integrate a PHP webmail script into the backend of WordPress?
- Calling the widget id of a mult-instance widget from inside the widget?
- How to Get a List of Sub Blogs without Using get_blog_list()?
- Do I need to call do_action in my plugin?
- Conditional check to see if a bootstrap.css is included in a theme
- WooCommerce get Shipping Class of product from either the product id or the order after order is completed
- Dequeue script, but still use wp_localize_script to pass vars
- Can I add pages to my custom menu via script?
- Replacing WordPress menu functionality with a plugin
- what is the best practice for including ‘wp-includes’ classes
- Programmatically Selecting Theme Based on URL
- Custom Plugin Database relations
- Save user-specific options in WordPress admin
- Why is print_r returning $classObj->userObj in several places on site
- Is it possible to load plugin from console with core ?
- use __($str) to translate strings (symfony/twig)
- Plugin development: is adding empty index.php files necessary?
- Plugin base URL
- Database for development
- Customize multisite site creation with user data
- Adding plugin settings link upon activation
- How to create multiple Gutenberg blocks in one plugin
- Proper way to run wp_query from inside a plugin
- Buddypress function and global $bp question
- Custom plugin: Loop through taxonomy types and update columns for all types?
- How to add setting section in custom post type [closed]
- Get Current Menu Location inside Nav_Walker
- Maximum lifetime for nonce
- How to Display my HTML form in my Custom Plugin?
- Where to add hooks in a class
- Insert terms for custom taxonomy on plugin activation, or each page load (init hook)
- Custom GET Parameters In Plugin’s Admin Page
- Adding rewrite rule dynamically
- Incorporate small angular feature in my wordpress site
- Bootstrap doesn’t work on admin menu page-How to override wp-admin style?
- Use just a shortcode from another page
- How can I avoid conflicts between plugin and theme?
- How to control an elements classes from multiple Gutenberg sidebar controls?
- WordPress class, using add_action to call member function does not work
- random code at the end of file after plugin upload
- How Can I add Fields in wp-option table?
- Where do I put my add_action(… and add_filter(… and do I need to remove them?
- $wpdb->prepare with LIKE and sprintf
- ajax recursive calls on wordpress returning answers outsite the function scope
- Jquery was not found on this server
- Is there an admin hook that will let me read GET variable before it’s too late to set the header Location
- WordPress plugin development OOP style
- How to create a digital product download link that can’t be used twice?
- How to create ShortCode
- shortcode tags not working in do_shortcode
- Working of foreach loop with array
- How to change a field in database through a submit button or Checkbox? [closed]
- Grandchildtheme (plugin) add header.php (not exist in child theme)
- Submit form to a different PHP file in the same plugin folder
- $wpdb->update Issue
- wp_insert_post generated mixed permalinks
- Adjust query on single
- Is there any way to pass messages from a script to a redirect target in a hidden fashion?
- What should I pass for $needed_dirs when calling _unzip_file_pclzip (aka PclZip)?
- Custom Path for a Plugin
- Import images remotly run through timeout error
- How to make every image title equal to alt text(wordpress/woocommerce)?
- Load specific page when a custom URL is hit
- Getting incorrect filepath inside custom block front-end output using @wordpress/create-block tutorial
- Trigger function on Remove block or add new block in Gutenberg JavaScript
- Trying to rename a file upload as the hash of file content on wordpress
- Getting products information, in woocommerce based on products ID
- How the add_action is included in the plugin development
- Fatal error: Uncaught Error: Using $this when not in object context
- How can I measure CPU and RAM used by my theme or plugin
- want to confirm popup with “Yes” and “No” button when user click on add to cart
- do I need to sanitize a shortcode’s function input?
- Email content as comment
- Warning: Illegal string offset – on homepage
- Modify search form with plugin
- Organising and completing posts (mark as read and hide)
- How to display properly exception or echo string after posting in plugin?
- When using an options array the Settings API isn’t creating the database record
- the correct way to use options from settings page [closed]
- On one of my sites a file is shown as 404 but the file IS there
- I want to add post meta for picture thum during submit for revision
- How to synchronize an e-commerce site and a pharmacy management software?
- woocommerce features to add product along with link
- Extend WP_List_Table class – Edit wp_usermeta – WPPB.me Boilerplate – Action error
- Build a dynamic block using the default attributes
- How to display .ptm file in my WP site without JAVA
- Show Admin Menu
- How to replace content of a block in and re-render on change?
- extending a core block doesn’t work inside the editor
- register_activation_hook doesn’t execute without add_action(‘init’,’some-function’)
- Getting similar posts by custom field value
- Does WP REST API cache internally executed (rest_do_request) requests?
- Trouble Importing whatsapp-web.js in a WordPress Plugin Development
- ‘useSate’ error when using React on the frontend in custom block plugin