Skip to content

Instantly share code, notes, and snippets.

View felipelavinz's full-sized avatar

Felipe Lavín Z. felipelavinz

View GitHub Profile
jQuery.fn.accordionMenu = function(settings){
settings = jQuery.extend({
delegate_selector : 'a', // {selector} selector that will receive the click
expandable_selector : 'dd', // {selector} selector that will expand/collapse
hide_onload : true, // {boolean} wheter to hide menus on page load
active_class : 'active', // {string} the name of the class that will be applied to the active element
fx : false, // {boolean} whether to use slide effect or simple hide/show
fx_speed : 'normal', // {string|number} speed keyword (slow, normal, fast) or milliseconds
dblclick_go : true // {boolean} whether to work as normal link on double click when menu is displayed
}, settings);
/**
* [[%%ask1: Nombre del Widget]]
* [[%%ask2: Descripción]]
*/
class [[%%ask3: Nombre de la función]] extends WP_Widget {
/** constructor */
function [[%%ask3]]() {
$widget_ops = array('classname' => '[[%%ask3]]', 'description' => '[[%%ask2]]');
$control_ops = array('width' => 400);
$this->WP_Widget('[[%ask3]]', '[[%%ask1]]', $widget_ops, $control_ops);
@felipelavinz
felipelavinz / functions.php
Created November 9, 2010 20:38
A basic WordPress functions.php as starting point for theme development
<?php
/* Register WordPress theme settings ******************************************/
/* Navigation menus -----------------*/
register_nav_menus( array(
'primary' => 'Principal'
));
/* Images ---------------------------*/
add_theme_support( 'post-thumbnails' );
/* Sidebars -------------------------*/
@felipelavinz
felipelavinz / WP_Widget_update_array.php
Created November 17, 2010 19:35
Save array data on WordPress Widgets
<?php
/**
* To be used on a WordPress Widget object
* Fields named as '_foo_bar' will become $new_instance['foo']['bar'] = $val
* Fields named as '_lorem_ipsum_dolor' become $new_instance['lorem']['ipsum']['dolor'] = $val
**/
function update( $new_instance, $old_instance ) {
foreach ( $new_instance as $key => $val ) {
@felipelavinz
felipelavinz / jquery.tab_nav.js
Created January 5, 2011 22:14
Tabs navigation for jQuery
jQuery.fn.tab_nav = function(settings) {
settings = jQuery.extend({
active_class: 'active',
return_act : false
},settings);
var s = settings,
$el = jQuery(this),
$tab_links = $el.find('a'),
$is_active = $el.find('.'+s.active_class);
// Set first tab as active on document ready
@felipelavinz
felipelavinz / jquery.accordion_menu.js
Created January 5, 2011 22:15
Accordion Menu for jQuery
jQuery.fn.accordionMenu = function(settings){
settings = jQuery.extend({
delegate_selector : 'a', // {selector} selector that will receive the click
expandable_selector : 'dd', // {selector} selector that will expand/collapse
hide_onload : true, // {boolean} wheter to hide menus on page load
active_class : 'active', // {string} the name of the class that will be applied to the active element
fx : false, // {boolean} whether to use slide effect or simple hide/show
fx_speed : 'normal', // {string|number} speed keyword (slow, normal, fast) or milliseconds
dblclick_go : true // {boolean} whether to work as normal link on double click when menu is displayed
}, settings);
@felipelavinz
felipelavinz / gist:788600
Created January 20, 2011 20:35
komodo snippets
// comillas internas
'. [[%(w:else:)]] .'
// concatenar a $out
$out .= '[[%(w:else:)]]';
@felipelavinz
felipelavinz / wp_transients_helper.php
Created January 25, 2011 16:28
An abstract class to facilitate working with WordPress transients
<?php
abstract class av_transients_helper{
var $transient_name;
var $expire;
function __construct($id, $expire){
$this->transient_name = $id;
$_expire = ( (int)$expire > 0 ) ? (int)$expire : 1;
$this->transient_expire = 60 * 60 * $_expire;
}
public function get_data(){
@felipelavinz
felipelavinz / wp_post_objects.php
Created March 17, 2011 19:04
Abstract class for dealing with common tasks over WordPress post objects
<?php
/**
* Basically, a posts objects iterator
* @author Felipe Lavín Z. <felipe@yukei.net>
**/
abstract class av_post_objects{
public $id;
public $meta;
public $type;
@felipelavinz
felipelavinz / phpfcgi-checker.bash
Created May 3, 2011 02:11
PHP FastCGI process checker
#! /bin/bash
if curl --write-out %{http_code} --silent --output /dev/null http://www.yukei.net | grep 504
then
killall -s KILL php-cgi
spawn-fcgi -U www-data -G www-data -a 127.0.0.1 -p 47990 /usr/bin/php-cgi
fi