Browse Source

init js search location details

windhamdavid 2 years ago
parent
commit
789ad04367
5 changed files with 87 additions and 8 deletions
  1. 8 1
      functions.php
  2. 53 0
      inc/physicians-location.php
  3. 3 0
      js/init.js
  4. 5 5
      search.php
  5. 18 2
      taxonomy-location.php

+ 8 - 1
functions.php

@@ -4,4 +4,11 @@ require get_stylesheet_directory() . '/inc/physicians-func.php';
 require get_stylesheet_directory() . '/inc/physicians-cpt.php';
 require get_stylesheet_directory() . '/inc/physicians-meta.php';
 require get_stylesheet_directory() . '/inc/physicians-temp.php';
-require get_stylesheet_directory() . '/inc/physicians-location.php';
+require get_stylesheet_directory() . '/inc/physicians-location.php';
+
+function srh_enqueue_scripts() {
+    wp_enqueue_script( 'script-name', get_template_directory_uri() . '/js/init.js', array(), '1.0.0', true );
+}
+add_action( 'wp_enqueue_scripts', 'srh_enqueue_scripts' );
+	
+add_filter( 'term_description', 'do_shortcode' );

+ 53 - 0
inc/physicians-location.php

@@ -263,6 +263,59 @@ function srh_save_term_map( $term_id ) {
 }
 
 
+add_action( 'init', 'srh_register_location_details' );
+add_action( 'location_add_form_fields', 'srh_new_term_details_field' );
+add_action( 'location_edit_form_fields', 'srh_edit_term_details_field' );
+add_action( 'edit_location', 'srh_save_term_details' );
+add_action( 'create_location', 'srh_save_term_details' );
+
+function srh_register_location_details() {
+    //register_meta( 'term', 'details', 'srh_sanitize_text' );
+}
+
+function srh_sanitize_text_details( $details ) {
+	$details = wp_kses_post( $_POST['srh_term_details'] );
+}
+
+function srh_get_term_details( $term_id ) {
+    $details = get_term_meta( $term_id, 'details', true );
+    return $details ? "{$details}" : $details;
+}
+
+function srh_new_term_details_field() {
+    wp_nonce_field( basename( __FILE__ ), 'srh_term_details_nonce' ); ?>
+    <div class="form-field jt-term-color-wrap">
+        <label for="srh-term-details"><?php _e( 'Location Details', 'srh' ); ?></label>
+        <input type="text" name="srh_term_details" id="srh-term-details" value="" class="srh-details-field" data-default-details="" />
+    </div>
+<?php }
+
+function srh_edit_term_details_field( $term ) {
+    $default = '';
+    $details = srh_get_term_details( $term->term_id, true );
+    if ( ! $details )
+        $details = $default; ?>
+    <tr class="form-field srh-term-details-wrap">
+        <th scope="row"><label for="srh-term-details"><?php _e( 'Location Details', 'srh' ); ?></label></th>
+        <td>
+            <?php wp_nonce_field( basename( __FILE__ ), 'srh_term_details_nonce' ); ?>
+			<?php wp_editor( wp_kses_post( $details ), 'srh_term_details' ); ?>
+			<p class="description"><?php esc_html_e( 'details of the location','srh' ); ?></p>
+        </td>
+    </tr>
+<?php }
+
+function srh_save_term_details( $term_id ) {
+    if ( ! isset( $_POST['srh_term_details_nonce'] ) || ! wp_verify_nonce( $_POST['srh_term_details_nonce'], basename( __FILE__ ) ) )
+        return;
+    $old_details = srh_get_term_details( $term_id );
+    $new_details = wp_kses_post( $_POST['srh_term_details'] );;
+    if ( $old_details && '' === $new_details)
+        delete_term_meta( $term_id, 'details' );
+    else if ( $old_details !== $new_details )
+        update_term_meta( $term_id, 'details', $new_details );	
+}
+
 
 
 

+ 3 - 0
js/init.js

@@ -0,0 +1,3 @@
+jQuery(window).load(function(){
+     
+});

+ 5 - 5
search.php

@@ -101,16 +101,16 @@
 					                        {
 					                            if(!in_array($taxonomy, $excluded_taxonomies))
 					                            {
-					                                $cats .= get_the_term_list($the_id, $taxonomy, '<span class="custom-tax">', '', '</span><br>').' ';
+					                                $cats .= get_the_term_list($the_id, $taxonomy, '<span class="custom-tax">', ' | ', '</span><br>').' ';
 					                            }
 					                        }
 					                    }
 
 					                    if(!empty($cats))
-					                    {	
-						                        echo '<span class="taxonomies">'.__('','avia_framework')." ";
-						                        echo  $cats;
-						                        echo '</span>';
+					                    {
+					                        echo '<span class="taxonomies">'.__('','avia_framework')." ";
+					                        echo  $cats;
+					                        echo '</span>';
 					                    }
 
 					                    ?>

+ 18 - 2
taxonomy-location.php

@@ -27,7 +27,9 @@
 						
 					<br />
 							
-					<?php the_archive_description( '<div class="taxonomy-description">', '</div>' );?>
+					<?php the_archive_description( '<div class="taxonomy-description">', '</div>' );
+					
+					?>
 			
 					<div  class='hr hr-short hr-center  avia-builder-el-1  el_after_av_textblock  el_before_av_one_full '><span class='hr-inner ' ><span class='hr-inner-style'></span></span></div>
 					<h3>Our Physicians:</h3>
@@ -46,6 +48,8 @@
 				
 
 						<div class="entry-content">	 
+
+							
 											
 						</div><!-- .entry-content -->
 
@@ -55,13 +59,25 @@
 					<?php endwhile; ?>
 					
 					<div  class='hr hr-short hr-center  avia-builder-el-1  el_after_av_textblock  el_before_av_one_full '><span class='hr-inner ' ><span class='hr-inner-style'></span></span></div>
+					<div class="entry-content details">
+
+						<?php
+						if ( $terms = get_the_terms( $post->ID, 'location' ) ) {
+						    $term = array_shift( $terms );
+							echo do_shortcode( get_term_meta ($term->term_id, 'details', true) );
+						    echo get_term_meta( $term->term_id, 'details', true );
+						}	
+						?>
+					</div>
+					
+					<div  class='hr hr-short hr-center  avia-builder-el-1  el_after_av_textblock  el_before_av_one_full '><span class='hr-inner ' ><span class='hr-inner-style'></span></span></div>
 					
 					<div class="map">
 						<?php
 						if ( $terms = get_the_terms( $post->ID, 'location' ) ) {
 						    $term = array_shift( $terms );
 							if ( $box = get_term_meta( $term->term_id, 'map', true ) ) {
-						    	echo '<iframe  src="' . get_term_meta( $term->term_id, 'map', true ) . 'style="border: 0" allowfullscreen="" width="600" height="450" frameborder="0"></iframe>';
+						    	echo '<iframe src="' . get_term_meta( $term->term_id, 'map', true ) . '" style="border: 0" allowfullscreen="" width="600" height="450" frameborder="0"></iframe>';
 							}
 						}
 						?>