Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Add the website URL without the www subdomain to the allowed HTTP origins array (fixes CORS issue)
- * Paste this in your active theme's functions.php file.
- * @param array $origins
- * @return array
- */
- add_filter( 'allowed_http_origins', function( $origins ) {
- $urls = [admin_url(), home_url()];
- foreach( $urls as $url ) {
- $parsedUrl = parse_url( $url );
- $host = str_replace( 'www.', '', $parsedUrl['host'] );
- $origins[] = 'http://'.$host;
- $origins[] = 'https://'.$host;
- }
- return array_unique( $origins );
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement