Skip to content

Instantly share code, notes, and snippets.

View GarySwift's full-sized avatar

Gary Swift GarySwift

  • Waterford City, Ireland
View GitHub Profile
@GarySwift
GarySwift / README.md
Last active October 22, 2023 14:33
WordPress Testimonials Custom Post Type #cpt #acf

WordPress Testimonials Custom Post Type

Add a custum post type for testimonails in WordPress.

This includes Advanced Custom Fields field groups for some extra fields.

Usage

Create a directory to store all files.

@GarySwift
GarySwift / copy.js
Last active July 24, 2023 12:05
5 ways copy text to clipboard using jQuery (+ JavaScript)
jQuery(document).ready(function($) {
// If a copy clickable input is clicked
// input value will be highlighted and copied to clipboard
$('body').on('click', 'input.js-click-to-copy-input', function(e) {
copy_input( this );
});
// If a button to copy an input is clicked
// associated input value will be highlighted and copied to clipboard
$('body').on('click', 'a.js-click-to-copy-link', function(e) {
@GarySwift
GarySwift / app.js
Last active May 12, 2022 21:14
Cookie Reusable Component in ES6
import { cookies } from './lib/cookies';
import modal from './lib/modal';
$(document).ready(function() {
modal(cookies);
});
@GarySwift
GarySwift / app.js
Created May 12, 2022 21:09
Simple Reusable Components in ES6
import { helloWorld } from './lib/hello-world';
import sayHello from './lib/say-hello';
$(document).ready(function() {
sayHello(helloWorld);
// Hello Friend
});
@GarySwift
GarySwift / _localhost.php
Created March 28, 2017 18:25
Detect if localhost
<?php
/**
* Detect if localhost
*
* @return true if using localhost
*/
function is_localhost() {
$whitelist = array( '127.0.0.1', '::1' );
if( in_array( $_SERVER['REMOTE_ADDR'], $whitelist) ) {
return true;
@GarySwift
GarySwift / _.md
Last active May 14, 2021 07:10
Easily add sass and webpack support for WordPress plugins created using https://wppb.me/.

Add Sass and Webpack Support for WordPress plugins

This is for when you use the WordPress Plugin Boilerplate generator as starter for a WordPress plugin.

This is a way to get Sass set up and have Javascript use module dependency with webpack as the module bundler.

Follow the steps below to get started.

Steps

@GarySwift
GarySwift / list_thumbnail_sizes.php
Last active December 17, 2020 10:25 — forked from twesolowski/list_thumbnail_sizes.php
Wordpress - get all defined thumbnail sizes
<?php
function list_thumbnail_sizes($type = 'all', $name = '') {
global $_wp_additional_image_sizes;
$sizes = array();
$rSizes = array();
foreach (get_intermediate_image_sizes() as $s) {
$sizes[$s] = array(0, 0);
if (in_array($s, array('thumbnail', 'medium', 'large'))) {
$sizes[$s][0] = get_option($s . '_size_w');
$sizes[$s][1] = get_option($s . '_size_h');
@GarySwift
GarySwift / acf-php-to-json.php
Created September 24, 2020 10:53 — forked from ollietreend/acf-php-to-json.php
Convert Advanced Custom Fields Pro configuration from PHP to JSON.
<?php
/**
* Plugin Name: Convert ACF PHP to JSON
* Description: Convert Advanced Custom Fields Pro configuration from PHP to JSON.
*/
namespace ConvertAcfPhpToJson;
/**
* Add submenu item under 'Custom Fields'
@GarySwift
GarySwift / Zurb_Foundation_Color_Palette_Add_Colors.md
Last active July 31, 2020 10:08
Zurb Foundation Color Palette Add Colors

Adding to the Zurb Color Palette

This gist shows how you can add your own custom colors to the Zurb Foundation color palette.

They new colors can then be used to create custom buttons. The color sass variable is also avaliable using the get-color() function.

Reference

http://foundation.zurb.com/sites/docs/button.html

@GarySwift
GarySwift / README.md
Last active June 5, 2020 06:58
Event listener examples for dimsemenov's Magnific Popup. The library can be installed from here https://github.com/dimsemenov/Magnific-Popup. #lightbox #popup

Event listener examples for dimsemenov's Magnific Popup.

The library can be installed from here [https://github.com/dimsemenov/Magnific-Popup].

Updated FOundationPress Zurb 6.4

via Bower bower install magnific-popup --save

WordPress Notes