Skip to content

Instantly share code, notes, and snippets.

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

Jasper Frumau jasperf

🏠
Working from home
View GitHub Profile
@jasperf
jasperf / add_wp_nav_menu_item.php
Last active February 3, 2017 11:12
WordPress code snippet to add LeadPages code at the end of navigation menu
add_filter( 'wp_nav_menu_items', function( $items, $args ) {
// Only used for the main menu
if ( 'main_menu' != $args->theme_location ) {
return $items;
}
// Add your custom item
$items .= '<li class="my-custom-menu-item">' . '<div style="width:350px;height:50px;"><div style="float:left;"><p style="font-weight: bold;">Coupon For 10% Off 1 Product, </p><p style="font-weight: bold;">15% Off 2 Or More? </p></div><a href="https://my.leadpages.net/leadbox/numbers/numbers/" target="_blank" style="color: rgb(0, 0, 0); text-decoration: none; font-family: Helvetica, Arial, sans-serif; font-weight: bold; font-size: 16px; line-height: 20px; padding: 10px; display: inline-block; max-width: 300px; border-radius: 5px; text-shadow: rgba(0, 0, 0, 0.247059) 0px -1px 1px; box-shadow: rgba(255, 255, 255, 0.498039) 0px 1px 3px inset, rgba(0, 0, 0, 0.498039) 0px 1px 3px; background: rgb(255, 221, 43);">Hell Yeah!</a></div><script data-leadbox="147764973f72a2:12a443817b46dc
add_filter( 'wp_nav_menu_items', function( $items, $args ) {
// Only used for the main menu
if ( 'main_menu' != $args->theme_location ) {
return $items;
}
// Add your custom item
$items .= '<li class="my-custom-menu-item">' . YOUR CUSTOM ITEM TEXT . '</li>';
<?php get_template_part('templates/content', 'store');
/**
*
* https://roots.io/using-woocommerce-with-sage/
*
* woocommerce_before_main_content hook.
*
* @hooked woocommerce_output_content_wrapper - 10 (outputs opening divs for the content)
* @hooked woocommerce_breadcrumb - 20
*/
<?php
/**
* The Template for displaying products in a product category. Simply includes the archive template
*
* This template can be overridden by copying it to yourtheme/woocommerce/taxonomy-product_cat.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you
* (the theme developer) will need to copy the new files to your theme to
* maintain compatibility. We try to do this as little as possible, but it does
* happen. When this occurs the version of the template file will be bumped and
@jasperf
jasperf / gist:521ae5a2da705138737cdbc24c3e4b10
Created December 16, 2016 04:41 — forked from mikejolley/gist:2176823
WooCommerce - Show products from current product category (when viewing a single product)
<?php
if ( is_singular('product') ) {
global $post;
// get categories
$terms = wp_get_post_terms( $post->ID, 'product_cat' );
foreach ( $terms as $term ) $cats_array[] = $term->term_id;
@jasperf
jasperf / extras.php
Created October 29, 2016 04:06
Add CMB2 to the Roots Sage Starters Theme (Ianua Implementation so do change function names and paths accordingly) #sage #roots #wordpress
<?php
/**
* Get the CMB2 bootstrap! If using the plugin from wordpress.org, REMOVE THIS!
*/
if ( file_exists( get_stylesheet_directory() . '/cmb2/init.php') ) {
require_once get_stylesheet_directory() . '/cmb2/init.php';
} elseif ( file_exists( get_stylesheet_directory() . '/CMB2/init.php' ) ) {
require_once get_stylesheet_directory() . '/CMB2/init.php';
}
@jasperf
jasperf / Trellis setup
Last active February 22, 2018 22:25 — forked from tobyl/Trellis setup
Bash script to setup Bedrock, Trellis and Sage #Roots
#!/bin/bash
# set this variable - it will be used as both the root folder name and the theme name for sage
# no spaces - should not be a URL - I'm using 'my-site' or similar
SITENAME="your-site-name"
# Add BitBucket username/password to have a remote repo setup
BBUSER="YOUR-BB-USERNAME"
BBPASS="YOUR-BB-PASSWORD"
@jasperf
jasperf / woocommerce-sage-template-part-overrides.md
Created September 4, 2016 12:12 — forked from drawcard/woocommerce-sage-template-part-overrides.md
Woocommerce - Using template part overrides in Sage

So, you know how to override a template file in Woocommerce using Sage, but you're having trouble changing something within the deeper level of that template file. For example, you want to change the output HTML structure of a given part of the product page loop, or incorporate a Bootstrap class into a button element without using Jquery to inject it. Here's how you can override deeper level parts, the default WC theme elements.

Prerequisites

Now you're familiar with how to do Sage + Woocommerce templates, it's time to make it happen.

The template page override

@jasperf
jasperf / ubuntu-xenial-remove-amp.sh
Created August 30, 2016 04:41
Remove Apache, MySQL and PHP 7 on Ubuntu Xenial #php #ubuntu #lamp
sudo apt remove apache2 apache2-bin apache2-data apache2-utils libapache2-mod-php libapache2-mod-php7.0 php7.0-mysql php7.0-opcache php7.0-readline mysql-client-5.7 mysql-client-core-5.7 mysql-common mysql-server mysql-server-5.7 mysql-server-core-5.7 php-mysql php7.0-mysql php-common php-mysql php7.0-cli php7.0-common php7.0-json
@jasperf
jasperf / mysql-connection-test.php
Created August 10, 2016 05:46
Testing MySQL connection #mysql
<?php
//http://jason.pureconcepts.net/2013/04/common-debugging-php-mysql/
$link = mysqli_connect('localhost', 'my_user', 'my_password', 'my_db');
if (!$link) {
die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error());
}
echo 'Connected... ' . mysqli_get_host_info($link) . "\n";