Skip to content

Instantly share code, notes, and snippets.

Alex King alexkingorg

View GitHub Profile
@alexkingorg
alexkingorg / standard-wp-admin-check.php
Created Jun 11, 2011
Check for standard WP admin page before attaching action.
View standard-wp-admin-check.php
<?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 Aug 15, 2011
ShareThis WordPress Plugin customization
View gist:1145803
<?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 Aug 15, 2011
Social WordPress Plugin "status broadcast" customization
View wp-social-status-broadcast.php
<?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 Aug 18, 2011
View source from a URL in BBEdit
View bbcurl.sh
bbcurl () { curl $1 | open -a BBEdit -f; }
@alexkingorg
alexkingorg / oembed-gist.php
Created Aug 18, 2011
Small mod to oEmbed Gist WordPress plugin to add NOSCRIPT support (RSS feeds, etc.).
View oembed-gist.php
<?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 Aug 18, 2011
Have comments appear before comment form in Social
View wp-social-comment-form-order.php
<?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 Aug 24, 2011
Filter in a URL to the pingback stack in WordPress
View filter-in-pingback.php
<?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 Sep 3, 2011
Change the brightness of the passed in hex color in PHP
View hex_color_mod.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
View git-submodule-fix.txt
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 Oct 1, 2011
New filter for adding image sizes to WP Media lightbox
View image_size_names_choose.php
<?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');
You can’t perform that action at this time.