It doesn’t recognize WP, because as far as PHP is concerned it’s not. It’s just a PHP file that happens to be in one of the folders related to WordPress.
You need to explicitly include WordPress core into it to have access to its functionality. However such custom handlers are notoriously fragile.
It would be much more reliable to create endpoint by means of WordPress functionality. See Rewrite API and around in Codex.
Related Posts:
- How to set and use global variables? Or why not to use them at all
- Contact form redirecting to page not found on send
- WordPress Theme variables scope
- Does an activated plugin automatically mean its methods are available to other WP functions?
- Where to get information about array fields in $_REQUEST?
- Custom plugin: Trying to show saved data on frontend
- How to call a function only once (global variable scope)
- How to export/import theme customizer settings?
- Create a global variable for use in all templates
- Site Title and Tagline in Theme Options Page
- reason of splitting theme files to multiple files
- Editor role cannot save custom theme options
- wp_customize_image_control default value
- Site Title and Tagline in Pagelines DMS Options Panel
- Filter the blog title displayed in the header
- How to override .htaccess with new rules without ftp or edit it manual
- How can one utilize a variable as a callback function name for add_settings_field
- JavaScript, best way to use data from the loop
- After upgrading to PHP 7.0 my contact form outputs error
- theme options echoing multiple times
- Theme Options: If There is No Input, Don’t Display?
- Displaying theme options in css
- max_input_vars: how many am I using?
- Putting PHP variables into javascript [duplicate]
- Choose To Display Post Views With An Options Panel
- Get Admin Email Address From External PHP page
- Set WordPress Default Template
- Call External Object in Class Function During Callback
- Set the checkbox as checked by default at options page
- Customizer – Prefix Class Extension
- Call global variable array() in woocommerce child/template
- Theme Options Page – User Updates Logo
- Selectbox in admin panel function linking to CSS
- Using if/else statements with output from theme options
- How to prevent XSS alter custom global javascript object & methods in WordPress
- WP Post-Thumbnail
- How to modify a global variable in a function and use it on another function?
- Contact form won’t submit
- Error: options page not found
- WordPress theme options error
- WordPress Options Page Theory Question
- Trying do build a contact form
- Warning: Illegal string offset on theme options page [closed]
- Changing the color scheme based on the url visited
- Why is an array created in a function hooked to customize register populated when customizer is loaded but not when the front-end is loaded?
- Link blogname and blogdescription to the Options Framework
- Where is this function’s callback getting its arguments from?
- How to add drag and drop functionalities to a div inside option panel
- What is the alternative code to if (isset ($_POST) && !empty ($_POST) to avoid warnings?
- Undefined index for default custom theme option
- PHP- Why is my contact form keep showing it is invalid? [closed]
- ‘global’ not working in wordpress?
- PHP if have image display image, if else text
- Deactivate a plugin on wp version
- Get value from db for custom contact form
- what does $options = get_option(‘test_theme’); do?
- Using theme options to change a border-radius value
- Contact form – problem with displaying message about sent mail
- Dynamically switch file in get_template_directory_uri() | Function [closed]
- Illegal string offset in PHP function in via Theme Customizer
- Is it secure to use SMTP password in .php file in WordPress website?
- global $product is empty string when passed into function
- Define global custom post
- Custom global variable not working in function
- Hide payment method based on user role AND minimum cart value
- Change CSS Variable value in Theme Customizer Live Preview
- How to find php variable of wordpress theme settings
- WordPress default contact form
- global $post inside plugin query messes up every new post page in wp-admin
- Use get_option with $emailTo on contact page
- wp_customize_image_control default value
- WordPress Setting page can not be saved by html radio
- WordPress $GLOBALS and PHP $GLOBALS
- key( $GLOBALS[‘wp_registered_sidebars’] ) is always showing the same value
- Not able to call class in NHP framework
- Category List in Theme Options Page
- custom contact form no longer working (because of 3.2?)
- How to change a specific character in a theme option value – replace a space with a plus sign
- Setting field not saving on front-end
- Select area and checkbox data is not saving?
- Options.php loop won’t show!
- Suppress errors when using global function
- Using global variables
- How can one use variables in a template or template part without polluting the global scope?
- Why is this specific API request failing when sending via wp_remote_post?
- Can’t send form data to wpdb when URL has query string
- XML WP_Query problem in PHP 8.0 and 8.1
- Dynamically added text at bottom of article – non searchable by PHP code
- $wpdb how to make a record lookup
- Add a custom user meta data on registration based on user email
- Error resetting database index using ALTER TABLE in $wpdb->query
- 500 Internal Server Error PHP 8.1 Array with wordpress
- why css file not link?how to create permalink?
- How to add different menu items on different menus?
- undefined variable in php
- functions.php doesn’t load all custom theme assets
- How to limit number of posts in the certain category and exclude the oldest post automatically
- Nav menù doesn’t display selected pages
- To perform the requested action, WordPress needs to access your web server
- Shortcode Displays 2 times