Skip to content

Instantly share code, notes, and snippets.

@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 / wp-plugin-path.php
Created December 15, 2011 19:04
Defining symlink compatible paths for WordPress plugins
<?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 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;
@alexkingorg
alexkingorg / wp-stats.php
Created January 3, 2012 04:28
WordPress per-year blog stats
<?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 January 6, 2012 06:22
WordPress Recent Posts by Format Widget
<?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';
@alexkingorg
alexkingorg / wp-favepersonal-format-image-excerpt-hover.php
Created January 14, 2012 22:26
Hover effect for image format excerpts
<?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 January 16, 2012 18:43
Character counter for WordPress editor
<?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 March 20, 2012 17:32 — forked from ejdanderson/style.css
FavePersonal Child Theme 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 March 20, 2012 17:37
FavePersonal Child Theme functions.php
<?php
if (__FILE__ == $_SERVER['SCRIPT_FILENAME']) { die(); }
// ADD YOUR CODE HERE