Skip to content

Instantly share code, notes, and snippets.

@onwp
onwp / auto-set-all-custom-fields-as-translatable-for-wpml.js
Created July 5, 2024 07:44
Check "Translate" option for all custom fields in WPML plugin
// Scroll into Custom Fields settings
document.querySelector(".wpml-custom-fields-settings").scrollIntoView();
// Click on 'Display All' button
jQuery(".wpml-custom-fields-settings .display-all").click();
const set_acf_fields_translatable = setInterval(() => {
// When 'Display All' button is clicked, the 'display-all' class is removed, therefore check until it doesnt exist
if (jQuery(".wpml-custom-fields-settings .display-all").length == "0") {
// Scroll into the 'Save' button
@onwp
onwp / chained-select-tinymce-window.js
Created May 20, 2024 15:09
Chained select (listbox) on tinymce window (modal). For WordPress.
/* global jQuery, iziToast */
// Chained select (listbox) on tinymce window (modal)
tinymce.PluginManager.add('address_shortcode_inserter', function (editor) {
var addresses = [];
function getCountries(countryID, elm) {
let win = tinymce.activeEditor.windowManager.getWindows()[0];
let countriesField = win.find(`#${elm.name}`);
let citiesField = win.find(`#${fields.citiesField.name}`);
@onwp
onwp / nginx.conf
Created December 12, 2023 08:34
alpine-nginx-php8/config/nginx.conf
worker_processes 1;
error_log stderr warn;
pid /run/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
@onwp
onwp / wp-cli-clear-cache-commands.txt
Created October 11, 2023 07:07
WP cli clear cache commands
#Flush the object cache using this WP-CLI command.
wp cache flush
#Beaver Builder plugin and Beaver Theme have these WP-CLI commands.
wp beaver clearcache
wp beaver theme clearcache
wp beaver clearcache --all
#Autoptimize plugin has this WP-CLI command.
wp autoptimize clear
@onwp
onwp / openvpn-weak-algorithm-fix.txt
Created May 30, 2023 12:27
openvpn weak algorithm fix
Insert the following line in the client's config.ovpn file:
tls-cipher "DEFAULT:@SECLEVEL=0"
@onwp
onwp / gist:16048aba167d66850ee32550f44b4cec
Created April 21, 2023 18:48
prisma not reading env database_url
npm install -g dotenv-cli
npx prisma generate
dotenv -e .env.local -- npx prisma db push
@onwp
onwp / fresh_npm_install.txt
Created March 19, 2023 18:46
Delete node_modules, clean cache, and npm install
rm -rf node_modules && rm -rf **/node_modules && rm -rf package-lock.json && rm -rf yarn-error.log && rm -rf yarn.lock && npm cache clean --force && npm i
@onwp
onwp / bulk-update-git-author-info.sh
Created February 25, 2023 15:41
Update your old email and name in commits.
git filter-branch --env-filter '
OLD_EMAIL="old@example.com"
NEW_NAME="New Author Name"
NEW_EMAIL="new@example.com"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_COMMITTER_NAME="$NEW_NAME"
export GIT_COMMITTER_EMAIL="$NEW_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]
@onwp
onwp / mac-desktop-icons-on-left-side.scpt
Last active December 13, 2023 12:35
MacOS Desktop Icons on Left. It rearranges your desktop icons, keeps it aligned to the left side of screen.
-- https://gist.github.com/mrienstra/8330528
-- Based on http://www.tuaw.com/2012/12/24/applescript-desktop-icon-race/
-- Inspired by http://namesakecomic.com/comic/happy-new-year-from-namesake/#comment-1182035013
-- Rearranges Desktop icons to flow from left to right, top to bottom.
-- To have this run automatically every time files are added or removed from the Desktop, set this script to run as a Desktop "Folder Action". (See https://developer.apple.com/library/mac/documentation/applescript/conceptual/applescriptlangguide/reference/ASLR_folder_actions.html )
-- This is currently a rough proof-of-concept. It has only been tested with OS y 10.8.5 (Mountain Lion).
@onwp
onwp / mac-clean-up-desktop.scpt
Created February 25, 2023 15:21
Tidy up your desktop icons on mac
tell application "System Events"
tell application "Finder" to activate desktop
tell process "Finder"
click menu item "Clean Up" of menu "View" of menu bar item "View" of front menu bar
end tell