Skip to content

Instantly share code, notes, and snippets.

// paste into WP console in admin
jQuery(document).ready(function($) {
$('.acf-flexible-content .values .acf-icon.-collapse').click(function(e){
$this = $(this);
if(e.shiftKey) {
open = $this.is('.-collapsed .-collapse');
console.log('shift clicked');
console.log('open: ', open);
if (open){
$all = $this.parentsUntil('.values').parent().find('.-collapsed .acf-icon.-collapse');
@infn8
infn8 / functions.php
Created March 7, 2018 22:00
Show Bootstrap Sizers in Wordpress
<?php
function getBootstrapBreakpoints() {
return array(
'xs',
'sm',
'md',
'lg',
'xl',
);
@infn8
infn8 / functions.php
Created December 8, 2016 19:57
Remove Paragraph Formating in Wordpress on a per post basis
<?php
// knock out default filter
remove_filter('the_content','wpautop');
// add NEW filter
add_filter('the_content','post_custom_formatting');
function post_custom_formatting($content){
global $post;
// to remove the wpautop add a meta field to the post called 'wpautop' equal to 'false'
$nope = trim(get_post_meta( $post->ID, 'wpautop', true )) === 'false';
if($nope){
@infn8
infn8 / cascade_values.fn.php
Last active July 28, 2016 05:42
Cascade Values
<?php
function cascade_values(){
for ($i = 0; $i < func_num_args(); $i++) {
$val = func_get_arg($i);
if(!empty($val)){
return $val;
}
}
return false;
}
@infn8
infn8 / gist:be3edaa79aa40693983a
Created March 4, 2016 20:50
WP CLI add post from lorem ipsum API with author of first administrator.
curl "http://loripsum.net/api/5/medium/decorate/link/ul/ol/dl/bq/code/headers/" | sed "s/<\/p>/<\/p>\<\!\-\-more\-\-\>/" | wp post generate --post_content --count=1 --post_author=$(wp user list --role=administrator --field=ID --format=json | sed "s/\[//" | sed "s/\]//" | sed "s/\,.*//")
@infn8
infn8 / functions.php
Created February 11, 2016 17:24
Add uStream oEmbed support to WordPress.
<?php
// Add this to your plugin file or to functions.php
function my_add_oembed_providers() {
wp_oembed_add_provider( '#http://(www\.)?ustream.tv/*#i', 'http://www.ustream.tv/oembed', true );
}
add_action( 'init', 'my_add_oembed_providers' );
?>

Sublime Text Snippets and Keyboard shortcuts for working with Bootstrap

To install:

  • Toss all .sublime-snippet files into /Packages/User/ in your sublime install
  • Optional
    • Copy the lines from sample.sublime-keymap into your user keymap More Info Here

Tab Triggers

@infn8
infn8 / functions.php
Last active April 5, 2018 11:11
Wordpress Bootstrap Image Sizes
function add_theme_features() {
// Add Image Sizes
$containerLG = 1170; // Change this if you have updated the largest bootstrap container width.
for ($i=1; $i <= 12; $i++) {
add_image_size(
'col-lg-'.$i,
ceil($containerLG / 12 * $i),
ceil($containerLG / 12 * $i) * 10,
false
);
@infn8
infn8 / NewWordpress.sh
Last active July 1, 2020 22:30
Wp CLI New Wordpress Install
#!/bin/bash
for ((i=1;i<=$#;i++));
do
if [ ${!i} = "--dbname" ]
then ((i++))
dbname=${!i};
elif [ ${!i} = "--dbuser" ];
then ((i++))
@infn8
infn8 / functions.smtp.php
Created February 25, 2015 18:36
Use Mandrill SMTP for WordPress wp_mail() function
<?php
/* Add this to your functions.php or plugin file */
add_action( 'phpmailer_init', 'configure_mandrill_smtp' );
function configure_mandrill_smtp( PHPMailer $phpmailer ){
$phpmailer->isSMTP(); //switch to smtp
$phpmailer->Host = 'smtp.mandrillapp.com';
$phpmailer->SMTPAuth = true;
$phpmailer->Port = 587;
$phpmailer->Username = 'MAILCHIMP_USER';
$phpmailer->Password = 'MAILCHIMP_API_KEY';