Last active
May 31, 2017 16:49
-
-
Save SeanChDavis/b99b497f10cd1b1cf64d to your computer and use it in GitHub Desktop.
EDD Points & Rewards - message placement
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 // don't copy this line | |
// Change callback function for points message | |
if ( class_exists( 'EDD_Points_Renderer' ) ) { | |
// remove default points message | |
remove_action( 'edd_before_download_content', array( $edd_points_render, 'edd_points_message_content' ), 10 ); | |
// call new points message function | |
add_action( 'edd_before_download_content', 'sd_custom_points_message', 10 ); | |
// Points & Rewards message based on single download category | |
function sd_custom_points_message() { | |
global $edd_points_render, $post; | |
// if in the category-slug category, show custom message | |
if ( has_term( 'category-slug', 'download_category', $post->ID ) ) { | |
?> | |
<div class="edd-points-product-message">CUSTOM MESSAGE</div> | |
<?php | |
} else { | |
// otherwise, show message from Points & Rewards settings | |
add_action( 'edd_before_download_content', array( $edd_points_render, 'edd_points_message_content' ), 0 ); | |
} | |
} | |
} | |
/** | |
* Move points message below content | |
*/ | |
function sd_move_pr_output() { | |
global $edd_points_render; | |
if ( class_exists( 'EDD_Points_Renderer' ) ) { | |
// remove default points message | |
remove_action( 'edd_before_download_content', array( $edd_points_render, 'edd_points_message_content' ), 10 ); | |
// add points message below content | |
add_action( 'edd_after_download_content', array( $edd_points_render, 'edd_points_message_content' ), 10 ); | |
} | |
} | |
add_action( 'init', 'sd_move_pr_output' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment