Skip to content

Instantly share code, notes, and snippets.

@bgrgicak
bgrgicak / debug-log.php
Created November 18, 2022 13:10
PHP pretty print objects and arrays in a log file
function debug( $message, $label = '', $log_file = 'debug.log' ) {
if ( is_bool( $message ) ) {
$message = $message ? 'true' : 'false';
} else if ( is_array( $message ) || is_object( $message ) ) {
$message = json_encode(
$message,
JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES
);
}

Basic utility to launch a python 2 or python 3 simple http server.

#!/usr/bin/env bash

if [ "$1" != "" ]; then
  PORT="$1"
elif [ "$PORT" = "" ]; then
  PORT=8000
fi
@ms-studio
ms-studio / add-metabox-to-taxonomy.php
Created December 14, 2015 21:57
simple but complete example of adding metabox to taxonomy - using WP 4.4 term meta functions
<?php
// source: http://wordpress.stackexchange.com/questions/211703/need-a-simple-but-complete-example-of-adding-metabox-to-taxonomy
// code authored by jgraup - http://wordpress.stackexchange.com/users/84219/jgraup
// REGISTER TERM META
add_action( 'init', '___register_term_meta_text' );
function ___register_term_meta_text() {
@gfazioli
gfazioli / old_version_event.js
Last active March 31, 2020 21:51
WordPress: Actions & Filters in Javascript
/**
* This is the old version build by jQuery trigger event.
*
* DO NOT USE
*
*/
if ( typeof window.wpdk_add_action === 'undefined' ) {
/**