Skip to content

Instantly share code, notes, and snippets.

@rickalday
rickalday / image-resize.php
Last active August 29, 2015 14:07
WordPress image resize functon
/**
* Resize an image to the specified dimensions
* http://codex.wordpress.org/Class_Reference/WP_Image_Editor
*
* Returns the new image file path
*
* @param image_url
* @param width
* @param width
* @return resized image file path
function get_post_siblings( $limit = 1, $date = '' ) {
global $wpdb, $post;
if( empty( $date ) )
$date = $post->post_date;
//$date = '2009-06-20 12:00:00'; // test data
$limit = absint( $limit );
if( !$limit )
//My custom Sell Media Loop
function my_sell_media_content_loop( $post_id, $i ){
$class = apply_filters( 'sell_media_grid_item_class', 'sell-media-grid-item', $post_id );
if ( ! sell_media_has_multiple_attachments( $post_id ) )
$class .= ' sell-media-grid-single-item';
$html = '<div id="sell-media-' . $post_id . '" class="' . $class . '">';
$parent = false;
if( !is_archive() ){
// if there is a post parent, change link to gallery
$parent = sell_media_attachment_parent_post( $post_id );
//Returns the Sell Media Item post title
function sell_media_custom_quick_view_text(){
global $post;
$title = get_the_title( $post->ID );
return $title;
}
add_filter( 'sell_media_quick_view_text', 'sell_media_custom_quick_view_text' );
@rickalday
rickalday / custom_get_the_archive_title
Created January 20, 2017 17:29
Rebuild the title for all the variants used in the original get_the_archive_title() function
// Return an alternate title, without prefix, for every type used in the get_the_archive_title().
add_filter('get_the_archive_title', function ($title) {
if ( is_category() ) {
$title = single_cat_title( '', false );
} elseif ( is_tag() ) {
$title = single_tag_title( '', false );
} elseif ( is_author() ) {
$title = '<span class="vcard">' . get_the_author() . '</span>';
} elseif ( is_year() ) {
$title = get_the_date( _x( 'Y', 'yearly archives date format' ) );
@rickalday
rickalday / custom_text_for_sell_media_products
Last active February 8, 2017 18:08
Filter for custom message for print or downloads
function my_sell_media_content_loop( $content ) {
global $post;
$post_id = $post->ID;
$parent_id = sell_media_get_attachment_parent_id( $post_id );
$post_id = ( '' === $parent_id ) ? $post_id : $parent_id;
$meta = get_post_meta( $post_id, '_sell_media_reprints_sell', true );
$message = '';
@rickalday
rickalday / sell_media_custom_tos
Created February 8, 2017 18:23
Custom TOS text and link for Sell Media Checkout page
function sell_media_custom_tos_text(){
return 'By clicking "Checkout Now", you are agreeing to our <a href="custom link here">terms of service</a>.';
}
add_filter( 'sell_media_tos_label', 'sell_media_custom_tos_text' );
#primary-menu>li>ul>li:nth-child(1) > a:after {
display: block;
content: '';
background: url(https://demo.graphpaperpress.com/composition/files/2016/09/screenshot-1024x640.jpg) no-repeat;
height: 125px;
max-width: 232px;
background-size: 100%;
margin: 1em 0 0;
}