Skip to content

Instantly share code, notes, and snippets.

Alex King alexkingorg

Block or report user

Report or block alexkingorg

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
@alexkingorg
alexkingorg / wp-anonomize-user-data.sql
Created Oct 6, 2011
Remove non-public user data from standard WP database.
View wp-anonomize-user-data.sql
-- 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 Oct 19, 2011
switch_to_post() stack implementation (similar to switch_to_blog()) for WordPress
View wp-switch-to-post.php
<?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 / wp-plugin-path.php
Created Dec 15, 2011
Defining symlink compatible paths for WordPress plugins
View wp-plugin-path.php
<?php
// include this near the top of your plugin file
$my_plugin_file = __FILE__;
if (isset($plugin)) {
$my_plugin_file = $plugin;
}
else if (isset($mu_plugin)) {
@alexkingorg
alexkingorg / query_format_standard.php
Created Jan 2, 2012
Enable WP_Query to search by "standard" post format.
View query_format_standard.php
<?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;
@alexkingorg
alexkingorg / wp-stats.php
Created Jan 3, 2012
WordPress per-year blog stats
View wp-stats.php
<?php
header('Content-type: text/plain');
global $wpdb;
?>
<table class="numbers">
<thead>
<tr>
<th>&nbsp;</th>
@alexkingorg
alexkingorg / wp-recent-posts-by-format.php
Created Jan 6, 2012
WordPress Recent Posts by Format Widget
View wp-recent-posts-by-format.php
<?php
// relies on https://gist.github.com/1549613
class WP_Widget_Recent_Posts_By_Format extends WP_Widget {
function __construct() {
$widget_ops = array('classname' => 'widget_recent_entries_by_format', 'description' => __( "The most recent posts on your site by format") );
parent::__construct('recent-posts-by-format', __('Recent Posts by Format'), $widget_ops);
$this->alt_option_name = 'widget_recent_entries_by_format';
View wp-favepersonal-format-image-excerpt-hover.php
<?php
// Cut off images at 300px high in excepts, show full image on hover
function akv3_image_excerpt_hover_js() {
?>
<script>
;jQuery(function($) {
$('.format-image.excerpt .entry-content').hover(function() {
if ($('body').width() < 768) {
@alexkingorg
alexkingorg / wp-editor-char-count.php
Created Jan 16, 2012
Character counter for WordPress editor
View wp-editor-char-count.php
<?php
// handy if you write status posts and send them to Twitter
function akv3_editor_char_count() {
?>
<script type="text/javascript">
(function($) {
wpCharCount = function(txt) {
$('.char-count').html("" + txt.length);
@alexkingorg
alexkingorg / style.css
Created Mar 20, 2012 — forked from ejdanderson/style.css
FavePersonal Child Theme style.css
View style.css
/*
Theme Name: FavePersonal Child
Theme URI: http://example.com/
Description: Child theme for the FavePersonal Theme
Author: Your name here
Author URI: http://example.com/about/
Template: favepersonal
Version: 1.0
*/
@alexkingorg
alexkingorg / functions.php
Created Mar 20, 2012 — forked from ejdanderson/functions.php
FavePersonal Child Theme functions.php
View functions.php
<?php
if (__FILE__ == $_SERVER['SCRIPT_FILENAME']) { die(); }
// ADD YOUR CODE HERE
You can’t perform that action at this time.