Skip to content

Instantly share code, notes, and snippets.

View pippinsplugins's full-sized avatar

Pippin Williamson pippinsplugins

View GitHub Profile
@pippinsplugins
pippinsplugins / all_post_types.php
Created April 21, 2012 16:54
All Post Types in Search
<?php
function ecpt_include_post_types_in_search($query) {
if(is_search()) {
$post_types = get_post_types(array('public' => true, 'exclude_from_search' => false), 'objects');
$searchable_types = array();
if($post_types) {
foreach( $post_types as $type) {
$searchable_types[] = $type->name;
}
@pippinsplugins
pippinsplugins / edd-currencies.php
Created April 25, 2012 20:52
EDD Currency Function
function edd_get_currencies() {
$currencies = apply_filters('edd_currencies', array(
'USD' => __('US Dollars (&#36;)', 'edd'),
'EUR' => __('Euros (&euro;)', 'edd'),
'GBP' => __('Pounds Sterling (&pound;)', 'edd'),
'AUD' => __('Australian Dollars (&#36;)', 'edd'),
'BRL' => __('Brazilian Real (&#36;)', 'edd'),
'CAD' => __('Canadian Dollars (&#36;)', 'edd'),
'CZK' => __('Czech Koruna', 'edd'),
'DKK' => __('Danish Krone', 'edd'),
@pippinsplugins
pippinsplugins / gist:2579659
Created May 2, 2012 19:41
Trying to change upload directory on "download" post type
<?php
function edd_load_upload_filter() {
add_action('load-edit.php', 'edd_change_downloads_upload_dir');
add_action('load-post.php', 'edd_change_downloads_upload_dir');
}
add_action('admin_init', 'edd_load_upload_filter');
function edd_change_downloads_upload_dir() {
$current_screen = get_current_screen();
@pippinsplugins
pippinsplugins / meta_field_class.php
Created May 7, 2012 15:23
Adds the value of an ECPT meta field to the post class
function ecpt_meta_field_classes($classes) {
$meta_value = get_post_meta(get_the_ID(), 'ecpt_fieldname', true);
if($meta_value) {
$classes[] = $meta_value;
}
return $classes;
}
add_filter('post_class', 'ecpt_meta_field_classes');
@pippinsplugins
pippinsplugins / edd_grid.php
Last active April 24, 2020 17:48
sample Easy Digital Downloads Product Grid with Pagination
<?php get_header(); ?>
<div id="main-content" class="row store-template">
<div class="content clearfix">
<?php
$current_page = get_query_var('paged');
$per_page = get_option('posts_per_page');
$offset = $current_page > 0 ? $per_page * ($current_page-1) : 0;
$product_args = array(
'post_type' => 'download',
@pippinsplugins
pippinsplugins / edd_cart_quantity.php
Created May 24, 2012 01:31
Easy Digital Downloads Cart Quantity
<a href="<?php echo edd_get_checkout_uri(); ?>">
Cart (<span class="header-cart edd-cart-quantity"><?php echo edd_get_cart_quantity(); ?></span>)
</a>
@pippinsplugins
pippinsplugins / edd_download_comments.php
Created May 24, 2012 01:37
Adds support for comments to the "Downloads" post type
<?php
function modify_edd_product_supports($supports) {
$supports[] = 'comments';
return $supports;
}
add_filter('edd_download_supports', 'modify_edd_product_supports');
@pippinsplugins
pippinsplugins / edd_post_type_labels.php
Created May 24, 2012 01:42
Modify the labels of the Downloads post type for Easy Digital Downloads
<?php
function set_download_labels($labels) {
$labels = array(
'name' => _x('Products', 'post type general name', 'your-domain'),
'singular_name' => _x('Product', 'post type singular name', 'your-domain'),
'add_new' => __('Add New', 'your-domain'),
'add_new_item' => __('Add New Product', 'your-domain'),
'edit_item' => __('Edit Product', 'your-domain'),
'new_item' => __('New Product', 'your-domain'),
'all_items' => __('All Products', 'your-domain'),
@pippinsplugins
pippinsplugins / ecpt_dates.php
Created May 25, 2012 16:51
Show nice dates from ECPT date meta fields
<?php
echo date( get_option('date_format'), get_post_meta( $post->ID, 'ecpt_datefieldname', true) );
<?php
function edd_change_downloads_upload_dir() {
global $pagenow;
if ( ! empty( $_POST['post_id'] ) && ( 'async-upload.php' == $pagenow || 'media-upload.php' == $pagenow ) ) {
if ( 'download' == get_post_type( $_REQUEST['post_id'] ) ) {
$wp_upload_dir = wp_upload_dir();
$upload_path = $wp_upload_dir['basedir'] . '/edd' . $wp_upload_dir['subdir'];
if (wp_mkdir_p($upload_path) && !file_exists($upload_path.'/.htaccess')) {