Skip to content

Instantly share code, notes, and snippets.

View PunchRockgroin's full-sized avatar

David Alberts PunchRockgroin

  • Many, many companies
  • Loveland, Colorado
View GitHub Profile
@PunchRockgroin
PunchRockgroin / app.js
Last active December 17, 2015 13:29
Example of working jQuery/Gumby Framework with Require.js, after replacing define(window.Gumby) with define('Gumby') in gumby.min.js
/*global define */
define(['jquery','gumby'], function () {
'use strict';
console.log('jQuery ' + $().jquery); // jQuery 1.9.1
console.log('Gumby is ready to go...', Gumby.debug()); //Gumby is ready to go... Object { $dom={...}, isOldie=false, uiModules={...}, more...}
});
@PunchRockgroin
PunchRockgroin / my_module.exclude_from_update_list.inc
Created July 17, 2013 15:05
Prevent Update for custom modules
<?php
/**
* @file
* <my_module>.exclude_from_update_list.inc
*/
/**
* Implements hook_update_projects_alter().
*/
@PunchRockgroin
PunchRockgroin / node_v0.11.7_build
Created September 18, 2013 20:30
Gumby Framework - Claymate on old/dev Node Versions
# node -v
v0.11.7
# claymate build
/root/.nvm/v0.11.7/lib/node_modules/claymate/node_modules/uglify-js/lib/parse.js:53
KEYWORDS = makePredicate(KEYWORDS);
^
util.debug: Use console.error instead
DEBUG: ERROR in file: /root/.nvm/v0.11.7/lib/node_modules/claymate/node_modules/uglify-js/lib/parse.js / ReferenceError: KEYWORDS is not defined
@PunchRockgroin
PunchRockgroin / modalCloseOutside
Created January 12, 2014 19:23
Gumby close modal on click outside
$('.modal').on(Gumby.click, function(e){
var container = $('.content');
if((!container.is(e.target) // if the target of the click isn't the container...
&& container.has(e.target).length === 0)) // ... nor a descendant of the container
{
$('.modal .close').trigger('gumby.trigger');
}
});
@PunchRockgroin
PunchRockgroin / functions.php
Created March 27, 2014 21:58
Gumby intrinsic Video Wrapper for Wordpress oEmbed. My regex is only as strong as Google can get me.
function THEMENAME_wrap_gumby_intrinsic($html, $url, $args){
$provider = '';
if (preg_match("#https?://youtu\.be/.*#i", $url) || preg_match("#https?://(www\.)?youtube\.com/watch.*#i", $url)) {
$provider = 'youtube';
}elseif (preg_match("/vimeo.com\/([^&]+)/i", $url)) {
$provider = 'vimeo';
}
//no oEmbed for Twich :<
//elseif (preg_match("/https?:\/\/(.*twitch\.tv\/.*|.*twitch\.tv\/.*\/b\/.*)/i", $url)){
//$provider = 'twitch';
@PunchRockgroin
PunchRockgroin / mailtest.php
Created November 12, 2014 23:16
Mail Test
<?php $to = '[email protected]'; $subject = 'Test email using PHP'; $message = 'This is a test email message'; $headers = 'From: [email protected]' . "\r\n" . 'Reply-To: [email protected]' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers, '[email protected]');
@PunchRockgroin
PunchRockgroin / domain-update.sql
Created March 6, 2015 17:22
Moving Wordpress without WP-CLI
UPDATE wp_options SET option_value = replace(option_value, 'http://www.old-domain.com', 'http://www.new-domain.com') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://www.old-domain.com', 'http://www.new-domain.com');
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.old-domain.com', 'http://www.new-domain.com');
UPDATE wp_postmeta SET meta_value = replace(meta_value, 'http://www.old-domain.com', 'http://www.new-domain.com');
<?php
// This file assumes that you have included the nav walker from https://github.com/twittem/wp-bootstrap-navwalker
// somewhere in your theme.
?>
<header class="banner navbar navbar-default navbar-static-top" role="banner">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only"><?= __('Toggle navigation', 'sage'); ?></span>
<?php
function the_date_range($args) {
global $post;
$default = array(
'start_field' => 'start_date',
'end_field' => null,
'base_format' => 'Ymd',
'post_id' => $post->ID,
'separator' => '<span class="date-separator">&ndash;</span>',
'month_format' => 'F',
@PunchRockgroin
PunchRockgroin / replace_vc_gitem_post_image_background.php
Created December 15, 2017 19:51
Replace Visual Composer / WPBakery Page Builder default image when no featured image present
function replace_vc_gitem_post_image_background($output){
// Get the URL to replace in string background-image: url('https://yoursite.com/wp-content/plugins/js_composer/assets/vc/vc_gitem_image.png') !important;
$url = get_site_url(null, '/wp-content/plugins/js_composer/assets/vc/vc_gitem_image.png');
// Full http(s) path to image
$new_url = 'full-uri-to-new-image.ext'; // 1024x1024 image
// String Replace
$new_output = str_replace($url, $new_url, $output);
// Return new string
return $new_output;
}