Dev log
Magento & WordPress password hash generator
Make a password hash for WordPress (bcrypt, phpass or MD5) or Magento 1 and 2, and set it in the database when you're locked out. Or use WP-CLI or bin/magento.
4 min read
Field notes
Blog
Notes from the Riksi studio in Melbourne. Plain guides on WordPress, Shopify, front-end code, speed and the tools I use every day.
Dev log
Magento & WordPress password hash generator
Make a password hash for WordPress (bcrypt, phpass or MD5) or Magento 1 and 2, and set it in the database when you're locked out. Or use WP-CLI or bin/magento.
4 min read
Dev log
Migrate a WordPress site from local to live
Move a WordPress site from your computer to a live server. Copy the files, move the database, fix URLs safely (serialized data included) and check everything.
4 min read
Dev log
Redirect logged-out users in PHP and WordPress
Send visitors who are not signed in to the login page. A safe session check in plain PHP, and the WordPress way with is_user_logged_in() and auth_redirect().
3 min read
Dev log
Use WordPress functions outside WordPress, and the better options
Require wp-load.php to use WordPress functions in another PHP script. I also cover when SHORTINIT, the REST API or WP-CLI is the better tool.
5 min read
Dev log
Create and use a dynamic sidebar (widget area) in WordPress
Register a widget area with register_sidebar(), show it with dynamic_sidebar() inside is_active_sidebar(), and handle block widgets since WordPress 5.8.
4 min read
Dev log
Show one WordPress page’s content in another template
Pull one page's content into another template with get_post() and the_content filter, or setup_postdata() for template tags. I include a safe shortcode too.
4 min read
Advertisement
Dev log
Replace text in a string with JavaScript
replace() changes the first match. replaceAll() or a regex with the g flag changes every match. Also case-insensitive swaps, $ patterns and escaping input.
4 min read
Dev log
Remove or escape illegal characters in a MySQL string
There are two jobs here. Stop quotes breaking a query with prepared statements, and clean unwanted characters out of stored data with REPLACE, TRIM or REGEXP_REPLACE.
4 min read
Dev log
Run a WordPress shortcode from PHP (and when not to)
Use do_shortcode() to run a shortcode in a PHP template, or call the function behind it when the shortcode is yours. Plus timing, escaping and [embed].
5 min read