Skip to content

Instantly share code, notes, and snippets.

@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 / 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');
@alexkingorg
alexkingorg / wp-anonomize-user-data.sql
Created October 6, 2011 15:37
Remove non-public user data from standard WP database.
-- generic email addresses and new passwords for users
UPDATE wp_users
SET user_email = CONCAT(user_login, '@example.com'),
user_pass = MD5(CONCAT(RAND(), CAST(ID AS CHAR), user_login));
-- generic email addresses for commentors
UPDATE wp_comments
SET comment_author_email = CONCAT(CAST(comment_ID AS CHAR), '@example.com');
@alexkingorg
alexkingorg / wp-switch-to-post.php
Created October 19, 2011 00:23
switch_to_post() stack implementation (similar to switch_to_blog()) for WordPress
<?php
$WP_POST_STACK = array();
function switch_to_post($post_id) {
global $WP_POST_STACK, $post;
if (!count($WP_POST_STACK)) {
$WP_POST_STACK[] = $post->ID;
}
$WP_POST_STACK[] = $post_id;
@alexkingorg
alexkingorg / query_format_standard.php
Created January 2, 2012 06:41
Enable WP_Query to search by "standard" post format.
<?php
function akv3_query_format_standard($query) {
if (isset($query->query_vars['post_format']) &&
$query->query_vars['post_format'] == 'post-format-standard') {
if (($post_formats = get_theme_support('post-formats')) &&
is_array($post_formats[0]) && count($post_formats[0])) {
$terms = array();
foreach ($post_formats[0] as $format) {
$terms[] = 'post-format-'.$format;