Skip to content

Instantly share code, notes, and snippets.

Adam Brewer adamcbrewer

Block or report user

Report or block adamcbrewer

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@adamcbrewer
adamcbrewer / transfer_process.sql
Created Mar 6, 2012
WP: SQL to transfer domains
View transfer_process.sql
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');
View getObjectSize.js
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;
}
View register_new_sidebar.php
<?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 / email_on_post.php
Created Mar 14, 2012
WP: Email Users On Post
View email_on_post.php
<?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 / custom_shortcodes.php
Created Mar 14, 2012
WP: Adding Shortcodes To Use When Posting
View custom_shortcodes.php
<?php
/**
* Adding shortcodes to the post-editing section: functions.php
* http://net.tutsplus.com/tutorials/wordpress/wordpress-shortcodes-the-right-way/
*
**/
/**
@adamcbrewer
adamcbrewer / custom_post_thumb_size.php
Created Mar 14, 2012
WP: Create A Custom Post-thumbnail Size
View custom_post_thumb_size.php
<?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 Mar 14, 2012
WP: Creating New Post Formats
View custom_post_formats.php
<?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',
View custom_nav_menus.php
<?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 Mar 14, 2012
WP: Custom Taxonomies And Post Types
View custom_taxes_and_posts.php
<?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 Jul 3, 2012
JS: Deferred, asynchronous script loading
View async-script.js
<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) {
You can’t perform that action at this time.