CSP nonces with Cloudflare Workers

Thank you for your answer, you are absolutely right. I also corrected my mistake. I’ll post the code if it helps. Code for Cloudflare Workers: https://gist.github.com/richie5um/b2999177b27095af13ec619e44742116 Code for WordPress : add_filter( ‘script_loader_tag’, ‘add_nonce_to_script’, 10, 3 ); function add_nonce_to_script( $tag, $handle, $source ) { $search = “type=”text/javascript””; $replace = “type=”text/javascript” nonce=”””; $subject = $tag; $output = … Read more

On a multisite environment, get the subdomain value as variable

wp_insert_site recieves WP_Site object, which contains details about the current site. https://developer.wordpress.org/reference/hooks/wp_insert_site/ do_action( ‘wp_insert_site’, WP_Site $new_site ) Fires once a site has been inserted into the database. https://developer.wordpress.org/reference/classes/wp_site/ WP_Site Object ( [blog_id] => 2 [domain] => localhost [path] => /m2/sagres/ [site_id] => 1 [registered] => 2018-03-23 13:49:37 [last_updated] => 2019-03-05 15:52:10 [public] => 0 [archived] … Read more

WordPress does not show correct page

The problem is with the permalinks. Swithing to «plain» made the problem go away. Still haven’t solved how to get correct behavior from «post name». With this setting, wordpress just delivers a random page. Case closed.

XMLRPC won’t connect?

Instead of using XMLRPC which isn’t available on some hosts, use the REST API instead. Send a HTTP POST request to the posts endpoint containing a JSON object with your desired post, with an authentication header. To do this, we’re going to need an authentication plugin ( standard WP only supports nonce + cookie which … Read more

WP Multisite – Additional subdomain on the site for API purposes

I have resovled it myself. I have enabled sunrise in wp-config. Then add a script to sunrise.php to override HTTP_HOST. I made it dynamic since we have many websites. When you visit api.domainxy.com it automatically shows you domainxy.com. <?php $re=”/(?:api\.)(.*)/m”; $str = $_SERVER[‘HTTP_HOST’]; preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0); if ($matches && $matches[0][1] != “”) { … Read more