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 / README.md
Created April 17, 2018 09:49 — forked from ericclemmons/README.md
Hot take on Zach Silveira's Gutenblock Demo!
@bahiirwa
bahiirwa / block-template.php
Created March 9, 2018 11:26 — forked from zgordon/block-template.php
Example of how to add block templates to post types in WordPress
<?php
function mytheme_block_templates( $args, $post_type ) {
// Only add template to 'post' post type
// Change for your post type: eg 'page', 'event', 'product'
if ( 'post' == $post_type ) {
// Optionally lock templates from further changes
// Change to 'insert' to allow adding other blocks, but lock defined blocks
@bahiirwa
bahiirwa / wc-prevent-checkout-for-cart-with-specific-category.php
Created January 30, 2018 07:23 — forked from bekarice/wc-prevent-checkout-for-cart-with-specific-category.php
Prevents checkout if the WooCommerce cart only contains items from a specific category
<?php // only copy this line if needed
/**
* Renders a notice and prevents checkout if the cart
* only contains products in a specific category
*/
function sv_wc_prevent_checkout_for_category() {
// set the slug of the category for which we disallow checkout
$category = 'clothing';
@bahiirwa
bahiirwa / AdminPage.php
Created December 25, 2017 17:31 — forked from carlalexander/AdminPage.php
WordPress and the single responsibility principle
<?php
/**
* The WordPress Meme Shortcode admin page.
*
* @author Carl Alexander
*/
class WPMemeShortcode_AdminPage
{
/**
@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;
@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 / 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 / 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 / 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 / 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;
}