Guest User

Untitled

a guest
Jul 23rd, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. /**
  2. * Customize Sell Content Price
  3. * Set a custom price for post content based on post type or
  4. * taxonomy relationships.
  5. * @mycred
  6. * @version 1.0
  7. */
  8. add_filter( 'mycred_get_content_price', 'mycred_pro_content_price_by_type', 10, 4 );
  9. function mycred_pro_content_price_by_type( $price, $post_id, $point_type, $user_id ) {
  10.  
  11. $post_type = get_post_type( $post_id );
  12.  
  13. // Pages always cost 5 points
  14. if ( $post_type == 'page' )
  15. return 5;
  16.  
  17. // Posts in the category "premium plus" costs 10 while all other posts cost 15
  18. if ( $post_type == 'post' ) {
  19.  
  20. $terms = wp_get_object_terms( $post_id, 'category', array( 'fields' => 'slugs' ) );
  21. if ( ! empty( $terms ) && in_array( 'premium-plus', $terms ) )
  22. return 10;
  23.  
  24. return 15;
  25.  
  26. }
  27.  
  28. // Returns default
  29. return $price;
  30.  
  31. }
Add Comment
Please, Sign In to add comment