Skip to content

Instantly share code, notes, and snippets.

@lmartins
lmartins / front-page.php
Created October 8, 2014 08:44
WooCommerce custom loop for Featured Products
<?php
$args = array(
'post_type' => 'product',
'meta_key' => '_featured',
'meta_value' => 'yes',
'posts_per_page' => 6
);
$featured_query = new WP_Query( $args );
if ($featured_query->have_posts()) :
?>
@lmartins
lmartins / loops.php
Created October 17, 2014 13:57
Change Add to Cart to Read More
add_filter( 'woocommerce_loop_add_to_cart_link', 'mw_change_add_to_cart_loop' );
function mw_change_add_to_cart_loop( $product ) {
global $product; // this may not be necessary as it should have pulled the object in already
return '<a class="button" href="' . esc_url( $product->get_permalink( $product->id ) ) . '">DETALHES</a>';
}
@julionc
julionc / ruby_setup.md
Last active August 18, 2017 15:24
Deploy Ruby On Rails on Ubuntu 14.04

Deploy Ruby On Rails on Ubuntu 14.04

Server: Nginx with Phusion Passenger

Ruby Version: 2.1.3

User System: deploy

User System

@lmartins
lmartins / functions.php
Created October 29, 2014 12:29
Add menu items programatically
add_filter( 'genesis_nav_items', 'be_follow_icons', 10, 2 );
add_filter( 'wp_nav_menu_items', 'be_follow_icons', 10, 2 );
/**
* Follow Icons in Menu
* @author Bill Erickson
* @link http://www.billerickson.net/genesis-wordpress-nav-menu-content/
*
* @param string $menu
* @param array $args
* @return string
user www-data;
worker_processes auto;
worker_rlimit_nofile 100000;
pid /run/nginx.pid;
events {
worker_connections 10240;
# multi_accept on;
}
@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?
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 );
}
<?php remove_action( 'genesis_meta', 'dynamik_responsive_viewport' ); ?>
@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;
}
@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'
*/