AFAIR, if you use file_exists
with relative paths, you have to be very careful, because the path is relative to script that is called by request and not relative to file that contains that check…
So if it’s a plugin and the request goes to main WP index.php, then you’ll be looking for a file in WP root.
But if the same code will be run by AJAX call (wp-admin/admin-ajax.php) it will search for that file in wp-admin directory.
That’s why you should use ABSPATH
or use __DIR__
(to make the path relative to file in which you check the file existence).
Related Posts:
- Setting $_SERVER[‘HTTPS’]=’on’ prevents access to wp-admin
- Enforcing password complexity
- Check if a menu is empty?
- Adding a search form inside a div
- How To Make Connection To WordPress Data Base In A Plugin?
- WordPress Template Engine?
- Dynamically change feature image in customiser
- Walker class: Problems with understanding how walk() method can be called without error
- How to get the post count for the last x days filtering by categories
- How to create shortcodes that pull custom field data from general settings
- Where exactly do I write define( ‘WP_DEBUG’, true ) in wp-config file
- Getting a fatal error while updating
- How to display related posts from parent category
- Making a follow button, Ajax not talking to php
- get understrap pagination to work with custom query
- Replace existing content from specific WooCommerce admin orders list column
- Using is_page() in functions.php not working at all
- #1062 – Duplicate entry ‘1’ for key ‘PRIMARY’
- Warning when using
- How to break down importing of feeds
- How to override wp-admin styling
- WordPress shows registration link for non logged users
- How to get woocommerce cart content without an action?
- How to call function at the bottom of post using plugin?
- How can I resolve the php notice “Constant EMPTY_TRASH_DAYS already defined”
- Use wp_get_recent_posts with search term
- multiple if statements [closed]
- Choose To Display Post Views With An Options Panel
- Prevent Data Resubmission On Page refresh
- Bridging TinyMCE js and WordPress PHP?
- Echo URL of large version of Featured Image
- Set a condition based on WooCommerce checkout city field while placing order
- Remove price from Woocommerce variable product dropdown menu
- Getting trackpacks/pingbacks for a post via wordpress?
- Loop through categories and display posts title under each dropdown
- How to hide products that do not have an image from a slider carousel for an ecommerce webpage?
- How to change redirection route to a php page for making it only accessible by logged-in members?
- how to query a post based on previous page post ID
- How to use $_GET function WordPress backend
- How to create a php variable using WordPress the_title() function
- How to set variable, pass it to a partial file and remove it after?
- Adding logo to WordPress header
- Is the wp_enqueue method efficient?
- Change page title from page using php via php executed from page/post itself
- How can I import an excel column into wordpress database?
- Making an AJAX call to refresh a table
- How does WP work in conjunction with a web server?
- add_filter only for front office
- How to array only one key from another array
- WordPress and MySQL: trying to print data using PHP from user_meta custom field data
- Form Submission Not Working In Custom Theme
- Convert a string into a decimal number for use in query
- How to get specific attribute from DB
- Show metabox only for homepage
- Custom $_SESSION expires too early
- Concatenate Custom Field Value & HTML Value
- How do I properly code my footer? See example
- Use of IF statement in Header file
- Kohana Frontend, WordPress Backend
- apply_filters with several different values?
- Advanced Query posts
- Triggering a timewall after X days
- How do you create a custom category widget that you can style?
- Bootstrap 4 Carosuel with ACF Repeater field
- How to preload header logo image in WordPress? like what’s the code and where do I put it?
- echo cutom css code to WordPress page template file ? is this safe?
- I am facing this error Your PHP installation appears to be missing the MySQL extension which is required by WordPress
- PHP `iconv` not working inside a WordPress site
- How to make a “page-option” in WordPress
- Replacing entire tag with shortcode – JavaScript [duplicate]
- How do I visualize the author’s post from the front end?
- How to add a full working piece of website already coded, to a large scale Website design project?
- How do if all posts has this category ID then do this
- Query to show average # of months all accounts with specific role have been active
- Send email to users when they get new followers
- Conditionally change WordPress core language
- Fatal error when using array_diff() function inside of wp_update_nav_menu hook?
- Use PHP to inject HTML into before page renders?
- Query doesn’t display text data with apostrophes
- WooCommerce Custom Tab with ACF Repeater Field
- My WP Website Shows HTTP ERROR 500
- add menu page in loop menu order
- CSS loading as empty file in Custom Theme
- Custom fields changes the formatting of metabox input
- Display product attributes for current product
- soap request in wordpress for a fedex pickup request [closed]
- Dynamically Create Posts Via XML File
- pages disable after wordpress update
- How to only fetch certain Tag ID’s
- Create server side text from wordpress page
- Make first child link default instead of its parent
- How to set a cookie based on a page Get variable?
- Editing the contents of just one div on a page from wordpress
- How to change the menu color
- Display latest 5 posts on homepage
- I want Page titles and excerpts to show up on home.php in certain order
- How do I reformat this to add php inside php?
- Advanced custom fields Repeater conditional statement not working [closed]
- how to display tables via ajax
- How to get posts by a certain author in inner loop using outer loop variable or post title WordPress