Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function king_add_download($text){
- global $post;
- $user = wp_get_current_user();
- $thumb_URL = get_the_post_thumbnail_url( get_the_ID(), 'full' );
- $download_class = "_YOUR_CLASS_HERE";
- if(in_array('administrator', $user->roles)){
- if(($post->post_type == 'post')){
- $last_tag = strrpos( $text, "</" );
- $text = substr_replace( $text, '<div="'.$download_class.'"><a href="'.$thumb_URL.'">Download this Image</a></div>', $last_tag, 0 );
- }
- }
- else{
- $last_tag = strrpos( $text, "</" );
- $text = substr_replace( $text, '<div="'.$download_class.'"><a href="#">Download this Image</a></div>', $last_tag, 0 );
- }
- return $text;
- }
- add_filter('the_content','king_add_download', 1);
Add Comment
Please, Sign In to add comment