Skip to content

Instantly share code, notes, and snippets.

View adamcbrewer's full-sized avatar

Adam Brewer adamcbrewer

View GitHub Profile
@adamcbrewer
adamcbrewer / transfer_process.sql
Created March 6, 2012 21:49
WP: SQL to transfer domains
update wp_options set option_value = replace(option_value,'string_to_find','string_to_replace');
update wp_posts set guid = replace(guid,'string_to_find','string_to_replace');
@adamcbrewer
adamcbrewer / getObjectSize.js
Created March 9, 2012 16:54
JS: Get Object Size
function objectSize(the_object) {
/* function to validate the existence of each key in the object to get the number of valid keys. */
var object_size = 0;
for (key in the_object){
if (the_object.hasOwnProperty(key)) {
object_size++;
}
}
return object_size;
}
@adamcbrewer
adamcbrewer / email_on_post.php
Created March 14, 2012 17:53
WP: Email Users On Post
<?php
function email_members($post_ID) {
global $wpdb;
// fetch the list of users registered
foreach( $wpdb->get_results("SELECT user_email FROM $wpdb->users;") as $key => $object) {
$user_emails[] = $object->user_email;
}
$users = implode(',', $user_emails);
@adamcbrewer
adamcbrewer / register_new_sidebar.php
Created March 14, 2012 17:52
WP: Register New Sidebar
<?php
/**
* Location: functions.php
*/
// callback function
function your_widget_display() {
// print some HTML for the widget to display here
echo "Your Widget Test";
}
@adamcbrewer
adamcbrewer / custom_post_thumb_size.php
Created March 14, 2012 17:57
WP: Create A Custom Post-thumbnail Size
<?php
/**
* Location: functions.php
*
*/
// drop in functions.php
if ( function_exists( 'add_theme_support' ) ) {
add_theme_support( 'post-thumbnails' );
add_theme_support( 'post-thumbnails', array('post', 'movie')); // include array of post_types (including registered ones)
@adamcbrewer
adamcbrewer / custom_post_formats.php
Created March 14, 2012 17:59
WP: Creating New Post Formats
<?php
/**
* Location: functions.php
*
*/
// comment out as necessary
// use for styling 'format-{type}' class generated from post_class() in the loop
if ( function_exists( 'add_theme_support' ) ) {
add_theme_support('post-formats',
@adamcbrewer
adamcbrewer / custom_nav_menus.php
Created March 14, 2012 18:05
WP: Custom Nav Menu's
<?php
/**
* Location: funtions.php
*
*/
// Registering in functions.php
if ( function_exists( 'register_nav_menus' ) ) {
register_nav_menus(
array(
@adamcbrewer
adamcbrewer / custom_taxes_and_posts.php
Created March 14, 2012 18:06
WP: Custom Taxonomies And Post Types
<?php //http://codex.wordpress.org/Function_Reference/register_post_type#Example
/**
* Base-settings for adding additional features to an existing WP install
*
* Location: functions.php file
*
*
*
* It's best to play around with the setting below, but this
* basic structure allows for:
@adamcbrewer
adamcbrewer / async-script.js
Created July 3, 2012 09:58
JS: Deferred, asynchronous script loading
<script type="text/javascript">
// Add a script element as a child of the body
function downloadJSAtOnload() {
var script = document.createElement("script");
script.src = "script.js";
document.body.appendChild(script);
}
// Check for browser support of event handling capability
if (window.addEventListener) {
@adamcbrewer
adamcbrewer / facebook.share.html
Last active October 8, 2015 23:27
Social: Custom sharing links
<a id="fb-share-popup" href="http://www.facebook.com/sharer.php?s=100&amp;p[title]=____&amp;p[url]=____&amp;p[summary]=____&amp;p[images][0]=____" target="_blank">share on Facebook</a>
<script>
// This will open our link in a new, small window in the middle of the browser
var p = {};
p.w = 700;
p.h = 400;
p.l = (screen.width/2)-(p.w/2);
p.t = (screen.height/2)-(p.h/2);