Skip to content

Instantly share code, notes, and snippets.

View jamestrevorlees's full-sized avatar

James Lees jamestrevorlees

  • Advantage Learn + Pango
  • Durban, South Africa
View GitHub Profile
@jamestrevorlees
jamestrevorlees / order_has_trial.php
Created May 8, 2019 02:41 — forked from chrisvanpatten/order_has_trial.php
Function to check if a WooCommerce order contains a free trial (via the Subscriptions extension)
<?php
/**
* Loop through an order's items and see if there's a free trial set
*
* @param WC_Order $order
* @return bool|WP_Error
*/
function custom_order_has_trial( $order ) {
if ( ! $order instanceof WC_Order )
@jamestrevorlees
jamestrevorlees / gist:ab17a1a172d0e488097ab8a81820bcf2
Created April 4, 2018 12:23 — forked from minio/gist:6982551
query to get all posts and associated categories from Wordpress database
$all_posts = $wpdb->get_results("
SELECT wp_posts.ID,wp_posts.post_date,wp_posts.post_title,wp_posts.post_name,
wp_terms.name,wp_terms.slug,wp_term_taxonomy.description
from wp_posts
join wp_term_relationships on wp_posts.ID = wp_term_relationships.object_id
join wp_terms on wp_term_relationships.term_taxonomy_id = wp_terms.term_id
join wp_term_taxonomy on wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id
WHERE wp_posts.post_status = 'publish'
ORDER BY wp_terms.slug,wp_posts.ID;
", ARRAY_A);
@jamestrevorlees
jamestrevorlees / Wordpress Bootstrap 3 nav.php
Created November 10, 2017 15:01 — forked from jfitzsimmons2/Wordpress Bootstrap 3 nav.php
How to structure your WP <nav> tag using wp_nav_menu to use Bootstrap 3's navbar. Note this is specifically for the "fixed top" version of the navbar (http://getbootstrap.com/components/#navbar-fixed-top). Also only works for single-level navs. If there are sub-menus, additional tweaking is needed.
<nav id="site-navigation" class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#main-navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#"><?php bloginfo( 'name' ); ?></a>
@jamestrevorlees
jamestrevorlees / country-shortcode.php
Created November 10, 2017 14:09 — forked from MatthewEppelsheimer/country-shortcode.php
WP Contact Form 7 shortcode with list of Countries
<?php
/*
UPDATED: December 31, 2011.
Modifications:
- Truncated the longest country names, including:
-- British Indian Ocean Territories (Chagos Archipelago) -> British Indian Ocean Territories
-- South Georgia and the South Sandhich Islands -> South Georgia & S. Sandwich Islands