/* ===================================================================================

* Theme Name: Reland Child
* Theme URI: https://www.themegenix.net/reland/
* Author: ThemeGenix
* Author URI: https://themeforest.net/user/themegenix/
* Description: Reland - Real Estate Group WordPress Theme
* Version: 1.5
* Template: reland
* License: GNU General Public License version 3.0
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
* Tags: one-column, right-sidebar, left-sidebar, custom-menu, featured-images, post-formats, sticky-post, translation-ready

* We encourage you to create Child theme for any modifications you will want to do.

* Why use Child theme?

* Because of future updates we may provide for this theme that will overwrite your
* modifications and all your custom work.

* If you are not familiar with Child Themes, you can read about it here:
* http://codex.wordpress.org/Child_Themes
* http://wp.tutsplus.com/tutorials/theme-development/child-themes-basics-and-creating-child-themes-in-wordpress/

====================================================================================== */

function reland_remove_project_type_from_filters( $fields ) {
    if ( isset( $fields['project-type'] ) ) {
        unset( $fields['project-type'] );
    }
    return $fields;
}
add_filter( 'reland_project_search_fields', 'reland_remove_project_type_from_filters' );

// Add to child theme functions.php OR use a Code Snippets plugin (run on front-end)
add_action('wp_footer','sw_remove_project_type_footer', 100);
function sw_remove_project_type_footer(){
  if(is_admin()) return;
  ?>
  <script>
  (function(){
    console.log('SW_PROJECT_REMOVER_v2: running');
    function tryRemove(){
      var s = document.getElementById('project-type') 
              || document.querySelector('select[name="project-type"]') 
              || Array.from(document.querySelectorAll('select')).find(x=> (x.options[0] && /project ?type/i.test(x.options[0].text)) );
      if(!s) { console.log('SW_PROJECT_REMOVER_v2: select not found'); return false; }
      var col = s.closest('[class*="col-"]');
      console.log('SW_PROJECT_REMOVER_v2: found select ->', s, ' parent col ->', col);
      if(col) { col.remove(); console.log('SW_PROJECT_REMOVER_v2: removed parent col'); }
      return true;
    }
    if(tryRemove()) return;
    document.addEventListener('DOMContentLoaded', tryRemove);
    var tries=0, int=setInterval(function(){
      tries++;
      if(tryRemove() || tries>60) clearInterval(int);
    },300);
    new MutationObserver(function(){ if(tryRemove()) this.disconnect(); }).observe(document.body,{childList:true,subtree:true});
  })();
  </script>
  <?php
}


