Skip to content

Instantly share code, notes, and snippets.

View magnificode's full-sized avatar
👹

Dominic Magnifico magnificode

👹
View GitHub Profile
@magnificode
magnificode / acf_cpt_dynamic_select.php
Last active August 29, 2015 14:26
Dynamic Advanced Custom Fields public custom post type select field.
<?php
/*
* Add this snippet to your functions.php file
* Create a select field through ACF (can be used in flexible content, repeater, etc.)
* Leave the choices field blank in the ACF backend
* Add it to your page.
*/
function acf_load_cpt_field_choices( $field ) {
// Reset choices
@magnificode
magnificode / attachment-detector.php
Last active August 29, 2015 14:13
Snippet that detects if a given ACF Page URL is an attachment page, detects the ID of that attachment page, and returns the URL for the actual attachment.
<?php
$ctaLink = get_field('static_hero_cta_button_link');
if (false !== strpos($ctaLink,'attachment_id')) {
$url = $ctaLink;
$url_parsed = parse_url($url);
parse_str($url_parsed['query'], $url_parts);
$attachmentID = $url_parts['attachment_id']; // attachment ID
$attachmentSrc = wp_get_attachment_url( $attachmentID ); // returns an array
$ctaLink = $attachmentSrc;
}
@magnificode
magnificode / _part-tabs.scss
Last active January 23, 2017 19:49
Dynamic tabs that switch to an accordion on mobile.
.tabs{
margin: {top:40px;}
&:last-child{
margin: {bottom:80px;}
}
h2{
color: $color-1;
font: {
size: emCalc(36px);
}
@magnificode
magnificode / full-width-nav.js
Last active December 29, 2015 00:39
Edge Case Mobile Nav where the child is relative to a smaller parent. Use this if you want that child to be the full width of the window.
var $window = $(window);
var $daNav = $('.main-head__nav').find('.menu');
function navGrow() { //it's like miracle grow for navs.
var superWide = $window.width();
$daNav.css('width', superWide);
$('.main-head__nav').click(function () {
$daNav.toggleClass('clack');
});
if ($window.width() > 768) {
@magnificode
magnificode / empty_search.php
Last active December 24, 2015 00:19
Fixes a Wordpress empty search query.
if(!is_admin()){
add_action('init', 'search_query_fix');
function search_query_fix(){
if(isset($_GET['s']) && $_GET['s']==''){
$_GET['s']=' ';
}
}
}
@magnificode
magnificode / index.html
Created August 3, 2013 21:48
A CodePen by dommagnifico. Block Nav - Rotating Block Nav
<link href='http://fonts.googleapis.com/css?family=Lato:900' rel='stylesheet' type='text/css'>
<div class="blocks">
<a href="#">
<div class="block">
<div class="block--norm">
<h2>Home</h2>
</div>
<div class="block--hover">
<h2>Home</h2>
@magnificode
magnificode / gmap_center.js
Last active October 28, 2016 12:42
Google maps snippet to keep the center centered on window resize
google.maps.event.addDomListener(window, 'resize', function() {
map.setCenter(YOUR_LAT_LONG_VAR_HERE);
});
@magnificode
magnificode / index.html
Created July 25, 2013 21:04
A CodePen by dommagnifico. Hover Lover - Hover over a thing, so that thing underneith does stuff
<link href='http://fonts.googleapis.com/css?family=Arbutus+Slab' rel='stylesheet' type='text/css'>
<article class="focus__list">
<div class="focus__area--wrap">
<div class="focus__area">
<div class="focus__icon">&amp;</div>
<div class="focus__title">
Ampersand
</div>
</div> <!-- //__area -->
@magnificode
magnificode / index.html
Created July 1, 2013 22:31
A CodePen by dominicmagnifico. Super Neat Responsive Nav - Uses a bit of jQuery to build a cool nav with some transitions.
<h2 class="slide-trigger">Super Neat Menu! <span></span></h2>
<nav role='navigation' class="nav">
<ul class="menu">
<li><a href="#">Inky</a></li>
<li><a href="#">Bink</a></li>
<li><a href="#">A Bottle</a></li>
<li><a href="#">Of Ink</a></li>
<li><a href="#">The Cork</a></li>
@magnificode
magnificode / index.html
Created June 27, 2013 15:08
A CodePen by dominicmagnifico. Stats - Lovely little stat counter using progress bars
<div class="container">
<div class="progress_wrapper pink_blue">
<span class="pink_blue tooltip">0%</span>
<progress max="100" value="0" data-value="60" class="pink_blue">
</progress>
</div>
<div class="progress_wrapper pink_blue">
<span class="pink_blue tooltip">0%</span>
<progress max="100" value="0" data-value="80" class="pink_blue">
</progress>