Skip to content

Instantly share code, notes, and snippets.

View robinbastien's full-sized avatar
Just a developer in a quarantined world

Robin Bastien robinbastien

Just a developer in a quarantined world
View GitHub Profile
@robinbastien
robinbastien / functions.php
Created March 12, 2018 21:26
[Youtube Embed Helpers] Functions to convert a youtube URL into a Youtube Embed URL #youtube #PHP #embed
<?php
/**
* Retrieves ID from Youtube URL
* @param [type] $url The full youtube URL
* @return [type] Just the ID
*/
function get_youtube_id_from_url($url) {
$parts = parse_url($url);
@robinbastien
robinbastien / machine-admin.css
Last active March 8, 2018 18:57
[Wordpress ACF Icon Selector] Modify an ACF radio field to be used as an icon picker. add the .icon-selector class when creating the field #wordpress #acf #backend #icons
/**
* Icon Selector
*/
.acf-field.icon-selector .acf-radio-list > li {
padding: 0.25rem 0;
margin-right: 0.5rem;
}
.acf-field.icon-selector li > label {
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.machine.myApp" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0">
<name>myApp</name>
<description>
myApp
</description>
<author email="hello@machine-agency.com" href="https://www.machine-agency.com">
Machine
</author>
<content src="index.html" />
@robinbastien
robinbastien / section.php
Last active December 7, 2016 22:08
Output a flexible field group of buttons with options
<?php
$link_type = get_sub_field('link_type');
if( $link_type && $link_type != 'none' ) :
$link_target = ( $link_type == 'external' || $link_type == 'file' ) ? ' target="_blank"' : '';
$link_text = get_sub_field('link_text');
$link_url = get_sub_field('link');
if( $link_type == 'internal' ) {
$link_text = empty( $link_text ) ? get_the_title( $link_url ) : $link_text;
$link_url = get_permalink( $link_url );
@robinbastien
robinbastien / main.js
Last active January 23, 2018 10:13
CSS Scroll Reveals (Simple WOW.js alternative)
// Get height of window and set an offset from bottom
var winHeight = $(window).height();
var offset = 50;
// Recalc height of window in case of resize
$(window).bind('resizeEnd', function() {
winHeight = $(window).height();
});
// When we scroll we do some checks...
@robinbastien
robinbastien / fixed-header-anchor-fix.css
Created March 29, 2016 22:44
A fix for linking to sections with anchors while having a 'sticky' header
.someselector[id]::before {
display: block;
content: "";
width: 1px;
visibility: hidden;
pointer-events: none;
/* Set both heights to the same, adjust as needed */
height: 11rem;
margin-top: -11rem;
@robinbastien
robinbastien / machine-pmpro.php
Last active June 4, 2018 13:07
Page Memberships Pro Components
<?php
/**
* machine-pmpro.php
* A dedicated function file for Paid Memberships Pro functionality
*
* @package WordPress
* @subpackage Machine
*/
$options = (object) array(
@robinbastien
robinbastien / machine-actions.php
Created July 14, 2015 15:33
Remove WP Emoji Scripts
<?php
remove_action('wp_head', 'print_emoji_detection_script', 7);
remove_action('wp_print_styles', 'print_emoji_styles');
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
remove_action( 'admin_print_styles', 'print_emoji_styles' );
?>
@robinbastien
robinbastien / jQuery.modal.js
Last active April 20, 2018 15:58
jQuery Simple Modal
/*!
* jQuery.modal.js
*
* Creates a modal to use with images
*
* @author Robin Bastien <robin@machine-agency.com>
* @version 1.0.1
*
* @example
* $('.section--gallery').modal();
@robinbastien
robinbastien / main.js
Last active August 29, 2015 14:22
jQuery Square blocks in grid system. Simple responsive stay-square listings
jQuery(document).ready(function($) {
// Assuming the items we want to square are .film-listing...
if( $('.film-listing').length ) {
makeItSquare('.film-listing');
// This handles resizing and preserving the nice squareness
$(window).bind('resizeEnd', function() {
makeItSquare('.film-listing');
});