Skip to content

Instantly share code, notes, and snippets.

View eteubert's full-sized avatar

Eric Teubert eteubert

View GitHub Profile
@eteubert
eteubert / upgrade.md
Created September 4, 2012 10:01
Podlove Publisher Upgrade to 1.2.x Troubleshooting

Podlove Publisher Upgrade to 1.2.x Troubleshooting

Feed URLs

All Feed URLs have changed. The show slug is not part of the URL any more. If you use Feedburner, remember to adjust the URL.

If you want your old URLs to work, you can add a manual redirect by adding some rules to your .htaccess:

# Pattern
Redirect 302 /feed/// /feed//
<?php
function podlove_camelcase_to_snakecase( $string ) {
return preg_replace( '/([a-z])([A-Z])/', '$1_$2', $string );
}
function podlove_camelsnakecase_to_camelcase( $string ) {
return str_replace( '_', '', $string );
}
@eteubert
eteubert / anonymous.php
Created June 30, 2012 09:03
WordPress: Thoughts on Filtering by Time
<?php
$age_filter = function ( $where = '' ) use ( $options ) {
$where .= " AND post_date > '" . date( 'Y-m-d', strtotime( '-' . $options[ 'max_post_age' ] ) ) . "'";
return $where;
};
add_filter( 'posts_where', $age_filter );
$query = new WP_Query( $args );
remove_filter( 'posts_where', $age_filter );
@eteubert
eteubert / similar_posts.php
Created June 15, 2012 09:59
WordPress: Similar posts by matching tags
<?php
/**
* Return posts with maximum age of one year.
*
* Usage:
* add_filter( 'posts_where', 'wp_query_filter_max_one_year_old' );
* $my_query = new WP_Query( array( ... ) );
* remove_filter( 'posts_where', 'wp_query_filter_max_one_year_old' );
*
* @param string $where
@eteubert
eteubert / template.html
Created April 23, 2012 07:08
Multi Feed Reader Template
<!-- before template -->
<table>
<thead>
<th>Title</th>
<th>URL</th>
<th>published</th>
</thead>
<tbody>
<?php
/**
* @package WordPress
* @subpackage MarketPress Theme
* @template page
* @since 0.0.1
*/
?>
<?php get_header(); ?>
@eteubert
eteubert / public_api.php
Created February 27, 2012 15:07
dtpr_get_all_user_capabilities
<?php
/**
* Return array containing all capabilities that user has access to.
* If he is an admin, the list will contain all available capability IDs.
*
* @param $user_id integer
* @return array
*/
function dtpr_get_all_user_capabilities( $user_id ) {
global $wpdb;
@eteubert
eteubert / archivist.html
Created February 25, 2012 16:27
archivist template
<table>
<thead>
<tr>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
@eteubert
eteubert / public_api.php
Created February 25, 2012 16:22
dtpr: dtpr_get_user_capability_names
<?php
/**
* Get capability names array of user.
*
* Example output:
*
* Array
* (
* [1] => Array
* (
@eteubert
eteubert / after.html
Created February 9, 2012 20:10
Multi Feed Reader Example
</tbody>
</table>