Skip to content

Instantly share code, notes, and snippets.

View tlovett1's full-sized avatar

Taylor Lovett tlovett1

View GitHub Profile
@tlovett1
tlovett1 / tup_get_blogs_info
Created August 30, 2012 14:46
Alternative function to get_blogs_list
function tup_get_blogs_info() {
if ( ( $results = get_site_option( '_blogs_info_list' ) ) === false ) {
global $wpdb;
$results = $wpdb->get_results( 'SELECT blog_id, path, domain FROM ' . $wpdb->blogs, ARRAY_A );
foreach ( $results as &$result ) {
switch_to_blog( $result['blog_id'] );
$site_info = $wpdb->get_results( 'SELECT option_value FROM ' . $wpdb->options . " WHERE option_name = 'blogname' ", ARRAY_A );
restore_current_blog();
@tlovett1
tlovett1 / gist:3744973
Created September 18, 2012 18:43
Run this code. Example of how parameters work.
<?php
function test( $test ) {
echo $test;
}
$dang = 'dang';
test( $dang );
test( '123' );
@tlovett1
tlovett1 / wp-config.php
Created November 8, 2012 16:04
wp-config.php
<?php
/**
* The base configurations of the WordPress.
*
* This file has the following configurations: MySQL settings, Table Prefix,
* Secret Keys, WordPress Language, and ABSPATH. You can find more information
* by visiting {@link http://codex.wordpress.org/Editing_wp-config.php Editing
* wp-config.php} Codex page. You can get the MySQL settings from your web host.
*
* This file is used by the wp-config.php creation script during the
@tlovett1
tlovett1 / gist:4062607
Created November 12, 2012 22:53
WP-CLI command in plugin
<?php
/*
Plugin Name: PMC Tag Scrubber
Plugin URI: http://www.pmc.com
Description: Download a .csv of tags/categories with their respective post counts. Flags duplicates automatically.
Author: Taylor Lovett, PMC, 10up
Version: 1.5
Author URI: http://www.10up.com
*/
function pmc_variety_image_credit( $form_fields, $attachment ) {
$image_credit = array(
'label' => 'Image Credit',
'value' => get_post_meta( $attachment->ID, '_image_credit', true ),
'helps' => 'Image credit, e.g. "Copyright ' . date('Y') . ' Getty Images".',
'show_in_edit' => true,
);
$form_fields['image_credit'] = $image_credit;
<?php
function vb_catch_bitmob_redirect() {
if ( ! empty( $_GET['bitmob_redirect'] ) ) {
$redirect_post = get_page_by_path( $_GET['bitmob_redirect'], OBJECT, 'post' );
if ( ! empty( $redirect_post ) )
wp_safe_redirect( get_permalink( $redirect_post->ID ), 301 );
}
}
@tlovett1
tlovett1 / gist:5365712
Created April 11, 2013 18:04
Connect with spoke api
<?php
error_reporting(E_ALL);
ini_set('display_errors','On');
/*$con = mysql_connect( 'localhost', 'root', 'ventureTemp' );
if ( ! $con ) {
//die( 'Could not connect: ' . mysql_error() );
}
@tlovett1
tlovett1 / gist:5853244
Created June 24, 2013 20:18
fun fun fun
<?php
/**
* Replace the excerpt meta box with a more user friendly summary meta box.
*
*/
class VB_Summary_Meta_Box {
/*
* Class variables
*/
<?php
require_once 'vendor/autoload.php';
use Guzzle\Http\Client;
$client = new Client( 'http://www.pehub.com/feed/' );
$request = $client->get();
$response = $request->send();
( function( $ ) {
$( '#pehub_post_quote_link' ).autocomplete( {
minLength: 3,
source: function( request, response ) {
var posts = [];
$.ajax( {
url: ajaxurl,