Skip to content

Instantly share code, notes, and snippets.

View utopianfool's full-sized avatar

Philip Porter utopianfool

View GitHub Profile
@utopianfool
utopianfool / woocommerce-change-no-shipping-message.php
Created November 3, 2020 11:40
Woocommerce change no shipping message in cart and checkout
<?php
/**
* Change shipping message in cart and checkout
*/
add_filter( 'woocommerce_no_shipping_available_html', 'littleargentina_no_shipping_message' );
add_filter( 'woocommerce_cart_no_shipping_available_html', 'littleargentina_no_shipping_message' );
function littleargentina_no_shipping_message( $message ) {
return __( 'We only ship to the UK. Please select "Deliver to a different address" if you are purchasing from outside the UK' );
}
?>
@utopianfool
utopianfool / convert-2-to-4-spaces-sublime-text.md
Created October 9, 2020 10:13
Convert 2 space indentation tabs into 4 in Sublime Text 2 or 3

Here's a neat trick in Sublime Text 2 or 3 to convert your indentation spacing in a document.

TL;DR:

Converting from 2 spaces to 4 spaces:

Ensure tab width is set to 2. Convert your 2-space indentation to tabs, switch to tab width 4, and then convert the indentation back to spaces.

The detailed description:

@utopianfool
utopianfool / cp.shouldstopexecution.js
Created October 9, 2020 08:45
Fix window.CP.shouldStopExecution used in some codepen scripts to prevent infinite loops - unminified
"use strict";
"object" != typeof window.CP && (window.CP = {}), window.CP.PenTimer = {
programNoLongerBeingMonitored: !1,
timeOfFirstCallToShouldStopLoop: 0,
_loopExits: {},
_loopTimers: {},
START_MONITORING_AFTER: 2e3,
STOP_ALL_MONITORING_TIMEOUT: 5e3,
MAX_TIME_IN_LOOP_WO_EXIT: 2200,
exitedLoop: function(o) {
@utopianfool
utopianfool / cp.shouldstopexecution.min.js
Created October 9, 2020 08:44
Fix window.CP.shouldStopExecution used in some codepen scripts to prevent infinite loops
"use strict";"object"!=typeof window.CP&&(window.CP={}),window.CP.PenTimer={programNoLongerBeingMonitored:!1,timeOfFirstCallToShouldStopLoop:0,_loopExits:{},_loopTimers:{},START_MONITORING_AFTER:2e3,STOP_ALL_MONITORING_TIMEOUT:5e3,MAX_TIME_IN_LOOP_WO_EXIT:2200,exitedLoop:function(o){this._loopExits[o]=!0},shouldStopLoop:function(o){if(this.programKilledSoStopMonitoring)return!0;if(this.programNoLongerBeingMonitored)return!1;if(this._loopExits[o])return!1;var t=this._getTime();if(0===this.timeOfFirstCallToShouldStopLoop)return this.timeOfFirstCallToShouldStopLoop=t,!1;var i=t-this.timeOfFirstCallToShouldStopLoop;if(i<this.START_MONITORING_AFTER)return!1;if(i>this.STOP_ALL_MONITORING_TIMEOUT)return this.programNoLongerBeingMonitored=!0,!1;try{this._checkOnInfiniteLoop(o,t)}catch(o){return this._sendErrorMessageToEditor(),this.programKilledSoStopMonitoring=!0,!0}return!1},_sendErrorMessageToEditor:function(){try{if(this._shouldPostMessage()){var o={action:"infinite-loop",line:this._findAroundLineNumber()};parent
@utopianfool
utopianfool / extra-wow-animations.scss
Created September 22, 2020 08:01
Extra wow animations in SCSS
/* WOW animations */
.animated {
-webkit-animation-duration: 1s;
animation-duration: 1s;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
}
.animated.hinge {
@utopianfool
utopianfool / wordpress-template-custom-isotope.php
Created September 22, 2020 06:29
The template for displaying cpt with isotope, bootstrap 4 and acf
<?php
/**
* The template for displaying cpt with isotope, bootstrap 4 and acf
* Template Name: Custom Isotope
*
* @package wordpress
*/
get_header();
?>
@utopianfool
utopianfool / worpress-custom-login-logo.php
Created September 22, 2020 06:06
WordPress Custom Login Logo Function
<?php
/**
* Add custom logo to login
*/
function custom_login_logo() { ?>
<style type="text/css">
#login h1 a, .login h1 a {
background-image: url(<?php echo get_stylesheet_directory_uri(); ?>/images/login-logo.png);
height:65px;
width:320px;
@utopianfool
utopianfool / accordion-wordpress-bootstrap-acf.html
Created September 22, 2020 05:34
Accordions in 2 column WordPress Bootstrap ACF Example
<section class="content-section">
<div class="container">
<div class="row justify-content-center py-3">
<div class="col-12 col-md-6 mb-3 pb-3">
<?php the_field('left_column_content'); ?>
<div class="accordion" id="fact-accordion">
<?php if( have_rows('accordion') ): ?>
@utopianfool
utopianfool / ekko-lightbox-jquery-example.js
Created September 22, 2020 05:24
Ekko Lightbox for Bootstrap and WordPress Example jQuery
jQuery(function($){
// Ekko lightbox attribute data-toggle to gallery links
$('.gallery-item').find('a').attr('data-toggle', 'lightbox');
$('.gallery-item').find('a').attr('data-gallery', 'gallery');
$('.gallery-item').find('a').attr('data-type', 'image');
// enable ekko lightbox on page
$(document).on('click', '[data-toggle="lightbox"]', function(event) {
event.preventDefault();
$(this).ekkoLightbox({
@utopianfool
utopianfool / ekko-lightbox-gallery-example.scss
Created September 22, 2020 05:19
Ekko Lightbox for Bootstrap and WordPress Example SCSS