Created
June 24, 2014 17:36
-
-
Save curtismchale/dd47b52a4c47de8145d6 to your computer and use it in GitHub Desktop.
Moves the EDD Purchase button (and variations) to the top of the content instead of placing it at the bottom. Removes the original purchase links so they don't show up twice. Blogged: http://wp.me/p1Fud2-1of June 26, 2014
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Puts the purchase links before the content | |
* | |
* @since 1.0.0 | |
* @global $post | |
* @author SFNdesign, Curtis McHale | |
* | |
* @param $content The the_content field of the download object | |
* @return string the content with any additional data attached | |
*/ | |
function sfn_edd_purchase_at_top( $content ) { | |
global $post; | |
if ( $post && $post->post_type == 'download' && is_singular( 'download' ) && is_main_query() && !post_password_required() ) { | |
ob_start(); | |
$download_id = absint( $post->ID ); | |
if ( ! get_post_meta( $download_id, '_edd_hide_purchase_link', true ) ) { | |
echo edd_get_purchase_link( array( 'download_id' => $download_id ) ); | |
} | |
$new_content .= ob_get_clean(); | |
$content = $new_content . $content; | |
} | |
return $content; | |
} | |
add_filter( 'the_content', 'sfn_edd_purchase_at_top' ); | |
remove_action( 'edd_after_download_content', 'edd_append_purchase_link' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment