You are execpeting a WP Error object if the URL has a non-valid protocol but esc_url_raw
returns an empty string in that case (see codex), not a WP Error object. So, is_wp_error( $escaped )
never verifies. Also, you are checking an undefined $escaped
variable (note that the value of esc_url_raw
is stored in $sanitized
variable):
function scientifik_sanitize_url($url){
$prots = array('http', 'https');
$item = $url;
$escaped = esc_url_raw( $item, $prots );
if ( empty( $escaped ) ) {
return 'funny';
die();
}
return $item;
};
Related Posts:
- Sanitizing URL in a WordPress plugin
- Can non-latin characters appear in slugs?
- Difference between esc_url() and esc_url_raw()
- Pulling a parameter out of the URL of a WP link without “?” or being sent to a different page
- Run WordPress frontend and backend in different domains
- How to set global variable in functions.php
- Can’t login after my site was moved to a new server
- Adding a hook to ‘parse_request’ so that siteurl/pagename/xyz ignores “xyz”
- How to have numeric URLs in Posts and Pages
- Why WordPress automatically removes http from the url of my website’s sub domain?
- WordPress Move to SSL How to Update Media Assets to HTTPS?
- Moving wp-content outside of web root?
- Generate one time URL
- In Settings>>General I am missing some fields
- Adding target and _blank as it’s value to the allowedtags
- permalink for category pages and posts
- Get url from file uploaded in Media Library
- Allow UTF-8 characters in the user slug part of URL
- WordPress converting ../url to http://../url
- home_url(); showing current page instead of site address
- URL parsing – what is it?
- Components used in Themes and Plugins: How to get file URL?
- Can URL remain the same if migrating from Drupal?
- Site URL always in front of other URLs
- How to add domain security certification, in WordPress website?
- Imported thumbnails have incorrect URL
- Is it necessary to check for `content-type` in headers?
- How to allow — in category name
- Request parameters in $_GET do not match URL called
- WordPress custom search url
- The requested URL was not found only on localhost
- Allow Chinese character on post URL slug
- How can I change a media attachment URL/slug, so that I can use that slug for a page?
- Problem with utf8 link
- remove query string from homepage url
- Twitter shortlink 404 not found [closed]
- Remove Trailing Slash from Category Base and Tag Base
- Custom url in wordpress
- WP URL /icons returns 403 forbidden error
- Get root folder without domain
- wordpress.com website url structure [closed]
- HTTP 403 Error when passing parameters to URL
- How to remove my website link when adding a link?
- Misentered the site address url. How to recover? [closed]
- How to call for bloginfo inside function in functions.php?
- Moving a WordPress site – Installation issue
- What can I replace ‘.get_bloginfo(‘url’).’ with to return the current URL rather than the home address?
- What is the best way to figure out which template file that a “pretty permalink” is using?
- How to see an item in the admin from its URL? (not sure if it’s a page, post, or what)
- Can’t change the wordpress site url
- Wrapping add_query_arg with esc_url not working
- Relative URLs within site
- Using WordPress for a site’s static marketing pages and blog at different URLs
- What is the best way to revert to www version of domain name?
- Need to check if user is on a particular page
- How to set path to the image instead of alt in media.php?
- Go back to my home page
- Changed domain name and all the 301 redirects work except the ones for the thumbnail image which return 403 Forbidden error
- Changing url of author page
- How to get previous and Next Post Url in the_post_navigation
- Thousands of unwanted URLs/pages with “0” in slug created
- How to remove % character from url
- Encode URL for WhatsApp “click to chat” without loosing accented characters
- append currency to URL
- Create 600 links to separate files on google drive
- Locked myself out of WordPress because I changed my URL and computer shut down
- Cant access my wordpress.org locally
- I changed the URL [closed]
- WP site homepage displays url link at beginning of each featured post
- how to set url in admin option page
- Unable to login after changing WordPress site url
- Why is my WordPress URL shortened
- mysterious issue with stop words in urls not working – how can I restore multiple url access?
- What does this structure of the URL mean? http://www.example.com/?i=0
- How to create URL for Pages/Posts
- Private Messages between users
- Navigation and Permalink not getting correctly
- How to create a dedicated folder for specific role via registration
- How to get the correct URL on my wordpress site?
- WordPress custom form post to different page
- Two domain site: Link base URLs point to wrong domain
- How to redirect WP post with a specific word in the URL
- Duplicate content with the same URL, google authorship
- Making a site URL
- Avoid too long words in a post title, post content or comment but only if its not a url
- Change URL to filter posts
- Modify WordPress to not replace + (plus) characters from URLs?
- How to remove slug from url (custom post type)
- Accessing a file saved outside webroot in a wordpress post
- Enabling canonical links to force search engines to go to site.com rather than site.net [closed]
- Why my wordpress site URL does not begin with my domain?
- Is There a Way to Schedule URL to Content Updates?
- I changed my url and cant access my site, Help?
- Accidentally changed the url
- Select Tab name to show in browser’s URL
- How to make media URLs Unique
- WordPress rewrites my link with custom URL scheme to http(s)
- Show page name after home url
- How to create multiple urls for a same page contents in wordpress
- how to add param string after website url in wordpress?