Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / pre-commit
Created August 15, 2024 13:22 — forked from joorloohuis/pre-commit
Git pre-commit hook for syntax checking before committing
#!/bin/bash
#
# PHP Syntax linter, checks syntax before commit actually happens
# Save this file in your git project as .git/hooks/pre-commit and make sure it's executable
# PHP lint command, modify if necessary
LINT='/usr/bin/php -l'
files=$(git diff --cached --name-only --diff-filter=ACM | grep "\.php$")
if [ "$files" = "" ]; then