In the context of that question, yes it is. Without inspecting the content type header you don’t know if what is being served is an html page or an image, and while it is unlikely that the regex will match anything in an image, the risk is there.
a different way to write that code is to hook it on template_redirect
or even get_header
to be as close to 100% sure you are dealing with html pages and not RSS, json, xml etc, for which that URL transformation might not be required or even welcome.
looking again at the original question, obviously you will want it in the admin pages as well… so maybe your original solution is the most comprehensive that can actually be.
OTOH, and not very related to this question, you might end with replacing too much, like the canonical url which might create duplicate content problem.
Related Posts:
- Load images with http urls inside https post
- Force home page to be https?
- WordPress Move to SSL How to Update Media Assets to HTTPS?
- Broken urls with http site and https wp-admin
- Avoid the removal of “https:” from URLs
- No https in url when writing links like:
- How do I make the block editor use https by default?
- 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
- Can’t login after my site was moved to a new server
- Why WordPress automatically removes http from the url of my website’s sub domain?
- 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
- Easiest way to simulate WordPress’s URL resolution to retrieve post ID, etc?
- How to add domain security certification, in WordPress website?
- Imported thumbnails have incorrect URL
- Redirect http to https does not work on subdir where another instance of WordPress installed
- 403 error on admin login page
- how to make URL link query string
- Allow Chinese character on post URL slug
- Problem with change url for all subpages (.htaccess)
- Displaying Post with Custom URL with RewriteRule or add_rewrite_rule
- How to get URL for the first page of post archive
- Newline URL entity when using esc_url()
- How to handle this URL Structure. Keep getting “page not found”
- WordPress changing script source from https to http
- Custom url in wordpress
- How to auto gen. custom post type values in other custom post type in url?
- WordPress get parameter ‘unapproved’ and ‘moderation-hash’
- URL issue after migrating to dev site
- 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
- Cannot access WordPress website from external IP while internally it is working properly [closed]
- Pass form input via url variable
- Wrapping add_query_arg with esc_url not working
- Relative URLs within site
- How to make WordPress urls matching static html urls
- 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
- Why does WordPress uses HTTPS for JS, CSS on EC2
- After changing Site http to https, can’t access wp login page with a digitalocean hosting
- Specific Page/Post Need to Stay Non SSL
- 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
- 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
- WordPress HTTPS – ‘… better to use HTTP for installation …’
- Two domain site: Link base URLs point to wrong domain
- How to redirect WP post with a specific word in the URL
- Making a site URL
- Avoid too long words in a post title, post content or comment but only if its not a url
- how to server over http and https with one installation
- 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?
- Accidentally changed the url
- Select Tab name to show in browser’s URL
- How to make media URLs Unique
- How to write url to display all posts of certain type and taxonomy with given term_id
- How to create multiple urls for a same page contents in wordpress