Guest User

WP-LiveEdit with User Role only for own Posts

a guest
Dec 21st, 2013
301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php if(!is_single()) { global $more; $more = 0; } //enable more link ?>
  2. <?php
  3. /** Themify Default Variables
  4.  *  @var object */
  5. global $themify; ?>
  6.  
  7. <?php
  8. // Check if User can Edit
  9. $current_user_is_allowed_to_edit = false;
  10. $user_ID = get_current_user_id();
  11. $post_author_ID = the_author_meta('ID');
  12.  
  13. if ( current_user_can('delete_posts') || $post_author_ID == $user_ID ) {
  14.     $current_user_is_allowed_to_edit = true;
  15. }
  16. ?>
  17.  
  18. <?php themify_post_before(); //hook ?>
  19. <article id="post-<?php the_ID(); ?>" <?php post_class( 'post clearfix ' . $themify->get_categories_as_classes(get_the_ID()) . ' ' . $themify->get_post_color_class(get_the_ID()) ); if( function_exists("live_edit") && $current_user_is_allowed_to_edit ){ live_edit('post_title, post_content, field1'); } ?>>
  20.     <?php themify_post_start(); //hook ?>
  21.    
  22.         <?php if ( $themify->hide_image != 'yes' ) : ?>
  23.        
  24.         <?php themify_before_post_image(); // Hook ?>
  25.        
  26.         <?php if ( themify_get( 'video_url' ) != '' ) : ?>
  27.            
  28.             <?php
  29.                 global $wp_embed;
  30.                 echo $wp_embed->run_shortcode('[embed]' . themify_get('video_url') . '[/embed]');
  31.             ?>
  32.  
  33.         <?php elseif( $post_image = themify_get_image($themify->auto_featured_image . $themify->image_setting . "w=".$themify->width."&h=".$themify->height) ) : ?>
  34.            
  35.             <figure class="post-image <?php echo $themify->image_align; ?>">
  36.                 <?php if( 'yes' == $themify->unlink_image): ?>
  37.                     <?php echo $post_image; ?>
  38.                 <?php else: ?>
  39.                     <a href="<?php echo themify_get_featured_image_link(); ?>"><?php echo $post_image; ?><?php themify_zoom_icon(); ?></a>
  40.                 <?php endif; // unlink image ?>
  41.             </figure>
  42.        
  43.         <?php endif; // video else image ?>
  44.        
  45.         <?php themify_after_post_image(); // Hook ?>
  46.  
  47.     <?php endif; // hide image ?>
  48.  
  49.     <div class="post-inner">
  50.        
  51.         <span class="post-icon"></span>
  52.         <!-- /post-icon -->
  53.        
  54.         <?php if($themify->hide_title != "yes"): ?>
  55.             <?php themify_before_post_title(); // Hook ?>
  56.             <?php if($themify->unlink_title == "yes"): ?>
  57.                 <h1 class="post-title"><?php the_title(); ?></h1>
  58.             <?php else: ?>
  59.                 <h1 class="post-title"><a href="<?php echo themify_get_featured_image_link(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h1>
  60.             <?php endif; //unlink post title ?>
  61.             <?php themify_after_post_title(); // Hook ?>
  62.         <?php endif; //post title ?>
  63.         <!-- / Title -->
  64.  
  65.         <?php get_template_part('includes/loop-' . $themify->get_format_template()); ?>
  66.        
  67.         <?php if(is_single()): ?>
  68. <div <?php if( function_exists("live_edit") && $current_user_is_allowed_to_edit ){ live_edit('post_title, myfield2'); }?>>
  69.     <?php if( function_exists('the_field') ) the_field('myfield1'); ?> </div>
  70.     <?php if( function_exists('the_field') ) the_field('myfield2');  ?>
  71. </div>
  72.             <?php wp_link_pages(array('before' => '<p><strong>' . __('Pages:', 'themify') . '</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
  73.  
  74.             <?php get_template_part( 'includes/author-box', 'single'); ?>
  75.            
  76.             <?php get_template_part( 'includes/post-nav'); ?>
  77.            
  78.             <?php if(!themify_check('setting-comments_posts')): ?>
  79.                 <?php comments_template(); ?>
  80.             <?php endif; ?>
  81.         <?php endif; ?>
  82.        
  83.     </div>
  84.     <!-- /.post-inner -->
  85.    
  86.     <?php themify_post_end(); //hook ?>
  87. </article>
  88. <!-- /.post -->
  89. <?php themify_post_after(); //hook ?>
Add Comment
Please, Sign In to add comment