Skip to content

Instantly share code, notes, and snippets.

View interactiveRob's full-sized avatar

Rob Kirkner interactiveRob

View GitHub Profile
@interactiveRob
interactiveRob / gist:aec4fd794e4247055625063659b1f641
Created August 20, 2018 14:58
Stop overflowing elements from causing horizontal scroll on iOS
//This must be applied to the overflowing element's direct parent. If no parent, wrap the overflowing element in a div.boundary
.boundary{
width: 100%;
overflow-x: hidden;
}
@interactiveRob
interactiveRob / preg-replace-wpautop.php
Last active November 2, 2018 05:56
Remove WP Auto paragraph tags in ACF content
<?php
/* preg replace removes extra <p> tags from Wordpress' WYSIWYG editor*/
$hero_headline = preg_replace('/<\/?p>/', '', get_field('hero_headline'));
?>
@interactiveRob
interactiveRob / rk_get_template_part.php
Last active November 22, 2019 19:46
Pass variables to get_template_part() as arguments in Wordpress
function rk_get_template_part($template_slug, $args = [], $var_store = false) {
$props = $args;
$template_slug = $template_slug . '.php';
ob_start();
include( locate_template($template_slug) );
$template_output = ob_get_clean();
@interactiveRob
interactiveRob / acf_group_has_content.php
Created November 5, 2018 20:45
Check if ACF group has content
function acf_group_has_content($group){
/* Necessarily checks if a groups sub_fields have content
because the ACF group always returns true even when the
group is empty */
foreach ($group as $item):
if($item):
return true;
endif;
@interactiveRob
interactiveRob / show_registered_post_types.php
Created November 8, 2018 18:21
Show a list of wordpress registered custom post types
function show_registered_post_types(){
$args=array(
'public' => true,
'exclude_from_search' => false,
'_builtin' => false
);
$output = 'names'; // names or objects, note names is the default
$operator = 'and'; // 'and' or 'or'
@interactiveRob
interactiveRob / dev-to-regular-human.md
Last active November 12, 2018 17:53
Things developers say to regular humans quite frequently

Things developers say to regular humans quite frequently

  • Hard Refresh / Clear Cache:
    To make sure you're seeing the latest updates, clear your cache by holding down the Shift key while you refresh the page.

  • Screenshot the Console (Chrome):
    Press keyboard shortcut: [Command Option J] ([Control Alt J] for Windows) and take a screenshot of the console that appears at the bottom of your browser window.

@interactiveRob
interactiveRob / name-line-break.php
Last active November 19, 2018 17:45
Regex Replace to break any name into two lines
/* Two step Regex replace to make sure names always break into 2 lines:
1) Remove all spaces entered by Human error from the end of the Full Name
2) Replace spaces with <br/> tags. Definitions
(?!^\s) Don't match spaces that come at the beginning of the name
(?!\w+\s) Also don't match a space after the First Name if there is another
word followed by a space after that. This prevents breaking the line for Middle Names.
*/
$title = preg_replace('/\s+$/', '', $title);
$title = preg_replace('/(?!^\s)\s(?!\w+\s)/', '<br/>', $title);
@interactiveRob
interactiveRob / es6-jquery-accordion
Created November 29, 2018 16:21
ES6 jQuery Accordion
class productsAccordion {
constructor($productsAccordion) {
this.$drawer = $productsAccordion;
this.$header = null;
this.headerHeight = null;
this.expandedSize = null;
}
getGroup(){
@interactiveRob
interactiveRob / rk-cubic-beziers.md
Last active November 29, 2018 17:51
Nice Cubic Bezier easings

For swipes/slideshows: cubic-bezier(0.06, 0.46, 0.68, 0.94);

@interactiveRob
interactiveRob / no-fouc-es6.js
Created December 13, 2018 20:07
No FOUC ES6 Class
export default class NoFouc {
constructor() {
this.$elements = $('.no-fouc');
}
removeFoucBlocker(){
this.$elements.removeClass('.no-fouc');
}
init() {