Skip to content

Instantly share code, notes, and snippets.

View nairnwebdesign's full-sized avatar

nairnwebdesign

View GitHub Profile
@nairnwebdesign
nairnwebdesign / hide-jetpack-from-non-admin.php
Created December 30, 2013 13:43
Hide JetPack from WordPress users who aren't administrators.
add_action( 'jetpack_admin_menu', 'hide_jetpack_from_others' );
function hide_jetpack_from_others() {
if ( ! current_user_can( 'administrator' ) ) {
remove_menu_page( 'jetpack' );
}
}
@nairnwebdesign
nairnwebdesign / remove-woocommerce-breadcrumbs.php
Created December 30, 2013 10:42
Remove WooCommerce Breadcrumbs
remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0 );
@nairnwebdesign
nairnwebdesign / remove-product-tabs.php
Created December 28, 2013 14:55
Remove the description, reviews and additional information tabs from WooCommerce product page.
/**
* Remove product tabs
*
*/
function woo_remove_product_tab($tabs) {
unset( $tabs['description'] ); // Remove the description tab
unset( $tabs['reviews'] ); // Remove the reviews tab
unset( $tabs['additional_information'] ); // Remove the additional information tab
@nairnwebdesign
nairnwebdesign / remove-wp-admin-bar.php
Created December 28, 2013 08:21
Remove the WordPress toolbar from the top of the screen, unless user is an Administrator.
add_action('after_setup_theme', 'remove_admin_bar');
function remove_admin_bar() {
if (!current_user_can('administrator') && !is_admin()) {
show_admin_bar(false);
}
}
@nairnwebdesign
nairnwebdesign / genesis-post-titles.php
Created December 28, 2013 07:35
Changing Genesis H1 Post Titles to H2
/*
Changing Genesis H1 Post Titles to H2
*/
add_filter( 'genesis_post_title_output', 'ac_post_title_output', 15 );
function ac_post_title_output( $title )
{ if ( is_home() || is_archive() )
$title = sprintf( '<h1 class="entry-title"><a href="' . get_permalink() . '">%s</a></h1>', apply_filters( 'genesis_post_title_text',get_the_title() ) );
return $title;
@nairnwebdesign
nairnwebdesign / embed-gists.php
Created December 27, 2013 21:03
Paste the following code into your functions.php file to embed Gists with only their URL.
/**
* Embed Gists with a URL
*
* Usage:
* Paste a gist link into a blog post or page and it will be embedded eg:
* https://gist.github.com/2926827
*
* If a gist has multiple files you can select one using a url in the following format:
* https://gist.github.com/2926827?file=embed-gist.php
*/
add_action( 'woocommerce_checkout_process', 'wc_minimum_order_amount' );
function wc_minimum_order_amount() {
global $woocommerce;
$minimum = 50;
if ( $woocommerce->cart->get_cart_total() < $minimum ) {
$woocommerce->add_error( sprintf( 'You must have an order with a minimum of %s to place your order.' , $minimum ) );
}
}