Guest User

Untitled

a guest
Feb 23rd, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.33 KB | None | 0 0
  1. <?php
  2. /*
  3. |--------------------------------------------------------------------------
  4. | Template name: Listing Template
  5. |--------------------------------------------------------------------------
  6. |
  7. |
  8. */
  9.  
  10. get_header();
  11. $isAuthor = is_author();
  12. global $wilokeSidebarPosition, $wiloke;
  13. if ( $isAuthor ){
  14. $authorID = get_queried_object_id();
  15. WilokePublic::accountHeaderBg($authorID);
  16. $totalPosts = count_user_posts($authorID, 'listing');
  17. $suffix = $totalPosts > 1 ? esc_html__( 'Listings', 'listgo') : esc_html__( 'Listing', 'listgo');
  18. $totalPosts = $totalPosts . ' ' . $suffix;
  19. $profileUrl = WilokePublic::getPaymentField('myaccount', true);
  20. $profileUrl = !empty($profileUrl) ? WilokePublic::addQueryToLink($profileUrl, 'mode=profile&user='.$authorID) : '#';
  21. $colMd = ' col-md-8';
  22. }else{
  23. WilokePublic::headerPage();
  24. $colMd = ' col-md-9';
  25. }
  26.  
  27. $author = '';
  28. if ( $isAuthor ){
  29. $author = get_query_var('author');
  30. $listingLocations = '';
  31. $listingCats = '';
  32. $aTemplateSettings['sidebar_position'] = $wiloke->aThemeOptions['listing_sidebar_position'];
  33. $aTemplateSettings['layout'] = 'listing--list';
  34. $aTemplateSettings['display_style'] = 'loadmore';
  35. $aTemplateSettings['posts_per_page'] = get_option('posts_per_page');
  36. $aTemplateSettings['order_by'] = 'post_date';
  37. $aTemplateSettings['image_size'] = 'medium';
  38. $aTemplateSettings['get_posts_from'] = 'post_author';
  39. $aTemplateSettings['show_terms'] = 'listing_location';
  40. $wrapperClass = ' is-author-page';
  41. }else{
  42. $aTemplateSettings = Wiloke::getPostMetaCaching($post->ID, 'template_settings');
  43. $listingLocations = !empty($aTemplateSettings['listing_location']) ? implode(',', $aTemplateSettings['listing_location']) : '';
  44. $listingCats = !empty($aTemplateSettings['listing_cat']) ? implode(',', $aTemplateSettings['listing_cat']) : '';
  45. $aTemplateSettings['sidebar_position'] = isset($aTemplateSettings['sidebar_position']) && $aTemplateSettings['sidebar_position'] !== 'inherit' ? $aTemplateSettings['sidebar_position'] : $wiloke->aThemeOptions['listing_sidebar_position'];
  46. $aTemplateSettings['layout'] = !isset($aTemplateSettings['layout']) ? 'listing--list' : $aTemplateSettings['layout'];
  47. if ( is_tax('listing_cat') ){
  48. $aTemplateSettings['get_posts_from'] = 'listing_cat';
  49. }else if(is_tax('listing_location')){
  50. $aTemplateSettings['get_posts_from'] = 'listing_location';
  51. }else{
  52. $aTemplateSettings['get_posts_from'] = 'the_both_listing_location_and_listing_cat';
  53. }
  54.  
  55. if ( $aTemplateSettings['display_style'] === 'all' ){
  56. $aTemplateSettings['posts_per_page'] = -1;
  57. }
  58. $wrapperClass = '';
  59. }
  60.  
  61. switch ( $aTemplateSettings['sidebar_position'] ){
  62. case 'left':
  63. $mainClass = $colMd.' col-md-push-3';
  64. $wilokeSidebarPosition = 'left';
  65. break;
  66. case 'right':
  67. $mainClass = $colMd;
  68. $wilokeSidebarPosition = 'right';
  69. break;
  70. default:
  71. $mainClass = 'col-md-12';
  72. $wilokeSidebarPosition = 'no';
  73. break;
  74. }
  75. ?>
  76. <div class="section<?php echo esc_attr($wrapperClass); ?>">
  77. <div class="container">
  78. <div class="row">
  79. <div class="<?php echo esc_attr($mainClass); ?>">
  80.  
  81. <?php if ( $isAuthor ) :
  82. $aAuthorMeta = Wiloke::getUserMeta(get_queried_object()->ID);
  83. if ( !empty($aAuthorMeta['description']) ): ?>
  84. <div class="listing__author-description">
  85.  
  86. <?php echo wpautop($aAuthorMeta['description']); ?>
  87.  
  88. <?php if ( !empty(WilokePublic::$oUserInfo) && WilokePublic::$oUserInfo->ID == $aAuthorMeta['ID'] ) : ?>
  89. <a style="color: red" href="<?php echo esc_url(admin_url('user-edit.php?user_id='.WilokePublic::$oUserInfo->ID)); ?>"><?php esc_html_e('Edit profile', 'listgo'); ?></a>
  90. <?php endif; ?>
  91.  
  92. </div>
  93.  
  94. <?php endif ?>
  95.  
  96. <h2 class="listing__author-result">
  97. <?php echo esc_html($totalPosts); ?> <?php esc_html_e('By', 'listgo'); ?> <a href="<?php echo esc_url($profileUrl); ?>"><?php echo esc_html($aAuthorMeta['display_name']); ?></a>
  98. </h2>
  99.  
  100. <?php endif; ?>
  101.  
  102. <div class="listgo-listlayout-on-page-template">
  103. <?php if ( !$isAuthor ) : ?>
  104. <div class="from-wide-listing">
  105. <div class="from-wide-listing__header">
  106. <span class="from-wide-listing__header-title"><?php echo esc_html__('Filter', 'listgo') ?></span>
  107. <span class="from-wide-listing__header-close"><span>×</span> <?php echo esc_html__('Close', 'listgo') ?></span>
  108. </div>
  109. <?php WilokeSearchSystem::searchForm(null, true, array(), 'listing-template'); ?>
  110. <div id="listgo-mobile-search-only" class="from-wide-listing__footer">
  111. <span><?php echo esc_html__('Apply', 'listgo') ?></span>
  112. </div>
  113. </div>
  114. <?php endif; ?>
  115. <?php echo do_shortcode('[wiloke_listing_layout post_authors="'.$author.'" layout="'.$aTemplateSettings['layout'].'" order_by="'.$aTemplateSettings['order_by'].'" order="'.$aTemplateSettings['order'].'" show_terms="'.$aTemplateSettings['show_terms'].'" image_size="'.$aTemplateSettings['image_size'].'" display_style="'.$aTemplateSettings['display_style'].'" get_posts_from="'.$aTemplateSettings['get_posts_from'].'" posts_per_page="'.$aTemplateSettings['posts_per_page'].'" filter_type="none" sidebar="'. $wilokeSidebarPosition .'"]'); ?>
  116. </div>
  117. </div>
  118. <?php
  119. if ( $wilokeSidebarPosition !== 'no' ) {
  120. get_sidebar('taxlisting');
  121. }
  122. ?>
  123. </div>
  124. </div>
  125. </div>
  126. <?php
  127. get_footer();
Add Comment
Please, Sign In to add comment