Skip to content

Instantly share code, notes, and snippets.

@danieljwonder
Forked from srikat/functions.php
Created June 25, 2018 02:27
Show Gist options
  • Select an option

  • Save danieljwonder/8ff1bacc21ad547eb8b08793d7e3cc5f to your computer and use it in GitHub Desktop.

Select an option

Save danieljwonder/8ff1bacc21ad547eb8b08793d7e3cc5f to your computer and use it in GitHub Desktop.

Revisions

  1. @srikat srikat revised this gist Jan 4, 2015. 1 changed file with 0 additions and 3 deletions.
    3 changes: 0 additions & 3 deletions functions.php
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,3 @@
    <?php
    //* Do NOT include the opening php tag

    //* Make Font Awesome available
    add_action( 'wp_enqueue_scripts', 'enqueue_font_awesome' );
    function enqueue_font_awesome() {
  2. @srikat srikat revised this gist Jan 3, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion functions.php
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@
    add_action( 'wp_enqueue_scripts', 'enqueue_font_awesome' );
    function enqueue_font_awesome() {

    wp_enqueue_style( 'font-awesome', '//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css' );
    wp_enqueue_style( 'font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css' );

    }

  3. @srikat srikat revised this gist Jan 5, 2014. 1 changed file with 0 additions and 2 deletions.
    2 changes: 0 additions & 2 deletions functions.php
    Original file line number Diff line number Diff line change
    @@ -9,8 +9,6 @@ function enqueue_font_awesome() {

    }

    add_theme_support( 'genesis-connect-woocommerce' );

    /**
    * Place a cart icon with number of items and total cost in the menu bar.
    *
  4. @srikat srikat revised this gist Jan 5, 2014. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions functions.php
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,6 @@
    <?php
    //* Do NOT include the opening php tag

    //* Make Font Awesome available
    add_action( 'wp_enqueue_scripts', 'enqueue_font_awesome' );
    function enqueue_font_awesome() {
  5. @srikat srikat created this gist Jan 5, 2014.
    50 changes: 50 additions & 0 deletions functions.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,50 @@
    //* Make Font Awesome available
    add_action( 'wp_enqueue_scripts', 'enqueue_font_awesome' );
    function enqueue_font_awesome() {

    wp_enqueue_style( 'font-awesome', '//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css' );

    }

    add_theme_support( 'genesis-connect-woocommerce' );

    /**
    * Place a cart icon with number of items and total cost in the menu bar.
    *
    * Source: http://wordpress.org/plugins/woocommerce-menu-bar-cart/
    */
    add_filter('wp_nav_menu_items','sk_wcmenucart', 10, 2);
    function sk_wcmenucart($menu, $args) {

    // Check if WooCommerce is active and add a new item to a menu assigned to Primary Navigation Menu location
    if ( !in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) || 'primary' !== $args->theme_location )
    return $menu;

    ob_start();
    global $woocommerce;
    $viewing_cart = __('View your shopping cart', 'your-theme-slug');
    $start_shopping = __('Start shopping', 'your-theme-slug');
    $cart_url = $woocommerce->cart->get_cart_url();
    $shop_page_url = get_permalink( woocommerce_get_page_id( 'shop' ) );
    $cart_contents_count = $woocommerce->cart->cart_contents_count;
    $cart_contents = sprintf(_n('%d item', '%d items', $cart_contents_count, 'your-theme-slug'), $cart_contents_count);
    $cart_total = $woocommerce->cart->get_cart_total();
    // Uncomment the line below to hide nav menu cart item when there are no items in the cart
    // if ( $cart_contents_count > 0 ) {
    if ($cart_contents_count == 0) {
    $menu_item = '<li class="right"><a class="wcmenucart-contents" href="'. $shop_page_url .'" title="'. $start_shopping .'">';
    } else {
    $menu_item = '<li class="right"><a class="wcmenucart-contents" href="'. $cart_url .'" title="'. $viewing_cart .'">';
    }

    $menu_item .= '<i class="fa fa-shopping-cart"></i> ';

    $menu_item .= $cart_contents.' - '. $cart_total;
    $menu_item .= '</a></li>';
    // Uncomment the line below to hide nav menu cart item when there are no items in the cart
    // }
    echo $menu_item;
    $social = ob_get_clean();
    return $menu . $social;

    }