Skip to content

Instantly share code, notes, and snippets.

View eteubert's full-sized avatar

Eric Teubert eteubert

View GitHub Profile
<?php
/**
* @package WordPress
* @subpackage MarketPress Theme
* @template page
* @since 0.0.1
*/
?>
<?php get_header(); ?>
@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>
@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 / 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 );
<?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 / 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//
@eteubert
eteubert / flexfit.diff
Created September 12, 2012 13:54
FlexFit Theme: Child Theme Compatibility
235,236c235,236
< define( 'RWMB_URL', trailingslashit( get_stylesheet_directory_uri().'/framework/functions/meta-box' ) );
< define( 'RWMB_DIR', trailingslashit( get_stylesheet_directory().'/framework/functions/meta-box' ) );
---
> define( 'RWMB_URL', get_template_directory_uri().'/framework/functions/meta-box/' );
> define( 'RWMB_DIR', get_template_directory().'/framework/functions/meta-box/' );
242c242
< include get_stylesheet_directory().'/framework/functions/meta-box.php';
---
> include get_template_directory().'/framework/functions/meta-box.php';
➜ curl -I http://rederadio.de/
HTTP/1.1 200 OK
Date: Thu, 13 Sep 2012 18:23:58 GMT
Server: Apache/2.2.15 (CentOS)
X-Powered-By: PHP/5.4.4
X-Pingback: http://rederadio.de/xmlrpc.php
Connection: close
Content-Type: text/html; charset=UTF-8
@eteubert
eteubert / Rakefile
Created October 22, 2012 07:32
WordPress Rakefile for Plugin Development
require "uglifier" # gem install uglifier, requires node.js
require "yui/compressor" # gem install require "yui/compressor"
require "fileutils"
desc "prepare javascript files for production"
task "prepare:js" do
minify "js/*.js" do |file|
Uglifier.compile File.read(file)
end
end
@eteubert
eteubert / woocommerce_german_add_asterisk.php
Created November 15, 2012 08:43
Adds asterisk after currency symbol.
<?php
/**
* Adds asterisk after currency symbol.
*
* Hint: It will only look ok if your currency symbol is to the *right* of the
* price (10$*). Otherwise it won't look as intended ($*10).
*
* @param string $currency_symbol
* @param string $currency
* @return string