Example #1
0
function ultimatum_default_template_nag(){
$msg=false;
$defaults = getDefaultTempLateandLayout();
//print_r($defaults);
if(!isset($defaults->tname)){
$msg = __('WARNING YOU DONT SEEM TO HAVE A DEFAULT TEMPLATE OR YOU MISS A DEFAULT LAYOUT','ultimatum'); 
} elseif(!isset($defaults->title)){
$msg = __('WARNING YOU DONT SEEM TO HAVE A DEFAULT LAYOUT','ultimatum');
}
			
if($msg){ echo "<div class='error'><p>$msg</p></div>"; }
}
function ultimatum_findLayout(){
	global $post;
	global $ultimatumlayout;
	if($ultimatumlayout){
		return;
	}
	// 404 Assignment
	if(is_404()){
		$ultimatumlayout = getLayoutInfoFromAssignment('404');
	}
	// Search Assignment
	if(is_search()){
		$ultimatumlayout = getLayoutInfoFromAssignment('search');
	}
	//
	if(is_author()){
		$ultimatumlayout = getLayoutInfoFromAssignment('author');
	}
	if(is_front_page()){
		$ultimatumlayout = getLayoutInfoFromAssignment('home');
	}
	if(is_home()){
		$page_for_posts = get_option( 'page_for_posts' );
		$meta_key= THEME_SLUG.'_layout';
		$ultimatumlayout =  getLayoutInfo(get_post_meta($page_for_posts, $meta_key, true));
	}
	if(!$ultimatumlayout){
		if(is_single() || is_page()){ // look for individual post layout
			$meta_key= THEME_SLUG.'_layout';
			$ultimatumlayout =  getLayoutInfo(get_post_meta($post->ID, $meta_key, true));
			if(!$ultimatumlayout){
				$posttype = $post->post_type.'-single';
				$ultimatumlayout = getLayoutInfoFromAssignment($posttype);
			}
		} else { // Look for cats taxes for multiple posts
			if(is_category()){
				$thisCat = get_category(get_query_var('cat'),false);
				$posttype = 'cat-'.$thisCat->term_id;
				$ultimatumlayout = getLayoutInfoFromAssignment($posttype);
			} else if (is_tax()) {
				$posttype = $post->post_type;
				global $wp_query;
				$tax =  get_query_var('taxonomy');
				$term =  get_query_var('term');
				$posttype =  $posttype.'-'.$tax.'-'.$term;
				$ultimatumlayout = getLayoutInfoFromAssignment($posttype);
			} else if(is_tag()){
				$posttype = $post->post_type;
				global $wp_query;
				$tax =  'post_tag';
				$term =  get_query_var('tag');
				$posttype =  $posttype.'-'.$tax.'-'.$term;
				$ultimatumlayout = getLayoutInfoFromAssignment($posttype);
			}
			if(!$ultimatumlayout){
				$posttype =  str_replace($post->post_type.'_', '',$posttype);
				$ultimatumlayout = getLayoutInfoFromAssignment($posttype);
			}
		}
	}
	if(!$ultimatumlayout){ //look for post type layout
		$posttype=$post->post_type;
		$ultimatumlayout = getLayoutInfoFromAssignment($posttype);
	}
	if(!$ultimatumlayout){//none found go with default
		$ultimatumlayout = getDefaultTempLateandLayout();
	}
	add_filter('body_class','ultimatum_body_class',10);
	//print_r($ultimatumlayout);
}
function ult_wysiwyg_widget_preview(){
    if($_GET['ult-front-frame'] == "ult-wysiwyg-widget") {
        global $ultimatumlayout;
        $ultimatumlayout = getDefaultTempLateandLayout();
        echo '<head>';
        wp_head();
        echo '<script type="text/javascript"> var pptheme = "facebook"; </script></head>';
        echo '<body>';
        echo '<div class="wrapper">';
        echo '<div class="container container_12">';
        echo apply_filters('wp_editor_widget_content', urldecode(base64_decode($_GET['data'])));
        wp_footer();
        echo '</div></div></body></html>';
    }
}