Skip to content

Instantly share code, notes, and snippets.

@chrono-meter
chrono-meter / sample.php
Created May 30, 2026 23:04
Configure SMTP settings in `wp-config.php`.
/**
* Configure SMTP settings in `wp-config.php`.
*
* @param \PHPMailer\PHPMailer\PHPMailer $phpmailer
* @link https://github.com/WordPress/WordPress/blob/master/wp-includes/PHPMailer/PHPMailer.php
*/
$GLOBALS['wp_filter']['phpmailer_init'][10][] = array(
'accepted_args' => 1,
'function' => function ( $phpmailer ) {
$phpmailer->Host = 'smtp.example.com';
function GM_onSelectorMatched(selector, callback) {
new MutationObserver(mutations => {
for (const mutation of mutations) {
for (const addedNode of mutation.addedNodes) {
if (addedNode instanceof HTMLElement) {
if (addedNode.matches(selector)) {
callback(addedNode);
}
for (const el of addedNode.querySelectorAll(selector)) {
#!/bin/sh
# 1. Copy this file as `/etc/initramfs-tools/scripts/local-top/mdadm-fallback`
# 2. Make executable: sudo chmod +x /etc/initramfs-tools/scripts/local-top/mdadm-fallback
# 3. Run `sudo update-initramfs -u`
# 4. (Optional) Run `sudo dpkg-reconfigure grub-efi-amd64`
# Tested on: Debian 10
set -eu
PREREQ="mdadm"
prereqs()
@chrono-meter
chrono-meter / _phpscoper-config-for-wp.md
Last active October 21, 2025 01:28
PHP-Scoper configuration sample for WordPress plugin.

PHP-Scoper configuration sample for WordPress plugin.

Replace YOUR_PREFIX in composer.json.

Run composer update or any composer package install/update command.

Then put the code below in your initialization code:

require_once __DIR__ . '/third-party/vendor/autoload.php';
@chrono-meter
chrono-meter / webpack.config.js
Created November 22, 2024 13:51
How to use `@wordpress/react-i18n`.
/**
* Even though some module is not included in WordPress core, `wp-scripts` treats it as an external module.
*
* The following code will cause an error like: `Uncaught TypeError: Cannot read properties of undefined (reading 'I18nProvider')`.
* ```js
* import { I18nProvider } from '@wordpress/react-i18n';
* ```
*/
const defaultConfig = require('@wordpress/scripts/config/webpack.config');
const DependencyExtractionWebpackPlugin = require('@wordpress/dependency-extraction-webpack-plugin');
@chrono-meter
chrono-meter / wp-customize-classiceditor.php
Created August 3, 2024 02:30
WordPress Classic Editor (wp-admin/edit-form-advanced.php) customization.
<?php
const POST_TYPE_NAME = 'YOUR_TYPE';
/**
* Use Classic Editor for this post type.
*/
add_filter( 'use_block_editor_for_post_type', fn( $result, $post_type_name ) => POST_TYPE_NAME === $post_type_name ? false : $result, 10, 2 );
@chrono-meter
chrono-meter / README.md
Created June 24, 2024 12:47
WordPress React components for plugin pages without node `id`.

Remove html id and pass arguments to React components.

See original version for more information.

@chrono-meter
chrono-meter / Apache reverse proxy via Putty port forward.md
Last active May 3, 2024 22:52
Apache reverse proxy via Putty port forward.

⚠️ Fix weak security before expose.

Add apache setting.

HOST="your-host.example.com"; FORWARD_URL="http://127.0.0.1:10080/"
sudo tee -a /etc/apache2/sites-enabled/$HOST.conf <<EOT
<VirtualHost *:80>
    ProxyPreserveHost On
    ProxyPass / $FORWARD_URL
 ProxyPassReverse / $FORWARD_URL
@chrono-meter
chrono-meter / install-sevpn-service.sh
Last active February 26, 2024 23:38
Install SoftEther VPN Server as systemd service.
sudo tee /lib/systemd/system/vpnserver.service << END
[Unit]
Description=SoftEther VPN Server
After=network.target
[Service]
Type=forking
Environment="TAP=tap_vpn"
Environment="BR=br0"
ExecStartPre=ip tuntap add \$TAP mode tap
ExecStartPre=ip link set \$TAP up
@chrono-meter
chrono-meter / wp-spoofing-hostport.php
Created October 26, 2023 00:39
Spoofing host and port for WordPress environment
<?php
/**
* Spoofing host and port for WordPress environment.
* To use this, include from your "wp-config.php" file.
* Note that this functions is not intended to be used in production.
*
* @see \is_ssl()
* @link https://ngrok.com/docs/using-ngrok-with/wordpress/
*/