Skip to content

Instantly share code, notes, and snippets.

View interactiveRob's full-sized avatar

Rob Kirkner interactiveRob

View GitHub Profile
@interactiveRob
interactiveRob / es6-dom-utils.js
Last active January 16, 2019 19:17
ES6 Dom Helpers/Utilities Boilerplate (to use instead of jQuery)
//dom_utils Class, keep this in a utils file of some sort
class dom_utils {
constructor(selector) {
this.node = selector;
}
exists() {
return typeof this.node !== 'undefined';
}
@interactiveRob
interactiveRob / conditional-wp-config.php
Last active January 14, 2019 17:48
Load config files conditionally into wp_config based on environment $_SERVER['HTTP_HOST']
<?php
/*———— -Determine environment and load the corresponding config file- ————*/
//builds RegEx patterns with any number of optional hostnames
function host_pattern($carry, $item, $initial){
return $carry . '(' . preg_quote($item) . ')?';
}
$local_hosts = [
'.docker',
@interactiveRob
interactiveRob / disable_gutenberg.php
Last active January 13, 2019 02:27
Disable Gutenberg Editor in one line of PHP
/* To disable the Gutenberg editor sitewide,
add the following snippet to functions.php or
any other PHP file that has been included in functions.php */
add_filter('use_block_editor_for_post', '__return_false', 10);
@interactiveRob
interactiveRob / start_session.php
Created January 11, 2019 18:55
Start Session for Wordpress
/* In order to use SESSION with AJAX etc in Wordpress. you must use add_action to hook into 'wp' */
add_action('wp', 'rk_start_session');
function rk_start_session() {
global $post;
//if you want to use anything from the $post variable you can
if(!session_id()):
@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() {
@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 / 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 / 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 / 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 / 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'