/**
  * valid condition from combine of fields value in your given relation
  * notice: this method should call in theme template files
  * @param $and_bind
  * @param $relation: and /or
  * @return bool
  */
 public static function check_fields_condition($and_bind, $relation = 'AND')
 {
     $result = array();
     //first set to false
     $match_page = true;
     //match template page
     $page = isset($GLOBALS['hw_rules_field_current_theme_template']) ? $GLOBALS['hw_rules_field_current_theme_template'] : '';
     //basename( get_page_template() ) ;     //template page
     //valid array
     foreach ($and_bind as $id => $cond) {
         if ($cond['act'] == '-1') {
             continue;
         }
         $and_bind[$cond['act']] = $cond;
         unset($and_bind[$id]);
     }
     global $wp_query;
     //valid and condition
     //foreach($and_bind as $condition) {
     if (is_single() || is_tax() || is_category()) {
         $queried_object = get_queried_object();
     }
     //check template
     if (isset($and_bind['templates'])) {
         $is_temp = HW__Template::check_template_page($and_bind['templates']['act_values']);
         $page = $and_bind['templates']['act_values'];
         if ($is_temp) {
             $match_page = $result['templates'] = $and_bind['templates']['compare'] == '==' ? true : false;
         } else {
             $match_page = $result['templates'] = false;
         }
     } else {
         $page = HW__Template::get_current_template_name();
         //detect current template identifier
     }
     //check current post type
     if ($match_page && isset($and_bind['post_types']) && is_single()) {
         if ($queried_object->post_type == $and_bind['post_types']['act_values'] && $and_bind['post_types']['compare'] == '==' || $queried_object->post_type != $and_bind['post_types']['act_values'] && $and_bind['post_types']['compare'] == '!=') {
             $result['post_types'] = true;
         } else {
             $result['post_types'] = false;
         }
     }
     //check current taxonomy
     if ($match_page && isset($and_bind['taxonomies']) && (is_tax() || isset($wp_query->tax_query) && !empty($wp_query->tax_query->queries) || is_category() || is_single())) {
         //if single template
         if (is_single()) {
             $terms = wp_get_object_terms($queried_object->ID, $and_bind['taxonomies']['act_values'], array('fields' => 'ids'));
             $result['taxonomies'] = count($terms) && $and_bind['taxonomies']['compare'] === '==' ? true : false;
         } else {
             $result['taxonomies'] = $queried_object->taxonomy === $and_bind['taxonomies']['act_values'] && $and_bind['taxonomies']['compare'] === '==' || $queried_object->taxonomy !== $and_bind['taxonomies']['act_values'] && $and_bind['taxonomies']['compare'] !== '==';
         }
     }
     //check current term taxonomy
     if ($match_page && isset($and_bind['terms']) && isset($and_bind['taxonomies']) && (is_single() || is_category() || is_tax($and_bind['taxonomies']['act_values']) || isset($wp_query->tax_query) && !empty($wp_query->tax_query->queries))) {
         if (is_single()) {
             $terms = wp_get_object_terms($queried_object->ID, $and_bind['taxonomies']['act_values'], array('fields' => 'slugs'));
             $result['terms'] = in_array($and_bind['terms']['act_values'], $terms) && $and_bind['terms']['compare'] === '==' ? true : false;
         } else {
             $result['terms'] = $queried_object->slug == $and_bind['terms']['act_values'] && $and_bind['terms']['compare'] === '==';
         }
     }
     //check current page
     if ($match_page && isset($and_bind['pages'])) {
         global $post;
         $result['pages'] = is_page() && (strcmp($post->ID, $and_bind['pages']['act_values']) == 0 && $and_bind['pages']['compare'] == '==' || strcmp($post->ID, $and_bind['pages']['act_values']) !== 0 && $and_bind['pages']['compare'] == '!=');
     }
     //check current post
     if ($match_page && isset($and_bind['posts'])) {
         global $post;
         $result['posts'] = is_single() && (strcmp($post->ID, $and_bind['posts']['act_values']) == 0 && $and_bind['posts']['compare'] == '==' || strcmp($post->ID, $and_bind['posts']['act_values']) !== 0 && $and_bind['posts']['compare'] == '!=');
     }
     //check user
     if ($match_page && !empty($result['templates']) && !empty($and_bind['author'])) {
         $curauth = get_query_var('author_name') ? get_user_by('slug', get_query_var('author_name')) : get_userdata(get_query_var('author'));
         if (is_wp_error($curauth)) {
             global $wp_query;
             $curauth = $wp_query->get_queried_object();
         }
         $result['author'] = is_object($curauth) && ($curauth->user_login == $and_bind['author']['act_values'] && $and_bind['author']['compare'] == '==' || $curauth->user_login !== $and_bind['author']['act_values'] && $and_bind['author']['compare'] == '!=');
     }
     //extend condition to check
     $result = apply_filters('apf_check_fields_condition', $result, array('match_page' => $match_page, 'and_bind' => $and_bind, 'page' => $page));
     //}
     $result = !empty($result) && strtoupper($relation) == 'AND' ? !in_array(false, $result) : in_array(true, $result);
     return array($page => $result);
 }
 /**
  * get content_classes option base current context
  * @param $field field to return value
  * @return mixed
  */
 private function get_nhp__content_classes($field = 'post_class')
 {
     static $classes_page = null;
     if (!$classes_page) {
         $classes_page = hw_option('content_classes');
     }
     //valid
     if (!in_array($field, array('post_class', 'body_class'))) {
         return;
     }
     if (is_array($classes_page)) {
         foreach ($classes_page as $page => $class) {
             if (HW__Template::check_template_page($page)) {
                 return $class[$field];
                 break;
             }
         }
     }
 }