Advertisement
nfmohit

Untitled

Jan 17th, 2018
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 10.88 KB | None | 0 0
  1. <?php
  2. /**
  3.  * BuddyPress User Blog - Post Create
  4.  *
  5.  * @package WordPress
  6.  * @subpackage BuddyPress User Blog
  7.  */
  8.  
  9. $theme       = wp_get_theme(); // gets the current theme
  10. $theme_name  = $theme->template;
  11.  
  12. $container       = '';
  13. $container_class = '';
  14. $content_class   = '';
  15. $sidebar_class   = '';
  16.  
  17. if ( 'kleo' == $theme_name ) {
  18.     $container       = ' kleo-sap-wrapper';
  19. }
  20.  
  21. if ( 'boss' == $theme_name || 'social-portfolio' == $theme_name ) {
  22.     $container       = ' boss-sap-wrapper';
  23. }
  24.  
  25. $old_post   = '';
  26. $content    = isset( $_POST[ 'content' ] ) ? $_POST[ 'content' ] : '';
  27. $title      = isset( $_POST[ 'title' ] ) ? $_POST[ 'title' ] : '';
  28.  
  29. if ( isset($_GET['post']) && !empty($_GET['post']) ) {
  30.     $pid = $_GET['post'];
  31.     $post_data = get_post($pid);
  32. }
  33.  
  34. if ( !empty( $post_data ) && 'trash' != $post_data->post_status && get_current_user_id() == $post_data->post_author ) {
  35.     $old_post = 'true';
  36. }
  37.  
  38. if ( $old_post == 'true' ) {
  39.     $edit_status    = 'true';
  40.     $draft_id       = $pid;
  41.     $post_status    = $post_data->post_status;
  42.     $post_status_content = ucfirst($post_data->post_status);
  43.     $old_title = $post_data->post_title;
  44.     $old_content    = apply_filters( 'bp-user-blog_editable_content', $post_data->post_content );
  45.     $post_category  = wp_get_post_categories($pid);
  46.     $permalink      = get_the_permalink($pid);
  47.     $class_to_apply   = '';
  48.     $featured_image_id_src = wp_get_attachment_image_src( get_post_thumbnail_id( $pid ) ,'medium' );
  49.     $draft_btn_txt = __('Revert to draft','bp-user-blog');
  50.    
  51.     if ( 'publish' == $post_status ) {
  52.         $post_status_content = __('Published','bp-user-blog');
  53.         $view_btn_txt = __('View','bp-user-blog');
  54.     } elseif( 'pending' == $post_status ) {
  55.         $view_btn_txt = __('Preview','bp-user-blog');
  56.     } else {
  57.         $view_btn_txt = __('Preview','bp-user-blog');
  58.         $draft_btn_txt = __('Save','bp-user-blog');
  59.     }
  60.    
  61. } else {
  62.     $pid            = '';
  63.     $post_category  = '';
  64.     $edit_status    = '';
  65.     $draft_id       = '';
  66.     $post_status    = '';
  67.     $old_title    = '';
  68.     $old_content    = '';
  69.     $permalink      = '';
  70.     $class_to_apply = 'sap-disabled';
  71.     $post_status_content = __('Draft','bp-user-blog');
  72.     $featured_image_id_src = '';
  73.     $draft_btn_txt = __('Save','bp-user-blog');
  74.     $view_btn_txt = __('Preview','bp-user-blog');
  75. }
  76.  
  77. ?>
  78.  
  79. <div class="sap-container-wrapper<?php echo $container; ?>">
  80.  
  81.     <div class="sap-container<?php echo $container_class; ?>">
  82.  
  83.         <div class="sap-editor-wrap<?php echo $content_class; ?>">
  84.             <div class="sap-post-author-wrap">
  85.  
  86.                 <?php
  87.                 global $current_user;
  88.  
  89.                 $current_user_id = get_current_user_id();
  90.                 $publish_post = buddyboss_sap()->option( 'publish_post' );
  91.                                
  92.                                 $displayed_user_id = bp_displayed_user_id();
  93.                                 $user_domain = (!empty($displayed_user_id) ) ? bp_displayed_user_domain() : bp_loggedin_user_domain();
  94.  
  95.                                 $blog_link = trailingslashit($user_domain . __('blog', 'bp-user-blog'));
  96.  
  97.                 if ( $publish_post ) {
  98.                     $button_text = __( 'Publish', 'bp-user-blog' );
  99.                 } else {
  100.                     $button_text = __( 'Submit for Review', 'bp-user-blog' );
  101.                 } ?>
  102.  
  103.                                 <a href="<?php echo $blog_link; ?>"><?php echo get_avatar( get_current_user_id(), 100 ); ?></a>
  104.                                
  105.                 <div class="sap-author-info">
  106.                                     <a class="sap-author-name" href="<?php echo $blog_link; ?>"><?php echo esc_html( $current_user->display_name ); ?></a>
  107.                                     <p class="sap-post-status"><?php echo $post_status_content; ?></p>
  108.                 </div>
  109.             </div>
  110.            
  111.            <div class="side-panel">
  112.                 <div class="sap-editor-toolbar">
  113.                    
  114.                 <a href="#" class="toggle-sap-widgets" title="<?php _e( 'More Actions', 'bp-user-blog' ); ?>">
  115.                     <svg class="write-story-icon" xmlns="http://www.w3.org/2000/svg" width="30" height="30" viewBox="0 0 30 30">
  116.                     <path id="write_a_story" data-name="write a story" class="cls-1" d="M4.2,12.214h11.5v0.873l-0.279.279H4.2V12.214Zm0,3.455h8.925l-1.151,1.152H4.2V15.67Zm6.9,8.062H4.2V22.58h6.9v1.152ZM4.2,19.125H9.938L9.563,20.25H9.213L9.24,20.277H4.2V19.125ZM19.158,21.8v3.088a2.3,2.3,0,0,1-2.3,2.3H3.051a2.3,2.3,0,0,1-2.3-2.3V5.517A2.5,2.5,0,0,1,3.051,3H15.526l3.632,3.636v3l-1.151,1.152V8.758h-3.26a1.343,1.343,0,0,1-1.342-1.344V4.151H3.051A1.354,1.354,0,0,0,1.9,5.518V24.883a1.151,1.151,0,0,0,1.15,1.152H16.857a1.151,1.151,0,0,0,1.151-1.152V22.947Zm-4.6-15.052a0.863,0.863,0,0,0,.863.864h1.726a0.863,0.863,0,0,0,.863-0.864L15.418,4.151a0.863,0.863,0,0,0-.863.864V6.743Z"/>
  117.                     <path id="write_a_post_icon_copy_2" data-name="write a post icon copy 2" class="cls-2" d="M29.188,9.323L15.9,22.626l-3.976,1.106-0.057-.057a0.59,0.59,0,0,1-.707-0.707L11.1,22.911l1.1-3.98L25.5,5.628a0.85,0.85,0,0,1,1.2.029L29.159,8.12A0.852,0.852,0,0,1,29.188,9.323ZM13.959,19.118a0.385,0.385,0,0,0-.353-0.354l-0.788.789-0.784,2.474a0.614,0.614,0,0,0,.773.774l2.471-.785,0.788-.789-0.057-.057c-0.345.084-.41-0.41-0.41-0.41a0.584,0.584,0,0,0-.158-0.549,1.22,1.22,0,0,0-.662-0.272,0.583,0.583,0,0,1-.549-0.158A1.222,1.222,0,0,1,13.959,19.118ZM23.572,8.787l-9.38,9.39a0.461,0.461,0,0,1,.353.354,1.222,1.222,0,0,0,.272.663,0.582,0.582,0,0,0,.549.158,1.221,1.221,0,0,1,.662.272,0.584,0.584,0,0,1,.158.549L16.3,20.287c-0.091.376,0.353,0.354,0.353,0.354l9.38-9.39Zm3.146-2.328a0.64,0.64,0,0,0-.8-0.019L24.158,8.2l2.461,2.464L28.378,8.9a0.626,0.626,0,0,0-.019-0.8Z"/>
  118.                     </svg>
  119.  
  120.                     <svg class="remove-icon" version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
  121.                      width="20px" height="20px" viewBox="0 0 20 20" enable-background="new 0 0 20 20" xml:space="preserve">
  122.                     <path fill-rule="evenodd" clip-rule="evenodd" fill="none" d="M1.588,0.174l18.231,18.23l-1.415,1.414L0.174,1.588L1.588,0.174z"/>
  123.                     <path fill-rule="evenodd" clip-rule="evenodd" fill="none" d="M0.193,18.392L18.404,0.181l1.414,1.415L1.607,19.806L0.193,18.392z"/>
  124.                     </svg>
  125.                     </a>
  126.  
  127.                     <div class="sap-editor-publish-wrapper clearfix">
  128.  
  129.                         <div class="sap-publish-popup">\
  130.                             <a class="button button-primary" href="https://help.tenno.network/" title="Help" >Help!</a>
  131.                             <?php
  132.                             if ( $publish_post ) {
  133.                                    if ( $old_post == 'true' && $post_status != 'draft' ) { ?>
  134.                                         <a class="sap-story-update sap-action-button sap-story-update-btn button button-primary" href="#" title="<?php _e('Update','bp-user-blog'); ?>" ><?php _e('Update','bp-user-blog'); ?></a><?php
  135.                                    } else { ?>
  136.                                         <a class="sap-story-publish sap-action-button sap-story-publish-btn button button-primary" href="#" title="<?php _e('Publish post','bp-user-blog'); ?>" ><?php echo $button_text ?></a><?php
  137.                                    }
  138.                             } else {
  139.                                    if ( $old_post == 'true' && $post_status == 'pending' ) { ?>
  140.                                         <a style="display:none;" class="sap-story-review sap-action-button sap-story-review-btn button button-primary" href="#" title="<?php _e('Submit post for review','bp-user-blog'); ?>" ><?php echo $button_text ?></a>
  141.                                         <a class="sap-pending-preview sap-pending-preview-btn button button-secondary sap-disabled" ><?php _e('In Review','bp-user-blog'); ?></a><?php
  142.                                    } else { ?>
  143.                                         <a class="sap-story-review sap-action-button sap-story-review-btn button button-primary" href="#" title="<?php _e('Submit post for review','bp-user-blog'); ?>" ><?php echo $button_text ?></a>
  144.                                         <a style="display:none;" class="sap-pending-preview sap-pending-preview-btn button button-secondary sap-disabled" ><?php _e('In Review','bp-user-blog'); ?></a><?php
  145.                                    }
  146.                             }
  147.                             ?>
  148.                             <a class="sap-story-draft sap-story-draft-btn button button-secondary" href="#" ><?php echo $draft_btn_txt; ?></a>
  149.                                                     <a class="sap-story-preview sap-story-preview-btn button button-secondary <?php echo $class_to_apply; ?>" target="_blank" href="<?php echo $permalink; ?>" title="<?php _e('Show preview in new window','bp-user-blog'); ?>" ><?php echo $view_btn_txt; ?></a>
  150.                         </div>
  151.  
  152.                     </div>
  153.  
  154.                 </div>
  155.  
  156.                 <div class="sap-widget-container" id="sap-widget-container">
  157.                     <?php sap_post_category_tags_widget($pid, $post_category); ?>
  158.                     <?php sap_post_featured_img_widget(); ?>
  159.  
  160.                     <?php if ( $old_post == 'true') { ?>
  161.                         <a class="sap-story-delete sap-story-delete-btn" href="#"><?php _e('Delete','bp-user-blog'); ?></a><?php
  162.                     } else { ?>
  163.                         <a style="display:none;" class="sap-story-delete sap-story-delete-btn" href="#"><?php _e('Delete','bp-user-blog'); ?></a><?php
  164.                     } ?>
  165.                 </div>
  166.             </div>
  167.  
  168.             <div class="sap-editor-area-wrapper">
  169.                 <textarea class="sap-editable-title" data-disable-toolbar="true" ><?php echo $old_title; ?></textarea>
  170.                 <textarea class="sap-editable-area"><?php echo $old_content; ?></textarea>
  171.             </div>
  172.  
  173.             <input type="hidden" class="sap-editor-nonce" name="sap_editor_nonce" value="<?php echo wp_create_nonce( 'sap-editor-nonce' ); ?>" />
  174.             <input type="hidden" id="sap-draft-pid" name="draft_pid" value="<?php echo $draft_id; ?>" />
  175.             <input type="hidden" id="sap-draft-status" name="draft_status" value="<?php echo $post_status; ?>" />
  176.             <input type="hidden" id="sap-edit-status" name="edit_status" value="<?php echo $edit_status; ?>" />
  177.  
  178.         </div>
  179.  
  180.     </div>
  181.  
  182. </div>
  183.  
  184. <script>
  185.     var content = '<?php echo $content; ?>',
  186.         title = '<?php echo $title; ?>';
  187.     if ( title ) {
  188.         jQuery( '.sap-editable-title' ).html( title );
  189.     }
  190.     if ( content ) {
  191.         jQuery( '.sap-editable-area' ).html( content );
  192.     }
  193.     <?php if ( !empty($featured_image_id_src) ) { ?>
  194.         jQuery('.featured-img-preview').attr('src','<?php echo $featured_image_id_src['0']; ?>' ).show();
  195.         jQuery('#featured-img-placeholder').hide();
  196.         jQuery('#featured-img-placeholder-id').val();
  197.         jQuery('.sap-preview-close').show(<?php echo get_post_thumbnail_id( $pid ); ?>);
  198.     <?php } ?>
  199. </script>
  200.  
  201. <?php
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement