$value) {
${"$key"} = $value ;
}
?>
$value) { ${"$key"} = $value; }
// Header styling and image loading
// Check if this is a post or page, if it has a thumbnail, and if it's a big one
global $post;
if (get_header_image() != '') { $himgsrc = get_header_image(); }
if ( is_singular() && has_post_thumbnail( $post->ID ) && ($mantra_fheader == "Enable") && ($image = wp_get_attachment_image_src(get_post_thumbnail_id( $post->ID ), 'header' ) ) && ($image[1] >= HEADER_IMAGE_WIDTH) ):
$himgsrc = $image[0];
endif;
if (isset($himgsrc) && ($himgsrc != '')) : echo ''; endif;
?>
';
break;
case 'Clickable header image' :
echo '' ;
break;
case 'Custom Logo' :
if (isset($mantra_logoupload) && ($mantra_logoupload != '')) : echo '
'; endif;
break;
case 'Empty' :
// nothing to do here
break;
}
if ($mantra_socialsdisplay0): mantra_header_socials(); endif;
echo '';
} // mantra_title_and_description()
add_action ('cryout_branding_hook','mantra_title_and_description');
/**
* Add social icons in header / undermneu left / undermenu right / footer
* Used in header.php and footer.php
*/
function mantra_header_socials() {
mantra_set_social_icons('sheader');
}
function mantra_smenul_socials() {
mantra_set_social_icons('smenul');
}
function mantra_smenur_socials() {
mantra_set_social_icons('smenur');
}
function mantra_footer_socials() {
mantra_set_social_icons('sfooter');
}
//if($mantra_socialsdisplay0) add_action('cryout_branding_hook', 'mantra_header_socials');
if($mantra_socialsdisplay1) add_action('cryout_forbottom_hook', 'mantra_smenul_socials');
if($mantra_socialsdisplay2) add_action('cryout_forbottom_hook', 'mantra_smenur_socials');
if($mantra_socialsdisplay3) add_action('cryout_footer_hook', 'mantra_footer_socials',13);
if ( ! function_exists( 'mantra_set_social_icons' ) ) :
/**
* Social icons function
*/
function mantra_set_social_icons($id) {
$cryout_special_keys = array('Mail', 'Skype');
global $mantra_options;
foreach ($mantra_options as $key => $value) {
${"$key"} = $value ;
}
echo '
';
for ($i=1; $i<=9; $i+=2) {
$j=$i+1;
if ( ${"mantra_social$j"} ) {
if (in_array(${"mantra_social$i"},$cryout_special_keys)) :
$cryout_current_social = esc_html( ${"mantra_social$j"} );
else :
$cryout_current_social = esc_url( ${"mantra_social$j"} );
endif; ?>
" title="">" src="" />';
}
endif;
/**
* Replaces header image with featured image if there is one for single pages
* Used in header.php
*/
/* // Moved to custom-styles.php
function mantra_header_featured_image() {
global $post;
global $mantra_options;
foreach ($mantra_options as $key => $value) {
${"$key"} = $value ;
}
// Check if this is a post or page, if it has a thumbnail, and if it's a big one
if ( is_singular() && has_post_thumbnail( $post->ID ) && $mantra_fheader == "Enable" &&
( $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'post-thumbnail' ) ) &&
$image[1] >= HEADER_IMAGE_WIDTH ) :
// Houston, we have a new header image!
//echo get_the_post_thumbnail( $post->ID, 'post-thumbnail' );
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), array(HEADER_IMAGE_WIDTH,HEADER_IMAGE_HEIGHT) );
endif;
}
*/
/**
* Mantra back to top button
* Creates div for js
*/
function mantra_back_top() {
echo '
';
}
if ($mantra_backtop=="Enable") add_action ('cryout_body_hook','mantra_back_top');
/**
* Creates breadcrumns with page sublevels and category sublevels.
*/
function mantra_breadcrumbs() {
$mantra_options= mantra_get_theme_options();
foreach ($mantra_options as $key => $value) { ${"$key"} = $value; }
global $post;
echo '
';
}
if ($mantra_copyright != '') add_action('cryout_footer_hook','mantra_copyright',11);
add_action('wp_ajax_nopriv_do_ajax', 'mantra_ajax_function');
add_action('wp_ajax_do_ajax', 'mantra_ajax_function');
/**
* Retrieves the IDs for images in a gallery.
* @since mantra 2.1.1
* @return array List of image IDs from the post gallery.
*/
function mantra_get_gallery_images() {
$images = array();
if ( function_exists( 'get_post_galleries' ) ) {
$galleries = get_post_galleries( get_the_ID(), false );
if ( isset( $galleries[0]['ids'] ) )
$images = explode( ',', $galleries[0]['ids'] );
} else {
$pattern = get_shortcode_regex();
preg_match( "/$pattern/s", get_the_content(), $match );
$atts = shortcode_parse_atts( $match[3] );
if ( isset( $atts['ids'] ) )
$images = explode( ',', $atts['ids'] );
}
if ( ! $images ) {
$images = get_posts( array(
'fields' => 'ids',
'numberposts' => 999,
'order' => 'ASC',
'orderby' => 'menu_order',
'post_mime_type' => 'image',
'post_parent' => get_the_ID(),
'post_type' => 'attachment',
) );
}
return $images;
} // mantra_get_gallery_images()
/**
* Checks the browser agent string for mobile ids and adds "mobile" class to body if true
* @since mantra 2.2.3
* @return array list of classes.
*/
function mantra_mobile_body_class($classes){
$mantra_options = mantra_get_theme_options();
if ($mantra_options['mantra_mobile']=="Enable"):
$browser = $_SERVER['HTTP_USER_AGENT'];
$keys = 'mobile|android|mobi|tablet|ipad|opera mini|series 60|s60|blackberry';
if (preg_match("/($keys)/i",$browser)): $classes[] = 'mobile'; endif; // mobile browser detected
endif;
return $classes;
}
add_filter('body_class', 'mantra_mobile_body_class');
if ( ! function_exists( 'mantra_ajax_function' ) ) :
function mantra_ajax_function(){
ob_clean();
// the first part is a SWTICHBOARD that fires specific functions
// according to the value of Query Var 'fn'
switch($_REQUEST['fn']){
case 'get_latest_posts':
$output = mantra_ajax_get_latest_posts($_REQUEST['count'],$_REQUEST['categName']);
break;
default:
$output = 'No function specified, check your jQuery.ajax() call';
break;
}
// at this point, $output contains some sort of valuable data!
// Now, convert $output to JSON and echo it to the browser
// That way, we can recapture it with jQuery and run our success function
$output=json_encode($output);
if(is_array($output)){
print_r($output);
}
else{
echo $output;
}
die;
}
endif;
if ( ! function_exists( 'mantra_ajax_get_latest_posts' ) ) :
function mantra_ajax_get_latest_posts($count,$categName){
$testVar='';
// The Query
query_posts( 'category_name='.$categName);
// The Loop
if ( have_posts() ) : while ( have_posts() ) : the_post();
$testVar .=the_title("",0);
endwhile; else: endif;
// Reset Query
wp_reset_query();
return $testVar;
}
endif;
?>