How to add additional http header to a wp_error rest response

WP_REST_Response extends WP_HTTP_Response class, which has a header() method for setting headers. Using the rest_request_after_callbacks filter should allow setting the header, but will need to duplicate the functionality of WP_REST_Server->error_to_response(), which at time of writing calls rest_convert_error_to_response(), so that’s easy enough. Here’s what I think this will end up looking like (untested). add_filter( ‘rest_request_before_callbacks’, static … Read more

Content Security Policy blocking images from installed plugins’ popup info window, as they are from external domains – global fix?

The answer, as mentioned in a comment by @JacobPeattie, was to add the domains to my .htaccess file where I am setting the CSP Headers, (turns out most plugins’ “View Details” link loads images from ps.w.org, which I just learned). A few other plugins loaded images from other domains, so I also added each of … Read more

Why is there a bunch of WordPress HTML code in my browser CSV download?

This code cannot run in a shortcode: if ( $_SERVER[‘REQUEST_METHOD’] == ‘GET’ && isset($_GET[‘CSV’]) ) { require_once __DIR__ . ‘/../assets/helpers.php’; // contains csv_download() function csv_download(); } The problem is that by the time a shortcode executes it’s too late to send HTTP headers, and WordPress has already sent the theme header and HTML body tags. … Read more

No Google Analytics code rendered in the header?

Thanks @Danijel for providing the link to their github. I’ve played around with the theme and I found that you should make changes here https://github.com/presscustomizr/customizr/blob/dev/templates/head-no-model.php It seems that the code from here https://github.com/presscustomizr/customizr/blob/dev/header.php#L10 is executed and doesn’t reach to your added code. I was able to see the GA script after adding the code in … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)