Skip to content

Instantly share code, notes, and snippets.

View munts's full-sized avatar

Scott Taylor munts

  • confluence web solutions
  • Colorado
View GitHub Profile
//Creating Custom Post types for Team
function setup_team_cpt(){
$labels = array(
'name' => _x('team', 'post type general name'),
'singular_name' => _x('team', 'post type singular name'),
'add_new' => _x('Add New', 'Team'),
'add_new_item' => __('Add New Team'),
'edit_item' => __('Edit Team'),
'new_item' => __('New Team'),
'all_items' => __('All Team'),
function disable_wp_emojicons() {
// all actions related to emojis
remove_action( 'admin_print_styles', 'print_emoji_styles' );
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
remove_action( 'wp_print_styles', 'print_emoji_styles' );
remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );
remove_filter( 'the_content_feed', 'wp_staticize_emoji' );
remove_filter( 'comment_text_rss', 'wp_staticize_emoji' );
//Trm excerpt
function berglund_trim_excerpt($length) {
global $post;
$explicit_excerpt = $post->post_excerpt;
if ('' == $explicit_excerpt) {
$text = get_the_content('');
$text = apply_filters('the_content', $text);
$text = str_replace(']]>', ']]>', $text);
} else {
$text = apply_filters('the_content', $explicit_excerpt);
//Creating Custom Post types for work
function setup_work_cpt(){
$labels = array(
'name' => _x('work', 'post type general name'),
'singular_name' => _x('work', 'post type singular name'),
'add_new' => _x('Add New', 'work'),
'add_new_item' => __('Add New work'),
'edit_item' => __('Edit work'),
'new_item' => __('New work'),
'all_items' => __('All work'),
function theme_setup() {
add_theme_support('post-thumbnails'); // adds thumbnail support for the pages, posts and Projects CPT
add_image_size('work_cat_thumb', 800, 500, true);
add_image_size('post_thumbnail', 600, 250, true);
add_image_size('post_thumbnail_1', 70, 70, true);
// Register menus
register_nav_menus(array(
/**
* Including all required style files in the theme
*/
function theme_styles() {
wp_register_style('bootstrap', get_template_directory_uri() . '/assets/css/bootstrap.css', array(), '1', 'all' );
wp_register_style('font-awesome.min', get_template_directory_uri() .'/assets/css/font-awesome.css', array(), null, 'all' );
wp_register_style('simple-line-icons', get_template_directory_uri() .'/assets/css/simple-line-icons.css', array(), null, 'all' );
wp_register_style('elegant-icons', get_template_directory_uri() .'/assets/css/elegant-icons.css', array(), null, 'all' );
wp_register_style('animate', get_template_directory_uri() .'/assets/css/animate.min.css', array(), null, 'all' );
wp_register_style('animsition', get_template_directory_uri() .'/assets/css/animsition.min.css', array(), null, 'all' );
@munts
munts / .gitignore
Created May 18, 2018 21:49 — forked from salcode/.gitignore
See https://salferrarello.com/wordpress-gitignore/ for the latest version of my WordPress .gitignore file
# -----------------------------------------------------------------
# .gitignore for WordPress
# Bare Minimum Git
# http://ironco.de/bare-minimum-git/
# ver 20150227
#
# This file is tailored for a WordPress project
# using the default directory structure
#
# This file specifies intentionally untracked files to ignore
@munts
munts / functions.php
Last active August 26, 2020 19:26
Remove Flat Rate Shipping in WooCommerce if Customer Qualifies for Free Shipping with cart total greater than specific amount
/* Change shipping based on cart total and if they they qualify for free shipping */
add_filter( 'woocommerce_package_rates', 'hide_flat_rate_if_cart_total_is_greater_than_threshold', 5, 1 );
function hide_flat_rate_if_cart_total_is_greater_than_threshold( $rates ) {
$threshold1 = 249;
$amount = WC()->cart->cart_contents_total;
if ( $amount > $threshold1 ) {
unset( $rates['flat_rate:5'] );
}
return $rates;
}
@munts
munts / functions.php
Last active August 26, 2020 19:33
Hide WooCommerce shipping options when free shipping is available. Ie. hide Flat Rate.
add_filter( 'woocommerce_package_rates', 'hide_shipping_when_free_is_available', 100 );
function hide_shipping_when_free_is_available( $rates ) {
$free = array();
foreach ( $rates as $rate_id => $rate ) {
if ( 'free_shipping' === $rate->method_id ) {
$free[ $rate_id ] = $rate;
break;
}
}
return ! empty( $free ) ? $free : $rates;