Skip to content

Instantly share code, notes, and snippets.

View interactiveRob's full-sized avatar

Rob Kirkner interactiveRob

View GitHub Profile
@interactiveRob
interactiveRob / path-based-redirect.php
Last active October 22, 2020 20:15
PHP custom redirect based on request path (Wordpress)
function redirect_to_google_doc(){
//a little bit of custom routing
$path = request_path();
if($path == 'notes'):
$redirect_url = 'https://docs.google.com/document/d/1vNAMaEHBrmrX1uQ-hJTdkmTk4MwaspYRzK-0I3nx454/edit?usp=sharing';
wp_redirect($redirect_url);
exit;
@interactiveRob
interactiveRob / js-helpers-localize-script.php
Created November 19, 2019 03:37
Wordpress PHP variables to javascript as a key on the window with localize script
function enqueue_script_helpers() {
/**
* passes variables to javascript for cookies and frontend ajax requests.
*/
wp_localize_script( 'main-js', 'jsHelpers',
array(
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'siteurl' => $_SERVER['SERVER_NAME'],
)
);
@interactiveRob
interactiveRob / tight-text-wrap.js
Created November 14, 2019 18:19
Tight text wrap for inline flex-items ES6
let TightTextWrap = (({}) => {
class TightTextWrap {
constructor(node, options = {}) {
this.node = node;
this.width = this.node.offsetWidth;
this.parent = this.node.parentNode;
this.parentWidth = this.parent.offsetWidth;
}
setWrapWidth() {
@font-face {
font-family: 'Manrope';
src: url('../fonts/manrope-bold.woff2') format('woff2'),
url('../fonts/manrope-bold.woff') format('woff'),
url('../fonts/manrope-bold.otf') format('truetype');
font-style: normal;
font-weight: 700;
}
@font-face {
@font-face {
font-family: 'Manrope';
src: url('../fonts/manrope-bold.woff2') format('woff2'),
url('../fonts/manrope-bold.woff') format('woff'),
url('../fonts/manrope-bold.otf') format('truetype');
font-style: normal;
font-weight: 700;
}
@font-face {
@font-face {
font-family: 'Manrope';
src: url('../fonts/manrope-bold.woff2') format('woff2'),
url('../fonts/manrope-bold.woff') format('woff'),
url('../fonts/manrope-bold.otf') format('truetype');
font-style: normal;
font-weight: 700;
}
@font-face {
@interactiveRob
interactiveRob / scriptTagInjection.js
Created September 24, 2019 15:08
Programmatically create script tag
<script>
(function() {
var script = document.createElement('script');
script.src = 'https://example.com/assets/js/add_your_custom_script_url_here.js';
script.type = 'text/javascript';
// Finally, inject the element to the end of <body>
document.body.appendChild(script);
})();
@interactiveRob
interactiveRob / wordpress_tinyMCE_script_injection.js
Last active September 3, 2019 20:27
Add Fontawesome or Typekit to the Wordpress Editor
/*
Here's the PHP that is needed to run the javascript below as a tinyMCE plugin.
Add to functions.php, or another PHP file that you have required or included
<?php
function gist_add_tinymce_plugins($plugin_array) {
$plugin_array['fontawesome'] = get_stylesheet_directory_uri() .'/assets/admin-assets/customTinyMCE.js';
return $plugin_array;
}
@interactiveRob
interactiveRob / drupalEditorRedirect.js
Created August 14, 2019 17:51
Drupal editor link redirect generator (paste into the console)
window.location.href = document.querySelector('link[rel="shortlink"]').getAttribute('href') + '/edit';
@interactiveRob
interactiveRob / generate-link-from-acf-array.php
Created June 22, 2019 10:31
Generate link markup from ACF link array