Skip to content

Instantly share code, notes, and snippets.

View andrezrv's full-sized avatar

Andrés Villarreal andrezrv

View GitHub Profile
@andrezrv
andrezrv / vvv-init-setup-plugins-post.sh
Last active August 29, 2015 13:55
Sample additional tasks for WordPress plugins installed via Peasant.
#!/bin/bash
#
# vvv-init-setup-plugins-post.sh
#
# This file will perform some additional tasks on installed plugins.
# Get Peasant from https://github.com/andrezrv/peasant-vvv-provider.
# Include config file.
this_dir="$(dirname `readlink -f $(dirname $0)/vvv-init.sh`)"
. "${this_dir}/config.sh"
@andrezrv
andrezrv / Vagrantfile.rb
Created February 11, 2014 21:11
Add CPUs to Vagrant VM
config.vm.provider :virtualbox do |v|
v.customize ["modifyvm", :id, "--memory", "3072"]
v.customize ["modifyvm", :id, "--cpus", "4"]
v.customize ["modifyvm", :id, "--ioapic", "on"]
end
@andrezrv
andrezrv / jquery.animate-number.js
Last active August 29, 2015 13:57
A very simple animation for numbers.
jQuery( document ).ready( function( $ ) {
$.fn.animate_number = function( options ) {
options.fromNumber = options.fromNumber ? options.fromNumber : 0;
options.toNumber = options.toNumber ? options.toNumber : 0;
options.rounding = options.rounding ? options.rounding : 0;
options.thousands = options.thousands ? options.thousands : '';
options.decimals = options.decimals ? options.decimals : '.';
options.element = this;
@andrezrv
andrezrv / local-plugins.php
Last active August 29, 2015 13:58
A loader for plugins that should run only in local stages. Have a local-plugins folder containing plugins into wp-content, and a local-config.php called from wp-config.php in your local stage. Then declare the relative path of your local plugins and load them.
<?php
/*
Plugin name: Local Plugins
Description: A loader for plugins that should run only in local stages.
Author: Andrés Villarreal
Author URI: http://about.me/andrezrv
Version: 1.0
License: GPL2
*/
function local_plugins_setup() {
@andrezrv
andrezrv / avoid-wp-mail-when-local.php
Created April 7, 2014 19:40
Avoid sending mails when working locally.
<?php
/**
* Avoid sending mails when working locally.
*/
if ( ! function_exists( 'wp_mail' )
&& defined( 'WP_STAGE' )
&& 'local' == WP_STAGE
&& ( ! defined( 'WP_MAIL_LOCAL' ) || true !== WP_MAIL_LOCAL )
) {
function wp_mail( $to, $subject, $message, $headers = '' ) {
@andrezrv
andrezrv / remove-google-analytics-warning.php
Last active August 29, 2015 13:58
Remove warning from Google Analytics for WordPress in network admin.
<?php
/**
* Remove Google Analytics warning from network admin.
*/
function remove_analytics_warning_from_network_admin() {
if ( is_network_admin() ) {
global $ga_admin;
remove_filter( 'admin_footer', array( $ga_admin, 'warning' ) );
}
}
@andrezrv
andrezrv / blacklist-jetpack-modules.php
Created April 7, 2014 19:50
Disallow Jetpack modules.
<?php
/**
* Blacklist Jetpack modules.
*/
function blacklist_jetpack_modules( $modules ){
$jp_mods_to_disable = array(
'contact-form',
'shortlinks',
);
@andrezrv
andrezrv / auto-activate-jetpack-modules.php
Created April 7, 2014 19:51
Auto activate Jetpack modules.
<?php
/**
* Auto activate Jetpack modules.
*/
function activate_jetpack_modules( $modules ){
$modules = array(
'widget-visibility',
'custom-css',
);
return $modules;
@andrezrv
andrezrv / show-current-stage.php
Last active August 29, 2015 13:58
Show info for current stage in admin toolbar.
<?php
/**
* Show info for current stage in admin toolbar.
*/
function show_current_stage_info( $wp_admin_bar ) {
if ( defined( 'WP_STAGE' ) && WP_STAGE != '%%WP_STAGE%%' ) {
$args = array(
'id' => 'current-stage',
'title' => '<span class="dashicons dashicons-admin-site" style="font-family: \'dashicons\'; font-size: 20px; margin-right: 5px;"></span> Current stage: ' . WP_STAGE,
'meta' => array( 'class' => 'current-stage' ),
@andrezrv
andrezrv / override-cdn-file-extensions.php
Created April 7, 2014 19:57
Limit file extensions to load from CDN when using Stage WP CDN plugin.
<?php
/**
* Limit file extensions to load from CDN.
*/
function override_cdn_file_extensions() {
return array( 'jpe?g', 'gif', 'png', 'bmp' );
}
add_filter( 'stage_wp_cdn_extensions', 'override_cdn_file_extensions' );