Skip to content

Instantly share code, notes, and snippets.

View celticwebdesign's full-sized avatar

Darren Stevens celticwebdesign

View GitHub Profile
@celticwebdesign
celticwebdesign / Showing loading animation until iFrame loads
Created January 25, 2017 10:22
This code was used to test for a third-party booking system iframe, upon loading the availability, remove the loading animation and show iframe availability results.
HTML ----
<div class="container well checking" style="max-width:700px">
<h3>We are now searching for your desired availability</h3>
<img src='images/loading.svg' alt='Loading availability' width='120' height='120'>
// loading.svg made at: http://loading.io/
https://code.tutsplus.com/articles/customizing-your-wordpress-admin--wp-24941
http://stackoverflow.com/questions/11298251/swap-array-values-with-php
function custom_menu_order($menu_ord) {
if (!$menu_ord) return true;
$temp = $menu_ord[3];
$menu_ord[3] = $menu_ord[4];
$menu_ord[4] = $temp;
@celticwebdesign
celticwebdesign / WordPress - Woocommerce tracking code
Created March 7, 2017 11:47
Add Woocommerce products tracking code before main Google Analytics code in header.php
header.php
<?php
if ( is_checkout() && ! empty( $wp->query_vars['order-received'] ) ) {
// echo $wp->query_vars['order-received'];
// Lets grab the order
$order = wc_get_order( $wp->query_vars['order-received'] );
// http://www.wpbeginner.com/wp-tutorials/how-to-use-shortcodes-in-your-wordpress-sidebar-widgets/
add_filter('widget_text','do_shortcode');
add_shortcode('shortcode_find_restaurant', 'shortcode_find_restaurant');
function shortcode_find_restaurant() {
$terms = get_terms( array(
'taxonomy' => 'towns-restaurant',
'hide_empty' => false,
add_shortcode('shortcode_find_takeaway', 'shortcode_find_takeaway');
function shortcode_find_takeaway() {
$terms = get_terms( array(
'taxonomy' => 'towns-takeaway',
'hide_empty' => false,
) );
if ( $terms && ! is_wp_error( $terms ) ) :
add_shortcode('shortcode_find_accommodation', 'shortcode_find_accommodation');
function shortcode_find_accommodation() {
$terms = get_terms( array(
'taxonomy' => 'towns-accommodation',
'hide_empty' => false,
) );
if ( $terms && ! is_wp_error( $terms ) ) :
// http://www.wpbeginner.com/wp-tutorials/how-to-create-a-custom-wordpress-widget/
//
// Select a Restaurant
class eoc_widget_select_restaurant extends WP_Widget {
function __construct() {
parent::__construct(
// Base ID of your widget
'eoc_widget_select_restaurant',
@celticwebdesign
celticwebdesign / PHP - WordPress - JSON encode
Created March 24, 2017 13:52
PHP encoding an array or arrays into JSON for JS Slideshow plugin.
function get_pop_up($ID) {
$rows_fss = get_field('slideshow_repeater',$ID);
$output = "";
if($rows_fss) {
$output .= "<div id='inline1' style='display: none;'>";
<?php
$local_folder = get_field('video_folder');
$path = "/var/sites/k/XXX.co.uk/public_html/Videos/top-video-folder/".$local_folder;
$files = scandir($path);
foreach ($files as &$value) {
if ($value != "." && $value != "..") {
@celticwebdesign
celticwebdesign / content-product.php
Last active April 3, 2024 12:12 — forked from croosen/content-product.php
WooCommerce - Display custom attributes on shop page - including attribute thumbnails
<?php
// this gist requires: http://candlestudio.net/woocommerce/plugins/button-variations/
// a fork of: https://gist.github.com/croosen/24a2845f91ce91a2819b
// WooCommerce - Display custom attributes on shop page - the official way ;-)
global $wc_ea_term_meta;
// Get the attributes