<?php
function my_theme_enqueue_styles() { 
    wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
}
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );

add_action('wp_enqueue_scripts', 'qg_enqueue');
function qg_enqueue() {
  wp_enqueue_script( 'main', get_stylesheet_directory_uri().'/assets/js/main.js',array('jquery'),false,true);
}

add_action('acf/init', 'my_acf_op_init');
function my_acf_op_init() {

    // Check function exists.
    if( function_exists('acf_add_options_page') ) {

        // Add parent.
        $parent = acf_add_options_page(array(
            'page_title'  => __('General Settings'),
            'menu_title'  => __('General Settings'),
            'redirect'    => false,
        ));

        // Add sub page.
        $child = acf_add_options_page(array(
            'page_title'  => __('Homepage Promo'),
            'menu_title'  => __('Homepage Promo'),
            'parent_slug' => $parent['menu_slug'],
        ));
        
        // Add sub page.
        $child = acf_add_options_page(array(
            'page_title'  => __('Office details'),
            'menu_title'  => __('Office details'),
            'parent_slug' => $parent['menu_slug'],
        ));
    }
}
// Top Right Menu
register_nav_menus( 
    array(
        'top-right-menu'   =>  __( 'Top Right Menu', 'hawk' ), 
    )
);
add_action('wp_footer', 'top_menu_data'); 
function top_menu_data() { 
      echo '<div class="fixed-section-menu">';     
       wp_nav_menu( array( 'theme_location' => 'top-right-menu', 'container_class' => 'fixed-section-menu-content'));
       echo '</div>';
    }
// Function to add subscribe text to posts and pages
function HelloWorldShortcode() {
     $image = get_field('image','option');
    $content = get_field('hp_promo_content','option');
    $bg = get_field('hp_promo_colour','option');
    $buttonlabel = get_field('hp_promo_button_label','option');
     $buttonurl = get_field('hp_promo_button_url','option');
     $buttonclass = get_field('hp_promo_button_class','option');
     if(get_field('hp-show','option')){
        $mainshow = 'yes';
     }else{
         $mainshow = 'no';            
     }
   $contentlist = '<div class="promo-home-wrap '.$mainshow.'" style="min-height: 100px; background: '.$bg.' ; margin: 40px auto 40px;">';
    if($image){
         $contentlist  .= '<div class="promo-left"> 
            <img loading="lazy" src="'.$image.'" alt="" >
            </div>';
       }   
       $contentlist  .= '<div class="promo-right"> 
        <div style="margin: auto;">
        '. $content;
        if($buttonlabel){
            $contentlist  .= '<a href="'. $buttonurl.'" class="btn-promo '. $buttonclass.'">'. $buttonlabel.'</a>';
        }
        $contentlist  .= '</div>
    </div>';
    return $contentlist;
}
add_shortcode('home-promo', 'HelloWorldShortcode');


remove_action( 'propertyhive_single_property_summary', 'propertyhive_template_single_title', 5 );
remove_action( 'propertyhive_single_property_summary', 'propertyhive_template_single_floor_area', 7 );
remove_action( 'propertyhive_single_property_summary', 'propertyhive_template_single_price', 10 );
remove_action( 'propertyhive_single_property_summary', 'propertyhive_template_single_meta', 20 );
remove_action( 'propertyhive_single_property_summary', 'propertyhive_template_single_sharing', 30 );

remove_action( 'propertyhive_after_single_property_summary', 'propertyhive_template_single_actions', 10 );
remove_action( 'propertyhive_after_single_property_summary', 'propertyhive_template_single_features', 20 );
remove_action( 'propertyhive_after_single_property_summary', 'propertyhive_template_single_summary', 30 );
remove_action( 'propertyhive_after_single_property_summary', 'propertyhive_template_single_description', 40 );

