I’m starting to read “WordPress Plugin Development Cookbook – Third Edition”. The first example does nothing other than make a do nothing plugin visible in the admin page, but the second example already allowed for some fun. I’m happy with how psychedelic this turned out: <?php /* Plugin Name: Chapter 2 - Plugin Page Header Plugin URI: Description: Declares a plugin that will add something to the header Version: 1.0 Author: David Faden Author URI: https://revfad.com License: MIT */ add_action('wp_head', 'ch2pho_page_header_output'); function ch2pho_page_header_output() { ?> <script> function setRandomBgcolor() { if (!document.body?.style) { return; } const color = '#' + parseInt(0xffffff * Math.random()).toString(16).padStart('0', 6); document.body.style.backgroundColor = color; } setInterval(setRandomBgcolor, 300); </script> <?php } I won’t add it here though. References mentioned: https://codex.wordpress.org/Main_Page https://developer.wordpress.org/apis/hooks/action-reference/…
No comments yet. Log in to reply on the Fediverse. Comments will appear here.