Skip to content

Instantly share code, notes, and snippets.

@alexkingorg
alexkingorg / standard-wp-admin-check.php
Created June 11, 2011 20:54
Check for standard WP admin page before attaching action.
<?php
/*
Plugin Name: Standard WP Admin Page Check
Description: Example code.
Version: 1.0
Author: Alex King
Author URI: http://alexking.org
*/
@alexkingorg
alexkingorg / gist:1145803
Created August 15, 2011 06:37
ShareThis WordPress Plugin customization
<?php
// customizations to have ShareThis nicely integrated into FavePersonal.
// step 1, disable auto-addition to posts
// this adds the ShareThis button to the post sidebar for content posts only
if (function_exists('st_makeEntries')) {
add_action('favepersonal_content_sidebar_after', 'sharethis_button');
}
@alexkingorg
alexkingorg / wp-social-status-broadcast.php
Created August 15, 2011 06:38
Social WordPress Plugin "status broadcast" customization
<?php
// set format for status posts to exclude title
// if status post is short enough, do not include URL either
function akv3_social_broadcast_format($format, $post, $service) {
if (get_post_format($post) == 'status') {
$format = (strlen($post->post_content) <= $service->max_broadcast_length() ? '{content}' : '{content} {url}');
}
return $format;
}
add_filter('social_broadcast_format', 'akv3_social_broadcast_format', 10, 3);
@alexkingorg
alexkingorg / bbcurl.sh
Created August 18, 2011 06:18
View source from a URL in BBEdit
bbcurl () { curl $1 | open -a BBEdit -f; }
@alexkingorg
alexkingorg / oembed-gist.php
Created August 18, 2011 06:39
Small mod to oEmbed Gist WordPress plugin to add NOSCRIPT support (RSS feeds, etc.).
<?php
/*
Plugin Name: oEmbed gist (AK)
Plugin URI: http://firegoby.theta.ne.jp/wp/oembed-gist
Description: Embed source from gist.github.
Author: Takayuki Miyauchi (THETA NETWORKS Co,.Ltd)
Version: 1.1.0
Author URI: http://firegoby.theta.ne.jp/
*/
@alexkingorg
alexkingorg / wp-social-comment-form-order.php
Created August 18, 2011 23:00
Have comments appear before comment form in Social
<?php
function akv3_social_comment_block_order($order) {
return array('comments', 'form');
}
add_filter('social_comment_block_order', 'akv3_social_comment_block_order');
@alexkingorg
alexkingorg / filter-in-pingback.php
Created August 24, 2011 05:52
Filter in a URL to the pingback stack in WordPress
<?php
function pingback_format_link_url($post_links, $post_id) {
$url = get_post_meta($post_id, '_format_link_url', true);
if (!empty($url) && !in_array($url, $post_links)) {
$post_links[] = $url;
}
return $post_links;
}
add_filter('pre_ping_post_links', 'pingback_format_link_url', 10, 2);
@alexkingorg
alexkingorg / hex_color_mod.php
Created September 3, 2011 23:42
Change the brightness of the passed in hex color in PHP
<?php
/**
* Change the brightness of the passed in color
*
* $diff should be negative to go darker, positive to go lighter and
* is subtracted from the decimal (0-255) value of the color
*
* @param string $hex color to be modified
* @param string $diff amount to change the color
@alexkingorg
alexkingorg / git-submodule-fix.txt
Created September 3, 2011 23:55
Re-set Kohana submodule
My fix is to do the following:
$: rm -rf core/kohana
$: vim .gitmodules
Delete the submodule path to kohana from this file.
$: git rm --cached core/kohana
$: git submodule add git@github.com:crowdfavorite/kohana.git core/kohana
$: git submodule init --recursive
@alexkingorg
alexkingorg / image_size_names_choose.php
Created October 1, 2011 06:32
New filter for adding image sizes to WP Media lightbox
<?php
function cfcp_image_size_input_fields_sizes($sizes) {
$sizes['medium-img'] = 'Content Width';
$sizes['banner-img'] = 'Content Width Short (Cropped)';
$sizes['large-img'] = 'Full Width';
return $sizes;
}
add_filter('image_size_names_choose', 'cfcp_image_size_input_fields_sizes');