Skip to content

Instantly share code, notes, and snippets.

View nawawi's full-sized avatar

Nawawi Jamili nawawi

View GitHub Profile
@nawawi
nawawi / docketcache_flush_when_plugin_update.php
Created October 14, 2025 12:42
docketcache_flush_when_plugin_update.php
<?php
// Place this code in wp-content/mu-plugins/docketcache_flush_when_plugin_update.php
add_action('docketcache/init', function($docket_cache_instance) {
$docket_cache = $docket_cache_instance;
add_action( 'upgrader_process_complete', function($wp_upgrader, $options) use($docket_cache) {
if ('update' !== $options['action']) {
return;
}
@nawawi
nawawi / wpstg-cli-faq.md
Last active October 1, 2025 05:00
wpstg-cli-faq

WP-Staging-CLI FAQ

General Questions

Q1: What is wp-staging-cli?
A1: wp-staging-cli is a high-performance command-line tool to process WP Staging backup files (.wpstg). It allows you to extract, normalize, inspect, and restore backups without using WordPress itself.

Q2: Which operating systems are supported?
A2: Windows, Linux, and macOS. Pre-built binaries are available for all major OSes.

@nawawi
nawawi / docketcache_flush_when_save_post.php
Created January 6, 2025 16:44
docketcache_flush_when_save_post.php
<?php
// Place this code in wp-content/mu-plugins/docketcache_flush_when_save_post.php
add_action('docketcache/init', function($docket_cache_instance) {
$docket_cache = $docket_cache_instance;
add_action( 'save_post', function($post_id, $post, $update) use($docket_cache) {
$result = $docket_cache->flush_cache(true);
$docket_cache->co()->lookup_set('occacheflushed', $result);
do_action('docketcache/action/flush/objectcache', $result);
}, 10, 3);
@nawawi
nawawi / docketcache_flush_daily.php
Last active December 26, 2024 11:30
docketcache_flush_daily.php
<?php
// Place this code in wp-content/mu-plugins/docketcache_flush_daily.php
add_action('docketcache/init', function($docket_cache_instance) {
$docket_cache = $docket_cache_instance;
add_action('docketcache_flush_daily', function() use($docket_cache) {
$result = $docket_cache->flush_cache(true);
$docket_cache->co()->lookup_set('occacheflushed', $result);
do_action('docketcache/action/flush/objectcache', $result);
});
@nawawi
nawawi / custom_base64_decode.php
Created December 9, 2024 13:25
custom_base64_decode
<?php
function custom_base64_decode($input) {
$base64_chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
$output = '';
// Remove padding characters and replace invalid characters
$input = str_replace(['-', '_'], ['+', '/'], $input);
$input = rtrim($input, '=');
@nawawi
nawawi / 0-docket-cache-deactivate.php
Last active December 8, 2024 02:11
Prevent docket-cache from being activated
<?php
// Disable wp-content/object-cache.php
if (!defined('DOCKET_CACHE_DISABLED')) {
define('DOCKET_CACHE_DISABLED', true);
}
// Deactivate docket-cache
add_action('docketcache/init', function ($docket_cache_instance) {
try {
(new Nawawi\DocketCache\Event($docket_cache_instance))->unregister();
@nawawi
nawawi / 0-wpstg-reset.php
Last active February 17, 2025 10:02
0-wpstg-reset
<?php
add_action('wpstg.clone_first_run', function () {
// Set to false for actual operation
$isDryRun = true;
// Abort if not wp-staging staging site
if (empty($GLOBALS['table_prefix']) || !preg_match('@^wpstg\d+@', $GLOBALS['table_prefix'])) {
return;
}
<?php
add_action('docketcache/init', function($docket_cache_instance) {
$docket_cache = $docket_cache_instance;
// Flush cache
add_action('docket_cache_control_flush_cache', function() use($docket_cache) {
$result = $docket_cache->flush_cache(true);
$docket_cache->co()->lookup_set('occacheflushed', $result);
do_action('docketcache/action/flush/objectcache', $result);
});
@nawawi
nawawi / openssl_private_public_key_example.php
Created June 11, 2024 06:58
php openssl private/public key example
<?php
// Configuration settings for the key
$config = array(
"digest_alg" => "sha512",
"private_key_bits" => 4096,
"private_key_type" => OPENSSL_KEYTYPE_RSA,
);
// Create the private and public key
$res = openssl_pkey_new($config);
@nawawi
nawawi / intuitive-custom-post-order.php
Last active April 16, 2024 19:38
intuitive-custom-post-order.php
<?php
/*
* Plugin Name: Intuitive Custom Post Order
* Plugin URI: http://hijiriworld.com/web/plugins/intuitive-custom-post-order/
* Description: Intuitively, Order Items (Posts, Pages, ,Custom Post Types, Custom Taxonomies, Sites) using a Drag and Drop Sortable JavaScript.
* Version: 3.1.5
* Author: hijiri
* Author URI: http://hijiriworld.com/web/
* Text Domain: intuitive-custom-post-order
* Domain Path: /languages