functions.php 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. <?php
  2. require get_stylesheet_directory() . '/inc/physicians-func.php';
  3. require get_stylesheet_directory() . '/inc/physicians-cpt.php';
  4. require get_stylesheet_directory() . '/inc/physicians-meta.php';
  5. require get_stylesheet_directory() . '/inc/physicians-temp.php';
  6. require get_stylesheet_directory() . '/inc/physicians-location.php';
  7. function srh_enqueue_scripts() {
  8. wp_enqueue_script( 'script-name', get_stylesheet_directory_uri() . '/js/init.js', array(), '1.0.0', true );
  9. }
  10. add_action( 'wp_enqueue_scripts', 'srh_enqueue_scripts' );
  11. add_filter( 'term_description', 'do_shortcode' );
  12. /****************
  13. * change logo link
  14. *****************/
  15. add_filter('avf_logo_link','av_change_logo_link');
  16. function av_change_logo_link($link)
  17. {
  18. $link = "http://www.selfregional.org";
  19. return $link;
  20. }
  21. /****************
  22. * remove left/right provider navigation
  23. *****************/
  24. function no_post_nav($entries)
  25. {
  26. $entries = array();
  27. return $entries;
  28. }
  29. add_filter('avia_post_nav_entries','no_post_nav');
  30. /****************
  31. * add AVIA Framework (enfold theme) shortcodes to the wysiwyg
  32. *****************/
  33. add_filter('avia_load_shortcodes', 'avia_include_shortcode_template', 15, 1);
  34. function avia_include_shortcode_template($paths) {
  35. $template_url = get_stylesheet_directory();
  36. array_unshift($paths, $template_url.'/shortcodes/');
  37. return $paths;
  38. }
  39. /****************
  40. * Remove default Avia Null Search Redirect
  41. *****************/
  42. add_action('after_setup_theme','avia_remove_search_redirect');
  43. function avia_remove_search_redirect(){
  44. remove_filter('pre_get_posts', 'avia_search_query_filter');
  45. }
  46. /****************
  47. * Remove Enfold theme LayerSlider and Portfolio Plugins
  48. *****************/
  49. add_theme_support('deactivate_layerslider');
  50. function remove_portfolio() {
  51. remove_action('init', 'portfolio_register');
  52. }
  53. add_action('after_setup_theme', 'remove_portfolio');
  54. /****************
  55. * Null Search show all
  56. *****************/
  57. add_filter( 'request', 'srh_request_filter' );
  58. function srh_request_filter( $query_vars ) {
  59. if( isset( $_GET['s'] ) && empty( $_GET['s'] ) ) {
  60. $query_vars['s'] = " ";
  61. }
  62. return $query_vars;
  63. }
  64. add_filter('pre_get_posts', 'srh_change_wp_search_size');
  65. function srh_change_wp_search_size($query) {
  66. if ( $query->is_search )
  67. $query->query_vars['posts_per_page'] = -1;
  68. return $query;
  69. }
  70. /****************
  71. * Add Search all taxonomies (locations)
  72. *****************/
  73. function atom_search_where($where){
  74. global $wpdb;
  75. if (is_search())
  76. $where .= "OR (t.name LIKE '%".get_search_query()."%' AND {$wpdb->posts}.post_status = 'publish')";
  77. return $where;
  78. }
  79. function atom_search_join($join){
  80. global $wpdb;
  81. if (is_search())
  82. $join .= "LEFT JOIN {$wpdb->term_relationships} tr ON {$wpdb->posts}.ID = tr.object_id INNER JOIN {$wpdb->term_taxonomy} tt ON tt.term_taxonomy_id=tr.term_taxonomy_id INNER JOIN {$wpdb->terms} t ON t.term_id = tt.term_id";
  83. return $join;
  84. }
  85. function atom_search_groupby($groupby){
  86. global $wpdb;
  87. $groupby_id = "{$wpdb->posts}.ID";
  88. if(!is_search() || strpos($groupby, $groupby_id) !== false) return $groupby;
  89. if(!strlen(trim($groupby))) return $groupby_id;
  90. return $groupby.", ".$groupby_id;
  91. }
  92. add_filter('posts_where','atom_search_where');
  93. add_filter('posts_join', 'atom_search_join');
  94. add_filter('posts_groupby', 'atom_search_groupby');
  95. /****************
  96. * Override the Archive Title for Specialties
  97. *****************/
  98. if(!function_exists('avia_which_archive'))
  99. {
  100. function avia_which_archive()
  101. {
  102. $output = "";
  103. if ( is_category() )
  104. {
  105. $output = __('Archive for category:','avia_framework')." ".single_cat_title('',false);
  106. }
  107. elseif (is_day())
  108. {
  109. $output = __('Archive for date:','avia_framework')." ".get_the_time( __('F jS, Y','avia_framework') );
  110. }
  111. elseif (is_month())
  112. {
  113. $output = __('Archive for month:','avia_framework')." ".get_the_time( __('F, Y','avia_framework') );
  114. }
  115. elseif (is_year())
  116. {
  117. $output = __('Archive for year:','avia_framework')." ".get_the_time( __('Y','avia_framework') );
  118. }
  119. elseif (is_search())
  120. {
  121. global $wp_query;
  122. if(!empty($wp_query->found_posts))
  123. {
  124. if($wp_query->found_posts > 1)
  125. {
  126. $output = $wp_query->found_posts ." ". __('search results for:','avia_framework')." ".esc_attr( get_search_query() );
  127. }
  128. else
  129. {
  130. $output = $wp_query->found_posts ." ". __('search result for:','avia_framework')." ".esc_attr( get_search_query() );
  131. }
  132. }
  133. else
  134. {
  135. if(!empty($_GET['s']))
  136. {
  137. $output = __('Search results for:','avia_framework')." ".esc_attr( get_search_query() );
  138. }
  139. else
  140. {
  141. $output = __('To search the site please enter a valid term','avia_framework');
  142. }
  143. }
  144. }
  145. elseif (is_author())
  146. {
  147. $curauth = (get_query_var('author_name')) ? get_user_by('slug', get_query_var('author_name')) : get_userdata(get_query_var('author'));
  148. $output = __('Author Archive','avia_framework')." ";
  149. if(isset($curauth->nickname) && isset($curauth->ID))
  150. {
  151. $name = apply_filters('avf_author_nickname', $curauth->nickname, $curauth->ID);
  152. $output .= __('for:','avia_framework') ." ". $name;
  153. }
  154. }
  155. elseif (is_tag())
  156. {
  157. $output = __('Tag Archive for:','avia_framework')." ".single_tag_title('',false);
  158. }
  159. // ************************************* Change Archive for: -> Specialty: ******************************************
  160. elseif(is_tax())
  161. {
  162. $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
  163. $output = __('Specialty:','avia_framework')." ".$term->name;
  164. }
  165. else
  166. {
  167. $output = __('Archives','avia_framework')." ";
  168. }
  169. if (isset($_GET['paged']) && !empty($_GET['paged']))
  170. {
  171. $output .= " (".__('Page','avia_framework')." ".$_GET['paged'].")";
  172. }
  173. $output = apply_filters('avf_which_archive_output', $output);
  174. return $output;
  175. }
  176. }
  177. /****************
  178. * filter location from search.
  179. *****************/
  180. add_filter('avf_exclude_taxonomies', 'avia_exclude_tax', 10, 3);
  181. function avia_exclude_tax($tax,$post_type,$id){
  182. $tax[] = 'location';
  183. return $tax;
  184. }