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
<?php
// Valid values: development, staging and production. To get this value use: wp_get_environment_type()
defined( 'WP_ENVIRONMENT_TYPE' ) or define( 'WP_ENVIRONMENT_TYPE', 'production' );
define('DB_NAME', 'fill in db name');
define('DB_USER', 'fill in username');
define('DB_PASSWORD', 'fill in db password');
define('DB_HOST', 'localhost');
@PunchRockgroin
PunchRockgroin / gp-limit-choices-add-message-when-full.js
Last active August 30, 2019 20:04
Gravity Perks Limit Choices add message when no more choices available
// Add classname .choicless-message to field in GF Admin
$('.choiceless-message').each(function() {
let $el = $(this)
let inputsWithChoice = $el.find('input').length
let inputsWithChoiceDisabled = $el.find('input:disabled').length
let waitlistHref = $el.data('waitlistHref') || '#'
if (inputsWithChoice === inputsWithChoiceDisabled) {
$('<div />').addClass('alert alert-warning').html('<p class="mb-0">There are no more open slots available<br /> <a href=".waitlistHref.">Join the waitlist</a></p>').appendTo($el)
}
@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;
}
<?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',
<?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>
@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');
@PunchRockgroin
PunchRockgroin / mailtest.php
Created November 12, 2014 23:16
Mail Test
<?php $to = 'nobody@example.com'; $subject = 'Test email using PHP'; $message = 'This is a test email message'; $headers = 'From: webmaster@example.com' . "\r\n" . 'Reply-To: webmaster@example.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers, '-fwebmaster@example.com');
@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 / 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 / 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