add_action( 'propertyhive_single_property_summary', 'property_content_summary', $priority = 10);
function property_content_summary(){
    global $post, $propertyhive, $property;
    $bedroom = get_post_meta( $post->ID, $key = '_bedrooms', $single = true );
    $bethroom = get_post_meta( $post->ID, $key = '_bathrooms', $single = true );
    $availability = get_the_terms( $post->ID, 'availability');
    $property_type = get_the_terms( $post->ID, 'property_type');
    $address_street = get_post_meta( $post->ID, '_address_street', $single = true);
    $town_name = get_post_meta( $post->ID, '_address_three', $single = true);
    ?>

    <!-- AddToAny END -->
    <!-- <div class="flex_row"> -->
        <div class="top-section">
            <div class="flex_row " style="gap: 30px; position: relative;z-index: 1;">
                <div class="flex-four-col">
                    <h1 class="prop_address"><?php echo $address_street; ?></h1>
                    <h3><?php echo $town_name; ?></h3>
                    <div class="price">
                        <h2 class="property_title entry-title">
                            <?php echo $property->get_formatted_price(); 
                            ?>
                            <?php
                                if (
                                    ( $property->department == 'residential-sales' || $property->department == 'commercial' ) &&
                                    $property->price_qualifier != ''
                                )
                                {
                                    echo ' <span class="price-qualifier">' . $property->price_qualifier . '</span>';
                                }

                                if ( $fees != '' )
                                {
                                    echo ' <span class="lettings-fees"><a data-fancybox data-src="#propertyhive_lettings_fees_popup" href="javascript:;">' . __( 'Tenancy Info', 'propertyhive' ) . '</a></span>';

                                    echo '<div id="propertyhive_lettings_fees_popup" style="display:none; max-width:500px;"><h3>' . __( 'Tenancy Info', 'propertyhive' ) . '</h3>' . $fees . '</div>';
                                }
                            ?>
                        </h2>
                    </div> 
                    <div class="flex-col bed-bath-count">
                        <ul>
                            <?php if($bedroom){ ?>
                            <li>
                                 <?php echo $bedroom ?></li>
                            <?php } 
                            if($bethroom){
                            ?>  
                                <li>
                                    <?php echo $bethroom; ?>
                                </li>
                            <?php } ?>  
                        </ul>
                     </div>       
                </div>
                <div class="flex-double-col">
                    <div class="call-section">
                        <div class="get-in-touch">
                            <a href="tel:0121 454 3696">    
                                <span>Interested? Get in touch!</span>
                                <div class="flex-col">
                                    0121 454 3696
                                </div>
                            </a>    
                        </div>
                        <div class="shortlist common-lft">
                            <?php echo do_shortcode('[shortlist_button]') ?>
                        </div>
                        <div class="email-to-friend common-lft">
                            <a href="#">
                                EMAIL TO A FRIEND
                            </a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="flex_row property-details" style="gap: 30px; position: relative;">
            <div class="flex-four-col">
                <div class="property_info">
                    <h4 class="prop-heading prop-desc-heading">Property Details</h4>
                    <p><?php echo $property->post_excerpt; ?></p>
                    <?php 
                    $features = $property->get_features();
                    if ( !empty($features) ){ ?>
                        <div class="features">
                            <h4><?php _e( 'Features', 'propertyhive' ); ?></h4>
                            <ul>
                                <?php foreach ($features as $feature) { ?>
                                    <li><?php echo $feature; ?></li>
                                            <?php
                                    }
                                ?>
                            </ul>
                        </div>
                    <?php
                    }
                     ?>
                     <h4 class="prop-heading prop-desc-heading">Location</h4>
                     <div class="map-top"><?php echo do_shortcode('[property_map height="250"  zoom="18"  id="'.$post->ID.'"]');?></div>
                     <div class="button-epc">
                         <div class="epc-button btnsec"><a href="#">VIEW EPC</a></div>
                         <div class="pdf-button btnsec"><a href="#">DOWNLOAD BROCHURE</a></div>
                     </div>
                </div>
            </div>
            <div class="flex-double-col">
                <div class="form-section-arranging">
                    <h2>Arrange a viewing</h2>
                    <p>Please feel free to contact us to arrange a viewing or if you have any questions about the property.</p>
                    <?php echo do_shortcode('[contact-form-7 id="31049" title="Arrange a viewing"]'); ?>
                </div>
            </div>
        </div>
    <!-- </div> -->
    <?php
}


