Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Replace the mycred_link shortcode
- * @version 1.0
- */
- add_action( 'mycred_init', 'mycredpro_replace_link_click_shortcode', 990 );
- function mycredpro_replace_link_click_shortcode() {
- remove_shortcode( 'mycred_link' );
- add_shortcode( 'mycred_link', 'mycredpro_render_shortcode_link' );
- }
- /**
- * Before showing the mycred_link shortcode, make sure the user
- * can afford to click on it.
- * @version 1.0
- */
- function mycredpro_render_shortcode_link( $atts, $content = '' ) {
- extract( shortcode_atts( array( 'amount' => 0, 'ctype' => 'mycred_default' ), $atts ) );
- if ( ! is_user_logged_in() ) return '';
- $mycred = mycred( $ctype );
- $balance = $mycred->get_users_balance( get_current_user_id(), $ctype );
- // Do not show anything if a user can not afford to click
- if ( $balance < abs( $amount ) ) return '';
- // Let myCRED generate the shortcode for us
- return mycred_render_shortcode_link( $atts, $content );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement