This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
views = { | |
"a1": {"position":0,"depends": []}, | |
"a2": {"position":0,"depends": ["a1"]}, | |
"a3": {"position":0,"depends": ["a2"]}, | |
"a5": {"position":0,"depends": ["a9"]}, | |
"a9": {"position":0,"depends": ["a7","a8"]}, | |
"a7": {"position":0,"depends": []}, | |
"a8": {"position":0,"depends": []}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def flatten_json(nested_json, name='', exclude=['']): | |
"""Flatten json object with nested keys into a single level. | |
Args: | |
nested_json: A nested json object. | |
name: A name to cancatenate to the sublevels keys | |
exclude: Keys to exclude from output. | |
Returns: | |
The flattened json object if successful, None otherwise. | |
""" | |
out = {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
for d in */ ; do | |
mp3PATH=$PWD/"$d" | |
OUTDIR=$(basename "${mp3PATH//\'}") | |
echo $mp3PATH $OUTDIR | |
if [ -d "$mp3PATH" ]; then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var total = 0; for(var x in localStorage) { var amount = (localStorage[x].length*2)/1024/1024; total += amount; } console.log("Total: "+total.toFixed(10)+" MB"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class My_Class { | |
public function __construct () { | |
// Aggiunge verifica email ai campi billing | |
add_filter( 'woocommerce_billing_fields' , array($this, 'woocommerce_billing_fields'), 10, 1 ); | |
add_action( 'woocommerce_checkout_process', array($this, 'woocommerce_checkout_process'), 9 ); | |
} | |
function array_insert(&$array, $position, $insert) { | |
$pos = array_search($position, array_keys($array)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Produces a dump on the state of WordPress when a not found error occurs */ | |
/* useful when debugging permalink issues, rewrite rule trouble, place inside functions.php */ | |
ini_set( 'error_reporting', -1 ); | |
ini_set( 'display_errors', 'On' ); | |
echo '<pre>'; | |
add_action( 'parse_request', 'debug_404_rewrite_dump' ); | |
function debug_404_rewrite_dump( &$wp ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function( $ ) { | |
$.fn.vcenter = function () { | |
this.css("position","absolute"); | |
this.css("top", Math.max(0, (($(window).height() - $(this).outerHeight()) / 2) + $(window).scrollTop()) + "px"); | |
return this; | |
} | |
$.fn.hcenter = function () { | |
this.css("position","absolute"); | |
this.css("left", Math.max(0, (($(window).width() - $(this).outerWidth()) / 2) + $(window).scrollLeft()) + "px"); | |
return this; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Aggiungo una notice nella pagina dei prodotti con due bottoni: | |
* uno per nascondere (mettere in bozza), l'altro per pubblicare tutti i prodotti. | |
*/ | |
add_action( "admin_notices", function() { | |
// Verifico che sia la pagina corretta | |
$screen = get_current_screen(); | |
if ( 'edit-product' != $screen->id ) return; | |
$_wpnonce = wp_create_nonce('la_mia_stringa_di_sicurezza'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Add a date range to a datepicker field, replace #date with the id of the date field. | |
add_filter( 'wp_footer' , 'woo_add_checkout_field_date_range_limit' ); | |
function woo_add_checkout_field_date_range_limit() { | |
if ( is_checkout() ) { | |
$js = 'jQuery( "#date" ).datepicker({ minDate: -5, maxDate: "+1M +10D" });'; | |
// Check if WC 2.1+ | |
if ( defined( 'WC_VERSION' ) && WC_VERSION ) { | |
wc_enqueue_js( $js ); | |
} else { |
NewerOlder