Skip to content

Instantly share code, notes, and snippets.

Chris Aprea aprea

  • Sydney, Australia
Block or report user

Report or block aprea

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
@aprea
aprea / gist:52381efc380ebbdf85da
Created Apr 23, 2015
WordPress oEmbed Tests
View gist:52381efc380ebbdf85da
YouTube Video
https://www.youtube.com/watch?v=bP7vggHJLVM
YouTube Playlist
https://www.youtube.com/playlist?list=PL75C7F02E0C4EA3E0
Twitter Tweet
https://twitter.com/google/status/590225864421482498
blip.tv Video
View gist:676166688917322dfe80
the_archive_title( '<h1 class="page-title">', '</h1>' );
View gist:eae346874f39bd8d450d
<?php
/**
* Get the table data
*
* @return Array
*/
private function table_data() {
global $wpdb;
View ms-extract-umeta-clean.sql
-- delete any usermeta specific to the other subsites
delete from wp_usermeta where meta_key regexp '^wp_([0-9]+)_';
-- duplicate the wp_usermeta structure in a working data table,
-- but add a unique index for filtering out duplicates
create table _fix_usermeta like wp_usermeta;
alter table _fix_usermeta add unique(user_id, meta_key);
-- copy the site-specific usermeta, keeping only the last of each duplicate
insert into _fix_usermeta
@aprea
aprea / gist:886a5f1d6ec094e996fc
Last active Aug 29, 2015
Disable excerpt filtering for a specific post category
View gist:886a5f1d6ec094e996fc
<?php
function disable_excerpt_filtering() {
// disable excerpt filtering for the "markup" post category
if ( has_category( 'markup' ) ) {
return true;
}
return false;
}
@aprea
aprea / gist:82b5cf043ade04f55463
Created Jun 24, 2014
Only add the "add more" link when required
View gist:82b5cf043ade04f55463
<?php
function ca_only_add_more_when_required( $default, $text, $options ) {
$text = strip_tags( $text );
if ( 'words' === $options['length_type'] ) {
$excerpt_length = str_word_count( $text );
} else {
$excerpt_length = strlen( $text );
}
@aprea
aprea / gist:b1f74bfa5e16b41c421b
Created Jun 10, 2014
Advanced Excerpt - right align "read more" link
View gist:b1f74bfa5e16b41c421b
<?php
function custom_advanced_excerpt_read_more_link_template( $template ) {
/*
* The Advanced Excerpt plugin code looks like this
* apply_filters( 'advanced_excerpt_read_more_link_template', ' <a href="%1$s" class="read-more">%2$s</a>', get_permalink(), $read_more );
*/
return sprintf( '<p style="text-align: right;">%s</p>', $template );
}
add_filter( 'advanced_excerpt_read_more_link_template', 'custom_advanced_excerpt_read_more_link_template' );
@aprea
aprea / gist:620566678b76bbffe0a0
Created May 21, 2014
Preserve the 'blog_plugic' setting in wp_options when migrating your DB With WP Migrate DB Pro
View gist:620566678b76bbffe0a0
<?php
function custom_preserved_options( $options ) {
$options[] = 'blog_public';
return $options;
}
add_filter( 'wpmdb_preserved_options', 'custom_preserved_options' );
@aprea
aprea / gist:9678766
Created Mar 21, 2014
Generate dummy WordPress posts
View gist:9678766
<?php
// Generates a SQL dump that imports a number of posts into the wp_posts table
set_time_limit(0);
$table_prefix = 'wp_';
$max_posts = 50000;
$max_inserts_per_query = 50;
$file = dirname( __FILE__ ) . '/dump.sql';
@aprea
aprea / Basic Dummy Comments
Last active Aug 29, 2015
A small WordPress plugin to create a bunch of dummy comments for a specified post
View Basic Dummy Comments
<?php
/*
Plugin Name: Basic Dummy Comments
Version: 0.1
Plugin URI: https://github.com/aprea
Description: Creates a bunch of dummy comments
Author: Chris Aprea
Author URI: https://gist.github.com/aprea/9344578
License: GPL v3
You can’t perform that action at this time.