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
Drupal.settings.isTouchDevice = function() { | |
return "ontouchstart" in window; | |
} | |
if ( Drupal.settings.isTouchDevice() ) { | |
Drupal.behaviors.jQueryMobileSlideShowTouchAdvance = { | |
attach: function(context, settings) { | |
self = Drupal.behaviors.jQueryMobileSlideShowTouchAdvance; | |
jQuery.each(jQuery(".views_slideshow_cycle_main.viewsSlideshowCycle-processed"), function(idx, value) { | |
value.addEventListener("touchstart", self.handleTouchStart); |
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
/** | |
* A textual language chooser widget compatible with qTranslate and qTranslate-slug | |
* Author: Mauro Mascia | |
* License: WTFPL (www.wtfpl.net) | |
*/ | |
class Widget_Language_Chooser extends WP_Widget { | |
function __construct() { | |
parent::__construct( | |
'widget_language_chooser', |
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
/** Get or set the current outer width/height for the first element in the set of matched elements. */ | |
var origOuterWidth = $.fn.outerWidth; | |
$.fn.outerWidth = function(){ | |
var value = arguments[0]; | |
if (arguments.length === 0 || typeof value === 'boolean') { return origOuterWidth.apply(this, arguments); } | |
else if (typeof value !== 'number') { throw new Error('Invalid argument. The new outerWidth value must be an integer.'); } | |
var css = ['borderLeftWidth','borderRightWidth','paddingLeft','paddingRight']; | |
if (arguments[1] === true) { css.push('marginLeft'); css.push('marginRight'); } | |
var $el = $(this), exclude = 0, parse = parseFloat; | |
for (var i=0; i<css.length; i++) { exclude += parse($el.css(css[i])); } |
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 | |
BACKUP_DIR="~/db_backups" | |
DBUSER="" | |
DBPASSWORD="" | |
BUCKET="your-unique-bucket-name" | |
FROM='"Backups" <backups@localhost>' | |
TO='"Admin" <admin@localhost>' | |
SUBJECT='Backup Log' |
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
// see also https://gist.github.com/3201854 | |
function mytheme_menu_tree__main_menu($variables) { | |
return '<select class="mobile-main-menu" onchange="location = this.options[this.selectedIndex].value;">' | |
. $variables['tree'] . '</select>'; | |
} | |
function mytheme_menu_link__main_menu($variables) { | |
global $base_url; | |
$e = $variables['element']; |
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 { |
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
/** | |
* Language list Code for non-Widget users | |
* | |
* @global array $q_config | |
* @param string $sep | |
*/ | |
function qtrans_generate_language_list($sep = " | ") { | |
global $q_config; | |
$languages = qtrans_getSortedLanguages(); | |
$num_langs = count($languages); |
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
/** | |
* Hide Standard Shipping option when free shipping is available | |
* | |
* @param array $available_methods | |
*/ | |
function sardbaba_hide_standard_shipping_when_free_is_available($available_methods) { | |
if (isset($available_methods['free_shipping']) AND isset($available_methods['flat_rate'])) { | |
// remove standard shipping option | |
unset($available_methods['flat_rate']); | |
} |
OlderNewer