post_type && has_post_thumbnail()):
$thumbnail_id = get_post_thumbnail_id( get_the_ID() );
elseif ( ( (is_single() && 'post' == $post->post_type) || is_home() ) && !apply_filters( 'bahotel_l_option', '', 'blog_header_default' ) && isset(Bahotel_L_Settings::$settings['blog_header_image']['id'])):
$thumbnail_id = Bahotel_L_Settings::$settings['blog_header_image']['id'];
elseif (is_post_type_archive('event') && !apply_filters( 'bahotel_l_option', '', 'events_header_default' ) && isset(Bahotel_L_Settings::$settings['events_header_image']['id'])):
$thumbnail_id = Bahotel_L_Settings::$settings['events_header_image']['id'];
elseif (is_post_type_archive('service') && !apply_filters( 'bahotel_l_option', '', 'services_header_default' ) && isset(Bahotel_L_Settings::$settings['services_header_image']['id'])):
$thumbnail_id = Bahotel_L_Settings::$settings['services_header_image']['id'];
elseif (is_archive() && !apply_filters( 'bahotel_l_option', '', 'archive_header_default' ) && isset(Bahotel_L_Settings::$settings['archive_header_image']['id'])):
$thumbnail_id = Bahotel_L_Settings::$settings['archive_header_image']['id'];
endif;
return absint($thumbnail_id);
}
endif;
///////////////////////////
add_filter( 'bahotel_l_background_spinner', 'bahotel_l_background_spinner', 10, 1 );
if ( ! function_exists( 'bahotel_l_background_spinner' ) ) :
/**
* Filter background spinner url
*
* @param string $spinner_url
*
* @return string
*/
function bahotel_l_background_spinner($spinner_url) {
return Bahotel_L_Settings::$default_spinner;
}
endif;
///////////////////////////
add_filter( 'bahotel_l_background_image_thumbnail', 'bahotel_l_background_image_thumbnail', 10, 1 );
if ( ! function_exists( 'bahotel_l_background_image_thumbnail' ) ) :
/**
* Filter background image thumbnail
*
* @param string $thumbnail
*
* @return string
*/
function bahotel_l_background_image_thumbnail($thumbnail) {
$thumbnail = 'bahotel_gallery_md';//'bahotel_list_vl'; //'bahotel_list_md';
return $thumbnail;
}
endif;
///////////////////////////
add_filter( 'bahotel_l_background_image_thumbnail_md', 'bahotel_l_background_image_thumbnail_md', 10, 1 );
if ( ! function_exists( 'bahotel_l_background_image_thumbnail_md' ) ) :
/**
* Filter background image thumbnail
*
* @param string $thumbnail
*
* @return string
*/
function bahotel_l_background_image_thumbnail_md($thumbnail) {
$thumbnail = 'bahotel_thumbnail_lg';
return $thumbnail;
}
endif;
///////////////////////////
add_filter( 'bahotel_l_background_image_full', 'bahotel_l_background_image_full', 10, 1 );
if ( ! function_exists( 'bahotel_l_background_image_full' ) ) :
/**
* Filter background image thumbnail
*
* @param string $thumbnail
*
* @return string
*/
function bahotel_l_background_image_full($thumbnail) {
$thumbnail = 'bahotel_header';
return $thumbnail;
}
endif;
///////////////////////////
add_filter( 'get_the_archive_title', 'bahotel_l_the_archive_title', 10, 1 );
if ( ! function_exists( 'bahotel_l_the_archive_title' ) ) :
/**
* Filters the archive title.
*
* @param string $title Archive title to be displayed.
* @return string
*/
function bahotel_l_the_archive_title($title) {
if ( is_post_type_archive() ) {
$title = post_type_archive_title( '', false );
}
return $title;
}
endif;
////////////////////////////
add_action( 'pre_get_posts', 'bahotel_l_archive_query', 10, 1 );
if ( ! function_exists( 'bahotel_l_archive_query' ) ) :
/**
* Filters the archive query params
*
* @param object $query
* @return
*/
function bahotel_l_archive_query($query) {
if ( is_post_type_archive( 'service' ) && ! is_admin() && $query->is_main_query() && in_array('service', (array)$query->query_vars['post_type'])) {
$query->set( 'posts_per_archive_page', -1 );
$query->set( 'orderby', 'menu_order title' );
$query->set( 'order', 'ASC' );
$services_include_pages = (array) apply_filters( 'bahotel_l_option', array(), 'services_include_pages' );
$services_include_pages = array_map('absint', $services_include_pages);
if (array_sum($services_include_pages)){
$post__in = array();
foreach($services_include_pages as $service_page_id => $service_page_include){
if ($service_page_include){
$post__in[] = $service_page_id;
}
}
$query->set( 'post__in', $post__in );
}
}
if ( is_post_type_archive( 'event' ) && ! is_admin() && $query->is_main_query() && in_array('event', (array)$query->query_vars['post_type'])) {
$orderby_first = apply_filters( 'bahotel_l_option', '', 'events_orderby' );
$order = apply_filters( 'bahotel_l_option', 'DESC', 'events_order' ) == 'DESC' ? 'DESC' : 'ASC';
if ('date_event' == $orderby_first){
$query->set( 'meta_key', 'event_date_timestamp' );
$orderby = array(
'meta_value_num' => $order,
'modified' => $order,
);
$query->set( 'orderby', $orderby );
} elseif ('modified' == $orderby_first || 'title' == $orderby_first){
$orderby = array(
$orderby_first => $order,
'date' => $order,
);
$query->set( 'orderby', $orderby );
}
}
return;
}
endif;
//////////////////////////////////////////////////
add_filter('bahotel_l_block_title_before', 'bahotel_l_block_title_before', 10, 1);
if ( ! function_exists( 'bahotel_l_block_title_before' ) ) :
//////////////////////////////////////////////////
/**
* Filter before block title
*
* @param string $output
*
* @return string
*/
function bahotel_l_block_title_before( $output = '' ) {
$output = '
'.wp_kses_post($excerpt) .'
' : ''; } return $output; } endif; /////////////////////////////////////// add_action( 'wp_insert_post', 'bahotel_l_updates_on_insert_post', 10, 3 ); if ( ! function_exists( 'bahotel_l_updates_on_insert_post' ) ) : /** * Clear postmeta '_post_excerpt' when post is updated * * @param int $post_id * @param obj $post WP_Post * @param boolean $update * * @return */ function bahotel_l_updates_on_insert_post( $post_id, $post, $update ) { remove_action( 'wp_insert_post', 'bahotel_l_updates_on_insert_post', 10, 3 ); if ( metadata_exists( 'post', $post_id, '_post_excerpt' ) ){ delete_post_meta($post_id, '_post_excerpt'); } return; } endif; ////////////////////////////////////////// if ( ! function_exists( 'bahotel_l_strip_tags_content' ) ) : /** * Strip tags with content * * @param string $text * @param string $tags * @param boolean $invert * * @return string */ function bahotel_l_strip_tags_content($text, $tags = '', $invert = false) { preg_match_all('/<(.+?)[\s]*\/?[\s]*>/si', trim($tags), $tags_arr); $tags_arr = array_unique($tags_arr[1]); if(is_array($tags_arr) AND count($tags_arr) > 0) { if($invert == false) { return preg_replace('@<(?!(?:'. implode('|', $tags_arr) .')\b)(\w+)\b.*?>.*?\1>@si', '', $text); } else { return preg_replace('@<('. implode('|', $tags_arr) .')\b.*?>.*?\1>@si', '', $text); } } elseif($invert == false) { return preg_replace('@<(\w+)\b.*?>.*?\1>@si', '', $text); } return $text; } endif;