Skip to content

Instantly share code, notes, and snippets.

Avatar

Pippin Williamson pippinsplugins

View GitHub Profile
@pippinsplugins
pippinsplugins / all_post_types.php
Created Apr 21, 2012
All Post Types in Search
View all_post_types.php
<?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;
}
View edd-currencies.php
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
Trying to change upload directory on "download" post type
View gist:2579659
<?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
Adds the value of an ECPT meta field to the post class
View meta_field_class.php
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 Apr 24, 2020
sample Easy Digital Downloads Product Grid with Pagination
View edd_grid.php
<?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
Easy Digital Downloads Cart Quantity
View edd_cart_quantity.php
<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
Adds support for comments to the "Downloads" post type
View edd_download_comments.php
<?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
Modify the labels of the Downloads post type for Easy Digital Downloads
View edd_post_type_labels.php
<?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
Show nice dates from ECPT date meta fields
View ecpt_dates.php
<?php
echo date( get_option('date_format'), get_post_meta( $post->ID, 'ecpt_datefieldname', true) );
View edd_change_uploads.php
<?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')) {
You can’t perform that action at this time.