$_SERVER['REQUEST_URI']
will not be empty in WordPress, because it is filled in wp_fix_server_vars()
(file wp-includes/load.php
).
This function is called in wp-settings.php
before any plugin is loaded. So you can use it.
But always escape the value. It is global and can be changed by any other code, so you cannot trust its value.
A different case is accessing the value per
filter_input(INPUT_SERVER, 'REQUEST_URI');
The write access by WordPress will not affect the value, because filter_input()
is always taking the original value. So while this is the more modern and clean approach, it might fail in some circumstances. See also this thread on Stack Overflow.
Related Posts:
- Configure Php server with ISAP
- How to get URL of current page displayed?
- What are PHP extensions and libraries WP needs and/or uses?
- Encode text string being appended as query to URL [closed]
- The correct method to pass query vars in AJAX using ajaxurl
- How to check if feed URL was requested?
- What is the best practice for escaping data URIs?
- urlencoding of the_title() doesn’t work?
- How do I get the author’s page url from their ID?
- Dynamic URL to reference custom PHP files
- Installing wp3.2.1 on IIS; getting empty sessions
- Your PHP installation appears to be missing the MySQL extension which is required by WordPress
- Concatenate site_url and string doesn’t work
- What’s the proper way to use wp_enqueue_script/style?
- Can I view my own wordpress php source code on my hosted web server?
- How to clear WordPress Cache from Server/FTP/Remote location
- Callback URL in WordPress
- Wrong links in WordPress?
- Newbie question: no index.php? in my plain wordpress permalink
- How is WordPress manipulating the posts like there are folders?
- How do I test PHP files in WordPress?
- PHP Code stuck in Cache [Memcached] [closed]
- wordpress upgrade has broken my permalinks
- WordPress Site front End and Back End Loading Slowly
- Extract subdomain and relative address from a url
- Remove query string specific key value
- Evaluations of two wordpress security plans against php code injection attack
- Echo URL of large version of Featured Image
- Why does WordPress remove my variables in the URL?
- WordPress Site Running Extremely Slow on Dedicated Server
- Where Does WordPress Make cURL Requests? How To Add cURL Option
- How to enable Zend Optimiser+ with Batcache
- Can you run WordPress on a MarketLive/Java EE server?
- Dynamic content based on a URL parameter
- Colon is Missing In My Website Url in WordPress
- How to change redirection route to a php page for making it only accessible by logged-in members?
- How to use $_GET function WordPress backend
- Incorrect MIME type for assets with Valet
- Extend PHP regex to cover “srcset” and “style” attributes
- My php header() function is not working [closed]
- Scrape external webpage for first image and add it to new post
- Create custom permalinks to show Custom Post Type’s relationship?
- wp-comments-post.php file returns a blank page
- Search Query: how to construct a search string from two select elements?
- Get URL Parameters from referer
- Need help enqueueing webfonts
- WP & Server Speed [Teacher Question]
- Why is $wp->request empty in WordPress 6.0?
- Get the URL of the page from which an ajax request has been launched within ajax callback
- How to check if the current page is at a specified path in the URL?
- 3 different times on my WordPress website
- Hardening uploads folder in IIS breaks images
- How to pass a PHP $_GET variable and fetch/output it?
- Post’s ID pattern?
- WordPress hit memory limit but not from the server
- After adding my website to a new server, I keep getting a unexpected end of file error, but the file is identitcal to it’s original source
- How can I find the cause of a 500 server error?
- HTTP ERROR 500 after installing child-theme [WordPress] [closed]
- WordPress mod_rewrite not working on php fpm
- I’m unable to call img path using single quotes in an array?
- Need to Modify a WordPress Shortcode with another wordpress shortcode
- change default RSS feed URL
- How do i add slugs to a URL, but still redirecting to the same page
- Problems clearing cache
- Can’t change website Title on wordpress
- Nginx WordPress and another Web app URL structure
- How to use title attributes in sidebar widget?
- how to get attached file url for current post?
- Call featured image url
- Creating customized php files in theme folder
- How do I include an external PHP file in a subdir WordPress install?
- How to add PHP pagination to wordpress
- Use an anchor link to open an iframe inside a WordPress page
- Adding custom url to readmore link using get_permalink()
- How to set base url for php widget
- How to prevent a function from running based on host (ie web vs local)?
- Comment_author_url doing nothing
- Modifying WP URL handing code?
- How to deal with a GET variable of ‘name’?
- WordPress permalink issue
- WordPress is removing query variables like page, p from the URL of a custom static page
- Workaround for og:image unsupported webp image type, Yoast SEO?
- How to define a rule in functions.php that ONLY disables the default wp functionality that undesirably changes ‘&’ to ‘#038;’?
- Reject all malicious URL requests functions.php
- How can I update WordPress plugins or WordPress itself in all server?
- Unable to display multiple parameters from url by javascript through shortcodes
- Allow two posts (from different categories) to have the same slug
- Prepend to all image URLs with PHP, only for mobile devices
- Get nice name of category from slug (remove dashes of category)
- how can i redirect dynamic URL in worpress base on ID in htaccess or wp-config or function.php
- current_time function incorrect in plugin and PHP, not in WordPress admin
- Add Link to PHP message
- (solved) WordPress Site not loading properly
- Current WordPress Page Title as Search Parameter into A Tag
- Rewrite rule not working, but only when parameter is text
- wp_signon works local, not on https
- Get WordPress username to customize url
- Upgrade to PHP7.3 and Changing Apache from Prefork to Event Breaks WordPress
- Suddenly got alert when trying to login to admin panel of wordpress
- Unable to update plug-ins – Undefined index a:1:{s:3:”ssl”;b:1;} in class-requests.php on line 213