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 / __page-cpt.php
Last active February 27, 2018 09:07
WordPress Template: CPT, custom post type loop (To use with FoundationPress theme)
<?php
/**
* Template Name: Custom Post
*
* @package FoundationPress
* @since FoundationPress 1.0.0
*/
get_header();
wp_reset_query();
@GarySwift
GarySwift / Change_Default_WordPress_Uploads_Folder.md
Last active April 27, 2017 08:42
WordPress: Change the Default WordPress Uploads Folder (to assets)

Change the Default WordPress Uploads Folder

Open your wp-config.php file, located at the root of your WordPress installation, and add the snippet below.

Make sure you add this code after the line:

'/* That's all, stop editing! Happy blogging. */'

Make sure you add this code before the line:

@GarySwift
GarySwift / _featured-image.php
Last active August 16, 2017 11:29
WordPress Featured Image Helper
@GarySwift
GarySwift / header.scss
Created April 5, 2017 13:01
SASS: Target All H Tags in Loop
@for $index from 1 through 6 {
h#{$index}{
margin: 0;
}
}
@GarySwift
GarySwift / _colors.scss
Created April 1, 2017 09:24
Sass Nested Color Palette: An example of how to how to use nested color palettes in sass.
// Color Palettes
$kilflam-colors: (
'primary': #E10001,
'secondary': #FE9800
);
$guardian-colors: (
'primary': #004A9D,
'secondary': #0099F2
);
$fumeguard-colors: (
@GarySwift
GarySwift / flexbox.css
Created March 29, 2017 13:42
CSS Vertical Center with Flexbox
/* Ref: https://davidwalsh.name/css-vertical-center-flexbox */
/*
Vertical centering requires a parent and children elements but
only the parent element needs CSS properties set for the vertical
centering of child elements:
*/
.flexbox-container {
display: -ms-flexbox;
display: -webkit-flex;
@GarySwift
GarySwift / _navigation-desktop-center.php
Created March 28, 2017 18:49
FoundationPress: Desktop Center Navigation Addon
<?php
/**
* FoundationPress: Desktop Center Navigation Addon
*
* A modifcation to the WordPress starter theme FoundationPress created by olefredrik based on Zurb Foundation.
*
* @link http://codex.wordpress.org/Function_Reference/register_nav_menus#Examples
* @package FoundationPress
* @ref https://github.com/olefredrik/FoundationPress
*/
@GarySwift
GarySwift / _slug-text.php
Created March 28, 2017 18:32
Change string into lowercase slug
<?php
/**
* Change string into lowercase slug
*
* @param $string Any string
* @return $string Converted string into slug
*/
function slug($string) {
# Lower case everything
$string = strtolower($string);
@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 / wp-config.php
Last active March 28, 2017 10:16
WordPress Debug mode for developing
<?php
/**
* For developers: WordPress debugging mode.
*
* Change this to true to enable the display of notices during development.
* It is strongly recommended that plugin and theme developers use WP_DEBUG
* in their development environments.
*
* For information on other constants that can be used for debugging,
* visit the Codex.