| 1 |
<?php |
| 2 |
/** |
| 3 |
* PropertyHive Conditional Functions |
| 4 |
* |
| 5 |
* Functions for determining the current query/page. |
| 6 |
* |
| 7 |
* @author PropertyHive |
| 8 |
* @category Core |
| 9 |
* @package PropertyHive/Functions |
| 10 |
* @version 1.0.0 |
| 11 |
*/ |
| 12 |
|
| 13 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 14 |
|
| 15 |
/** |
| 16 |
* is_propertyhive - Returns true if on a page which uses PropertyHive templates |
| 17 |
* |
| 18 |
* @access public |
| 19 |
* @return bool |
| 20 |
*/ |
| 21 |
function is_propertyhive() { |
| 22 |
return apply_filters( 'is_propertyhive', ( is_search_results() || is_property() ) ? true : false ); |
| 23 |
} |
| 24 |
|
| 25 |
if ( ! function_exists( 'is_search_results' ) ) { |
| 26 |
|
| 27 |
/** |
| 28 |
* is_search_results - Returns true when viewing the property archive (search results). |
| 29 |
* |
| 30 |
* @access public |
| 31 |
* @return bool |
| 32 |
*/ |
| 33 |
function is_search_results() { |
| 34 |
return ( is_post_type_archive( 'property' ) || is_page( ph_get_page_id( 'search_results' ) ) ) ? true : false; |
| 35 |
} |
| 36 |
} |
| 37 |
|
| 38 |
if ( ! function_exists( 'is_property' ) ) { |
| 39 |
|
| 40 |
/** |
| 41 |
* is_product - Returns true when viewing a single product. |
| 42 |
* |
| 43 |
* @access public |
| 44 |
* @return bool |
| 45 |
*/ |
| 46 |
function is_property() { |
| 47 |
return is_singular( array( 'property' ) ); |
| 48 |
} |
| 49 |
} |
| 50 |
|
| 51 |
if ( ! function_exists( 'is_ajax' ) ) { |
| 52 |
|
| 53 |
/** |
| 54 |
* is_ajax - Returns true when the page is loaded via ajax. |
| 55 |
* |
| 56 |
* @access public |
| 57 |
* @return bool |
| 58 |
*/ |
| 59 |
function is_ajax() { |
| 60 |
return defined( 'DOING_AJAX' ); |
| 61 |
} |
| 62 |
} |