Skip to content

Instantly share code, notes, and snippets.

View garykay's full-sized avatar

Gary Readhead garykay

  • Poole, United Kingdom
  • 05:37 (UTC +01:00)
View GitHub Profile
@garykay
garykay / functions.php
Created April 8, 2020 08:03
Functions
<?php
function hello_world() {
return 'Hellow World';
}
?>
@garykay
garykay / vuejs-php.md
Created November 22, 2017 09:30
VueJs and PHP

VueJs and PHP

Setup

First test

@garykay
garykay / Using Git to Manage a Live Web Site.md
Created November 15, 2017 04:47 — forked from Nilpo/Using Git to Manage a Live Web Site.md
Using Git to Manage a Live Web Site

Using Git to Manage a Live Web Site

###Overview

As a freelancer, I build a lot of web sites. That's a lot of code changes to track. Thankfully, a Git-enabled workflow with proper branching makes short work of project tracking. I can easily see development features in branches as well as a snapshot of the sites' production code. A nice addition to that workflow is that ability to use Git to push updates to any of the various sites I work on while committing changes.

####Contents

@garykay
garykay / functions.php
Created July 17, 2017 07:36 — forked from galengidman/functions.php
Check if WooCommerce cart has items, add link to have if it does
<?php
function my_nav_wrap() {
// checks if there is an item in the cart
// returns default items + cart link if there is
// returns default items if the cart is empty
if (sizeof(WC()->cart->get_cart()) != 0) {
$wrap = '<ul id="%1$s" class="%2$s">';
<?php
/*
Plugin Name: Videos
Plugin URI:
Author: Dave Rupert
Author URI: http://www.daverupert.com
Description: A custom post type that adds videos and custom taxonomies.
Version: 1.0
*/
/*
* From css-tricks.com
* http://css-tricks.com/snippets/css/media-queries-for-standard-devices/
*/
/* Smartphones (portrait and landscape) ----------- */
@media only screen
and (min-device-width : 320px)
and (max-device-width : 480px) {
/* Styles */
remove_action( 'woocommerce_after_single_product', 'woocommerce_upsell_display');
add_action( 'woocommerce_after_single_product', 'woocommerce_output_upsells', 20);
if (!function_exists('woocommerce_output_upsells')) {
function woocommerce_output_upsells() {
woocommerce_upsell_display(3,3); // Display 3 products in rows of 3
}
}

Targeting Nexus 7 2012 & 2013

Media Query Differences

Demo here


@media only screen and (min-device-width: 800px) and (orientation: portrait) {
#device:after {
content: "Nexus 7 - portrait - firefox";
}
}
@media screen and (min-device-width : 602px) and (orientation: portrait) {
#device:after {
content: "Nexus 7 - portrait - chrome";
}
}
/**
* This code should be added to functions.php of your theme
**/
add_filter('woocommerce_default_catalog_orderby', 'custom_default_catalog_orderby');
function custom_default_catalog_orderby() {
return 'date'; // Can also use title and price
}