Skip to content

Instantly share code, notes, and snippets.

View acf-collapse-all.js
// 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 Mar 7, 2018
Show Bootstrap Sizers in Wordpress
View functions.php
<?php
function getBootstrapBreakpoints() {
return array(
'xs',
'sm',
'md',
'lg',
'xl',
);
@infn8
infn8 / functions.php
Created Dec 8, 2016
Remove Paragraph Formating in Wordpress on a per post basis
View functions.php
<?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){
View cascade_values.fn.php
<?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 Mar 4, 2016
WP CLI add post from lorem ipsum API with author of first administrator.
View gist:be3edaa79aa40693983a
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 Feb 11, 2016
Add uStream oEmbed support to WordPress.
View functions.php
<?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' );
?>
View README.md

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 Apr 5, 2018
Wordpress Bootstrap Image Sizes
View functions.php
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 Jul 1, 2020
Wp CLI New Wordpress Install
View NewWordpress.sh
#!/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 Feb 25, 2015
Use Mandrill SMTP for WordPress wp_mail() function
View functions.smtp.php
<?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';