Skip to content

Instantly share code, notes, and snippets.

@lmartins
lmartins / gulpfile.js
Last active August 25, 2016 17:00
Current Gulpfile configuration
'use strict';
var gulp = require('gulp'),
connect = require('gulp-connect'),
gulpLoadPlugins = require('gulp-load-plugins'),
cleanhtml = require('gulp-cleanhtml'),
dev = require('gulp-dev'),
browserSync = require('browser-sync'),
plugins = gulpLoadPlugins(),
webpack = require('webpack'),
@lmartins
lmartins / woo-archives.php
Created November 18, 2014 19:24
Show categories associated to each product in archives
/**
* Mostra as categorias associadas ao tema
*/
add_action( 'woocommerce_after_shop_loop_item_title', 'mw_archive_add_theme_category', 5 );
function mw_archive_add_theme_category()
{
global $product;
$out = '<div class="product-categories">';
$out .= strip_tags( $product->get_categories() );
<?php
add_filter('gettext', 'rename_admin_menu_items');
add_filter('ngettext', 'rename_admin_menu_items');
/**
* Replaces wp-admin menu item names
*
* @author Daan Kortenbach
*
* @param array $menu The menu array.
*
<?php
/*
Usage:
$frag = new CWS_Fragment_Cache( 'unique-key', 3600 ); // Second param is TTL
if ( !$frag->output() ) { // NOTE, testing for a return of false
functions_that_do_stuff_live();
these_should_echo();
// IMPORTANT
$frag->store();
// YOU CANNOT FORGET THIS. If you do, the site will break.
upstream phpfpm {
server unix:/var/run/php5-fpm.sock;
}
upstream hhvm {
server unix:/var/run/hhvm/hhvm.sock;
}
# SSL
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
@lmartins
lmartins / filter-genesis-structural-wrap.php
Last active August 29, 2015 14:09 — forked from calliaweb/filter-genesis-structural-wrap.php
Add additional content before/after Genesis structural elements
<?php
//* Do NOT include the opening php tag
add_filter( "genesis_structural_wrap-footer-widgets", 'jmw_filter_footer_widgets_structural_wrap', 10, 2);
/**
* Filter the footer-widgets context of the genesis_structural_wrap to add a div before the closing wrap div.
*
* @param string $output The markup to be returned
* @param string $original_output Set to either 'open' or 'close'
*/
@lmartins
lmartins / functions.php
Created November 14, 2014 12:44
Sanitize file names during upload to Wordpress
/**
* Sanitize File name during upload
* http://stackoverflow.com/questions/3259696/rename-files-during-upload-within-wordpress-backend
*/
function make_filename_hash($filename) {
$info = pathinfo($filename);
$ext = empty($info['extension']) ? '' : '.' . $info['extension'];
$name = basename($filename, $ext);
return md5($name) . $ext;
}
<?php remove_action( 'genesis_meta', 'dynamik_responsive_viewport' ); ?>
add_action( 'wp_enqueue_scripts', 'custom_enqueue_scripts' );
/**
* Enqueue an external Custom Javascript file to Dynamik Website Builder
*/
function custom_enqueue_scripts()
{
wp_enqueue_script( 'my-scripts', dynamik_get_stylesheet_location( 'url' ) . 'my-scripts.js', array( 'jquery' ), CHILD_THEME_VERSION, true );
}
@webdev1001
webdev1001 / .bashrc
Last active August 29, 2015 14:09 — forked from tommybutler/.bashrc
# put timestamps in my bash history
export HISTTIMEFORMAT='%F %T '
# don't put duplicate commands into the history
export HISTCONTROL=ignoredups
# record only the most recent duplicated command (see above)
export HISTCONTROL=ignoreboth
# don't record these commands in the history; who cares about ls?