Skip to content

Instantly share code, notes, and snippets.

View BruceMcKinnon's full-sized avatar

BruceMcKinnon

View GitHub Profile
@BruceMcKinnon
BruceMcKinnon / page-template.php
Created March 4, 2021 05:45
Move an element based on vertical scroll position
<?php
/*
Template Name: Bio Really Full Width
*/
?>
<?php get_header(); ?>
<div class="bio">
<div id="let-nikki-fly"><div id="flying-nikki"></div></div>
@BruceMcKinnon
BruceMcKinnon / functions.php
Created February 17, 2021 22:27
Volume of a bag
<?php
// calcBagVolume() - Calculate the volume of a bag or satcel. Provide the width/height dimensions in cms and get the volume in litres
function calcBagVolume($length,$width) {
// https://mathworld.wolfram.com/PaperBagSurface.html
$volume = pow($width,3) * ( ( $length / (pi() * $width) ) - ( 0.142 * ( 1 - (pow(10,(0-($length/$width)) ) ) ) ) );
$litres = $volume / 1000;
return $litres;
@BruceMcKinnon
BruceMcKinnon / single.php
Created February 16, 2021 21:21
Wordpress post navigation - only show posts fromt he same category
<?php the_post_navigation(array(
'prev_text' => '<span class="screen-reader-text">' . __( 'Previous Post', 'twentyseventeen' ) . '</span><span aria-hidden="true" class="nav-subtitle">' . __( 'Previous', 'twentyseventeen' ) . '</span> <span class="nav-title">%title</span>',
'next_text' => '<span class="screen-reader-text">' . __( 'Next Post', 'twentyseventeen' ) . '</span><span aria-hidden="true" class="nav-subtitle">' . __( 'Next', 'twentyseventeen' ) . '</span> <span class="nav-title">%title</span>', 'in_same_term' => true,
) ); ?>
@BruceMcKinnon
BruceMcKinnon / functions.php
Created December 17, 2020 23:20
Add multiple featured images to posts/pages/cpt etc - no plugin
<?php
// Thanks to:
//
// https://stackoverflow.com/questions/36506088/upload-multiple-featured-images-in-a-custom-post-wordpress
//init the meta box
add_action( 'after_setup_theme', 'custom_postimage_setup' );
function custom_postimage_setup(){
add_action( 'add_meta_boxes', 'custom_postimage_meta_box' );
@BruceMcKinnon
BruceMcKinnon / custom-post-widget.php
Created December 14, 2020 04:46
Custom Post Widget with Templates
<?php
/*
Add this code to allow support for categories in Custom Post Widget content blocks.
*/
add_action( 'init', 'add_content_block_taxonomies', 99 );
function add_content_block_taxonomies() {
@BruceMcKinnon
BruceMcKinnon / _fifths.scss
Created October 22, 2020 22:33
Foundation SCSS for 5 column and 7 column grids
//
// 5 columns in a 12 column grid
//
.grid-x > .small-2-4 {
@include grid-column(2.4); // (12/5 = 2.4)
}
.grid-x > .medium-2-4 {
@include breakpoint(medium) {
@include grid-column(2.4); // (12/5 = 2.4)
}
@BruceMcKinnon
BruceMcKinnon / gist:5c7dfccaa2c477e183007ff2e4e8cdf0
Last active August 7, 2024 01:22
Bitbucket or GitHub remote connect local repo
git init
git add .
git commit -m "Initial Commit"
// You can find the URL next to the git clone command for the repository.
// E.g., {URL} = https://[email protected]/username/repo.git
//
// Refer to: https://community.atlassian.com/t5/Git-questions/fatal-No-such-remote-origin-after-git-remote-set-url-origin/qaq-p/401456
//
@BruceMcKinnon
BruceMcKinnon / function.php
Created August 27, 2020 01:12
Add taxonomies to Content Blocks (Custom Post Widgets)
//
// Add Category support to the Custom Post Widget - https://wordpress.org/plugins/custom-post-widget/
// NB - Must set the priority to a high number
//
add_action( 'init', 'add_content_block_taxonomies', 99 );
function add_content_block_taxonomies() {
register_taxonomy_for_object_type( 'category', 'content_block' );
}
@BruceMcKinnon
BruceMcKinnon / readme.txt
Created August 24, 2020 23:16
Making custom OpenStreetMap bounded areas
1 - Get coastline .SHP file - https://export.hotosm.org/
2 - Convert .SHP file to GeoJSON format - https://mapshaper.org/
3 - Create final GeoJSON file - https://geojson.io/
@BruceMcKinnon
BruceMcKinnon / gf-datepicker.scss
Created August 24, 2020 03:04
Gravity Forms DatePicket styling
// General GF Date Picker - based on https://jboullion.com/gravity-forms-date-picker-styling
#ui-datepicker-div {
background: $white !important;
border: 1px solid $medium-gray !important;
border-radius: 0 !important;
display: none;
padding: rem-calc(20) !important;
width: rem-calc(280) !important;
text-shadow: none !important;