Skip to content

Instantly share code, notes, and snippets.

View interactiveRob's full-sized avatar

Rob Kirkner interactiveRob

View GitHub Profile
@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 / 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 / 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 / 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 / mac-terminal.md
Last active November 16, 2021 04:29
Useful Mac Terminal Commands

Kill Processes

  • Bluetooth -- sudo killall blued
  • Webcam -- sudo killall AppleCameraAssistant; sudo killall VDCAssistant
  • Finder -- sudo killall Finder
  • Sound -- sudo killall coreaudiod
  • Fix Eternal Harddrive mounting issue -- sudo pkill -f fsck

Find Application Serial Keys

Panic Coda -- defaults read com.panic.Coda2 SerialNumber

@interactiveRob
interactiveRob / basic_wp_enqueue.php
Created July 6, 2018 19:50
Basic WP enqueue scripts and Styles
/**
* Proper way to enqueue scripts and styles.
*/
function wpdocs_theme_name_scripts() {
wp_enqueue_style( 'style-name', get_stylesheet_uri() );
wp_enqueue_script( 'script-name', get_template_directory_uri() . '/js/example.js', array(), '1.0.0', true );
}
add_action( 'wp_enqueue_scripts', 'wpdocs_theme_name_scripts' );
@interactiveRob
interactiveRob / prevent clicks
Created May 1, 2018 16:45
jQuery prevent all link clicks on a page
$('a').each(function(){
$this = $(this);
$this.click(function(e){
e.preventDefault();
});
});
@interactiveRob
interactiveRob / .htaccess
Created April 18, 2018 14:26
.htaccess forbid all
Order deny,allow
Deny from all
@interactiveRob
interactiveRob / gist:1e7495dd50155e88dc7643388b225714
Last active April 12, 2018 15:56
Easy PHP check Day of Week
<?php
$day = date('D');
if($day == 'Mon' || $day == 'Wed' || $day == 'Fri'):
//do something
else:
endif;
?>
@interactiveRob
interactiveRob / set-timeout.js
Last active March 9, 2018 20:27
run function after a delay
setTimeout(function(){
//do something after 600 milliseconds
}, 600);