Advertisement
brownboots

search.php

Jan 23rd, 2020
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.12 KB | None | 0 0
  1. <?php
  2. /**
  3. * Template for search results.
  4. *
  5. * @package Avada
  6. * @subpackage Templates
  7. */
  8.  
  9. // Do not allow directly accessing this file.
  10. if ( ! defined( 'ABSPATH' ) ) {
  11. exit( 'Direct script access denied.' );
  12. }
  13. ?>
  14. <?php get_header(); ?>
  15. <section id="content" <?php Avada()->layout->add_class( 'content_class' ); ?> <?php Avada()->layout->add_style( 'content_style' ); ?>>
  16. <?php if ( have_posts() && 0 !== strlen( trim( get_search_query() ) ) ) : ?>
  17.  
  18. <?php if ( 'bottom' === Avada()->settings->get( 'search_new_search_position' ) ) : ?>
  19. <?php get_template_part( 'templates/blog', 'layout' ); ?>
  20. <div class="fusion-clearfix"></div>
  21. <?php endif; ?>
  22.  
  23. <?php if ( 'hidden' !== Avada()->settings->get( 'search_new_search_position' ) ) : ?>
  24. <div class="search-page-search-form search-page-search-form-<?php echo esc_attr( Avada()->settings->get( 'search_new_search_position' ) ); ?>">
  25. <?php
  26. /**
  27. * Render the post title
  28. */
  29. $title_size = ( false === avada_is_page_title_bar_enabled( 0 ) ? '1' : '2' );
  30. echo avada_render_post_title( 0, false, esc_html__( 'Need a new search?', 'Avada' ), $title_size ); // phpcs:ignore WordPress.Security.EscapeOutput
  31. ?>
  32. <p><?php esc_html_e( 'If you didn\'t find what you were looking for, try a new search!', 'Avada' ); ?></p>
  33. <?php get_search_form(); ?>
  34. </div>
  35. <?php endif; ?>
  36.  
  37. <?php if ( 'top' === Avada()->settings->get( 'search_new_search_position' ) || 'hidden' === Avada()->settings->get( 'search_new_search_position' ) ) : ?>
  38. <?php get_template_part( 'templates/blog', 'layout' ); ?>
  39. <?php endif; ?>
  40.  
  41. <?php else : ?>
  42.  
  43. <div class="post-content">
  44.  
  45. <?php Avada()->template->title_template( esc_html__( 'Couldn\'t find what you\'re looking for!', 'Avada' ) ); ?>
  46. <div class="error-page">
  47. <div class="fusion-columns fusion-columns-3">
  48. <div class="fusion-column col-lg-4 col-md-4 col-sm-4 fusion-error-page-oops">
  49. <h1 class="oops"><?php esc_html_e( 'Oops!', 'Avada' ); ?></h1>
  50. </div>
  51. <div class="fusion-column col-lg-4 col-md-4 col-sm-4 useful-links fusion-error-page-useful-links">
  52. <h3><?php esc_html_e( 'Helpful Links:', 'Avada' ); ?></h3>
  53. <?php
  54. // Get needed checklist default settings.
  55. $circle_class = ( Avada()->settings->get( 'checklist_circle' ) ) ? 'circle-yes' : 'circle-no';
  56. $font_size = Fusion_Sanitize::convert_font_size_to_px( Avada()->settings->get( 'checklist_item_size' ), Avada()->settings->get( 'body_typography', 'font-size' ) );
  57. $checklist_divider = ( 'yes' === Avada()->settings->get( 'checklist_divider' ) ) ? ' fusion-checklist-divider' : '';
  58.  
  59. // Calculated derived values.
  60. $circle_yes_font_size = $font_size * 0.88;
  61. $line_height = $font_size * 1.7;
  62. $icon_margin = $font_size * 0.7;
  63. $icon_margin_position = ( is_rtl() ) ? 'left' : 'right';
  64. $content_margin = $line_height + $icon_margin;
  65. $content_margin_position = ( is_rtl() ) ? 'right' : 'left';
  66.  
  67. // Set markup depending on icon circle being used or not.
  68. if ( Avada()->settings->get( 'checklist_circle' ) ) {
  69. $before = '<span class="icon-wrapper circle-yes" style="background-color:var(--checklist_circle_color);font-size:' . $font_size . 'px;height:' . $line_height . 'px;width:' . $line_height . 'px;margin-' . $icon_margin_position . ':' . $icon_margin . 'px;" ><i class="fusion-li-icon fa fa-angle-right" style="color:var(--checklist_icons_color);"></i></span><div class="fusion-li-item-content" style="margin-' . $content_margin_position . ':' . $content_margin . 'px;">';
  70. } else {
  71. $before = '<span class="icon-wrapper circle-no" style="font-size:' . $font_size . 'px;height:' . $line_height . 'px;width:' . $line_height . 'px;margin-' . $icon_margin_position . ':' . $icon_margin . 'px;" ><i class="fusion-li-icon fa fa-angle-right" style="color:var(--checklist_icons_color);"></i></span><div class="fusion-li-item-content" style="margin-' . $content_margin_position . ':' . $content_margin . 'px;">';
  72. }
  73.  
  74. $error_page_menu_args = [
  75. 'theme_location' => '404_pages',
  76. 'depth' => 1,
  77. 'container' => false,
  78. 'menu_id' => 'fusion-checklist-1',
  79. 'menu_class' => 'fusion-checklist fusion-404-checklist error-menu' . $checklist_divider,
  80. 'items_wrap' => '<ul id="%1$s" class="%2$s" style="font-size:' . $font_size . 'px;line-height:' . $line_height . 'px;">%3$s</ul>',
  81. 'before' => $before,
  82. 'after' => '</div>',
  83. 'echo' => 0,
  84. 'item_spacing' => 'discard',
  85. 'fallback_cb' => 'fusion_error_page_menu_fallback',
  86. ];
  87.  
  88. // Get the menu markup with correct containers.
  89. $error_page_menu = wp_nav_menu( $error_page_menu_args );
  90.  
  91. /**
  92. * Fallback to main menu if no 404 menu is set.
  93. *
  94. * @since 5.5
  95. * @param array $error_page_menu_args The menu arguments.
  96. * @return string|false
  97. */
  98. function fusion_error_page_menu_fallback( $error_page_menu_args ) {
  99. if ( has_nav_menu( 'main_navigation' ) ) {
  100. $error_page_menu_args['theme_location'] = 'main_navigation';
  101. }
  102.  
  103. unset( $error_page_menu_args['fallback_cb'] );
  104.  
  105. return wp_nav_menu( $error_page_menu_args );
  106. }
  107.  
  108. // Make sure divider lines have correct color.
  109. if ( $checklist_divider ) {
  110. $error_page_menu = str_replace( 'class="menu-item ', 'style="border-bottom-color:var(--checklist_divider_color);" class="menu-item ', $error_page_menu );
  111. }
  112.  
  113. echo $error_page_menu; // phpcs:ignore WordPress.Security.EscapeOutput
  114. ?>
  115. </div>
  116. <div class="fusion-column col-lg-4 col-md-4 col-sm-4 fusion-error-page-search">
  117. <h3><?php esc_html_e( 'Try again', 'Avada' ); ?></h3>
  118. <p><?php esc_html_e( 'If you want to rephrase your query, here is your chance:', 'Avada' ); ?></p>
  119. <?php echo get_search_form( false ); ?>
  120. </div>
  121. </div>
  122. </div>
  123. </div>
  124. <?php endif; ?>
  125. </section>
  126. <?php do_action( 'avada_after_content' ); ?>
  127. <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement