Skip to content

Instantly share code, notes, and snippets.

View bahiirwa's full-sized avatar
🏠
Working from home

Laurence Bahiirwa bahiirwa

🏠
Working from home
View GitHub Profile
@bahiirwa
bahiirwa / wp-update-url.sql
Created October 11, 2016 07:24 — forked from jpederson/wp-update-url.sql
This sql file will update the URLs in all relevant WordPress tables when you move a site form one domain to another. Simply change the variables at the top to your URLs and execute it.
SET @wp_url_old = 'http://oldurl.com', @wp_url_new = 'http://newurl.com';
UPDATE wp_options SET option_value = replace( option_value, @wp_url_old, @wp_url_new )
WHERE option_value LIKE CONCAT( '%', @wp_url_old, '%' );
UPDATE wp_posts SET guid = replace( guid, @wp_url_old, @wp_url_new );
UPDATE wp_posts SET post_content = replace( post_content, @wp_url_old, @wp_url_new );
UPDATE wp_postmeta SET meta_value = replace( meta_value, @wp_url_old, @wp_url_new );
@bahiirwa
bahiirwa / functions.php
Created October 19, 2016 11:17 — forked from srikat/functions.php
Adding a cart icon with number of items and total cost in nav menu when using WooCommerce. http://sridharkatakam.com/adding-cart-icon-number-items-total-cost-nav-menu-using-woocommerce/
//* Make Font Awesome available
add_action( 'wp_enqueue_scripts', 'enqueue_font_awesome' );
function enqueue_font_awesome() {
wp_enqueue_style( 'font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css' );
}
/**
* Place a cart icon with number of items and total cost in the menu bar.
@bahiirwa
bahiirwa / gist:8d5de040e62ca72598260766643c570d
Created October 28, 2016 17:14 — forked from mikejolley/gist:6713608
WooCommerce Shipping Method Skeleton Plugin
<?php
/*
Plugin Name: Your Shipping plugin
Plugin URI: http://woothemes.com/woocommerce
Description: Your shipping method plugin
Version: 1.0.0
Author: WooThemes
Author URI: http://woothemes.com
*/
@bahiirwa
bahiirwa / functions.php
Created November 1, 2016 09:08 — forked from WooForce/functions.php
Rearrange shipping methods
add_filter('woocommerce_package_rates', 'wf_sort_shipping_methods', 10, 2);
function wf_sort_shipping_methods($available_shipping_methods, $package)
{
// Arrange shipping methods as per your requirement
$sort_order = array(
'wf_shipping_ups' => array(),
'wf_shipping_usps' => array(),
'free_shipping' => array(),
'local_pickup' => array(),
@bahiirwa
bahiirwa / action.php
Created November 27, 2016 01:10 — forked from danielpataki/action.php
WordPress Emails
function set_mail_html_content_type() {
return 'text/html';
}
add_action( 'publish_post', 'author_publish_notice', 10 ,2 );
function author_publish_notice( $ID, $post ) {
if( 'post' == $post->post_type ) {
return;
}
@bahiirwa
bahiirwa / README.md
Created April 12, 2017 16:47 — forked from fnichol/README.md
Download a cacert.pem for RailsInstaller

Why?

There is a long standing issue in Ruby where the net/http library by default does not check the validity of an SSL certificate during a TLS handshake. Rather than deal with the underlying problem (a missing certificate authority, a self-signed certificate, etc.) one tends to see bad hacks everywhere. This can lead to problems down the road.

From what I can see the OpenSSL library that Rails Installer delivers has no certificate authorities defined. So, let's go fetch some from the curl website. And since this is for ruby, why don't we download and install the file with a ruby script?

Installation

The Ruby Way! (Fun)

@bahiirwa
bahiirwa / Default Taxonomy Term for CPT
Created August 5, 2017 05:31 — forked from mayeenulislam/Default Taxonomy Term for CPT
Make Default taxonomy term for Custom Post Type - WordPress
/**
* Author: Michael Fields
* Source: http://wordpress.mfields.org/2010/set-default-terms-for-your-custom-taxonomies-in-wordpress-3-0/
* Thanks a lot for the nice tweak
*/
/**
* Define default terms for custom taxonomies in WordPress 3.0.1
*
@bahiirwa
bahiirwa / page-metabox.php
Created August 25, 2017 11:02 — forked from dingo-d/page-metabox.php
A page metabox with a color picker option
<?php
add_action( 'admin_enqueue_scripts', 'mytheme_backend_scripts');
if ( ! function_exists( 'mytheme_backend_scripts' ) ){
function mytheme_backend_scripts($hook) {
wp_enqueue_media();
wp_enqueue_style( 'wp-color-picker');
wp_enqueue_script( 'wp-color-picker');
}
@bahiirwa
bahiirwa / functions.php
Created November 24, 2017 22:33 — forked from mikejolley/functions.php
WooCommerce - Hide shipping rates when free shipping is available.
<?php
/**
* Hide shipping rates when free shipping is available.
* Updated to support WooCommerce 2.6 Shipping Zones.
*
* @param array $rates Array of rates found for the package.
* @return array
*/
function my_hide_shipping_when_free_is_available( $rates ) {
$free = array();
@bahiirwa
bahiirwa / functions.php
Created December 5, 2017 07:05 — forked from om4james/functions.php
Display product description on WooCommerce shop/category pages
<?php
/**
* Add the product's short description (excerpt) to the WooCommerce shop/category pages. The description displays after the product's name, but before the product's price.
*
* Ref: https://gist.github.com/om4james/9883140
*
* Put this snippet into a child theme's functions.php file
*/
function woocommerce_after_shop_loop_item_title_short_description() {
global $product;