_x('Banners', 'post type general name', 'woothemes'), 'singular_name' => _x('Banner', 'post type singular name', 'woothemes'), 'add_new' => _x('Add New', 'banner', 'woothemes'), 'add_new_item' => __('Add New Banner', 'woothemes'), 'edit_item' => __('Edit Banner', 'woothemes'), 'new_item' => __('New Banner', 'woothemes'), 'view_item' => __('View Banner', 'woothemes'), 'search_items' => __('Search Banners', 'woothemes'), 'not_found' => __('No banners found', 'woothemes'), 'not_found_in_trash' => __('No banners found in Trash', 'woothemes'), 'parent_item_colon' => '' ); $args = array( 'labels' => $labels, 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'query_var' => true, 'rewrite' => array('slug' => 'banners'), 'capability_type' => 'post', 'hierarchical' => false, 'menu_icon' => '/wp-content/themes/canvas/includes/images/slides.png', 'menu_position' => null, '_builtin' => false, 'supports' => array('title','editor'/*,'comments','excerpt','author','thumbnail',*/) ); register_post_type('banner',$args); } /*-----------------------------------------------------------------------------------*/ /* Custom Post Type - Product */ /*-----------------------------------------------------------------------------------*/ add_action('init', 'woo_add_product'); function woo_add_product() { $labels = array( 'name' => _x('Products', 'post type general name', 'woothemes'), 'singular_name' => _x('Product', 'post type singular name', 'woothemes'), 'add_new' => _x('Add New', 'product', 'woothemes'), 'add_new_item' => __('Add New Product', 'woothemes'), 'edit_item' => __('Edit Product', 'woothemes'), 'new_item' => __('New Product', 'woothemes'), 'view_item' => __('View Product', 'woothemes'), 'search_items' => __('Search Products', 'woothemes'), 'not_found' => __('No products found', 'woothemes'), 'not_found_in_trash' => __('No products found in Trash', 'woothemes'), 'parent_item_colon' => '' ); $args = array( 'labels' => $labels, 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'query_var' => true, 'rewrite' => array('slug' => 'products'), 'capability_type' => 'post', 'hierarchical' => true, 'menu_icon' => '/wp-content/themes/canvas/includes/images/slides.png', 'menu_position' => null, '_builtin' => false, 'supports' => array('title','editor', 'page-attributes','thumbnail'/*,'comments','excerpt','author'*/) ); register_post_type('product',$args); } /*-----------------------------------------------------------------------------------*/ /* Custom Post Type - News */ /*-----------------------------------------------------------------------------------*/ add_action('init', 'woo_add_news'); function woo_add_news() { $labels = array( 'name' => _x('News', 'post type general name', 'woothemes'), 'singular_name' => _x('News', 'post type singular name', 'woothemes'), 'add_new' => _x('Add New', 'news', 'woothemes'), 'add_new_item' => __('Add New News', 'woothemes'), 'edit_item' => __('Edit News', 'woothemes'), 'new_item' => __('New News', 'woothemes'), 'view_item' => __('View News', 'woothemes'), 'search_items' => __('Search News', 'woothemes'), 'not_found' => __('No news found', 'woothemes'), 'not_found_in_trash' => __('No news found in Trash', 'woothemes'), 'parent_item_colon' => '' ); $args = array( 'labels' => $labels, 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'query_var' => true, 'rewrite' => array('slug' => 'news'), 'capability_type' => 'post', 'hierarchical' => true, 'menu_icon' => '/wp-content/themes/canvas/includes/images/slides.png', 'menu_position' => null, '_builtin' => false, 'supports' => array('title','editor'/*, 'thumbnail','comments','excerpt','author'*/) ); register_post_type('news',$args); } /*-----------------------------------------------------------------------------------*/ /* Custom Post Type - Careers */ /*-----------------------------------------------------------------------------------*/ add_action('init', 'woo_add_career'); function woo_add_career() { $labels = array( 'name' => _x('Careers', 'post type general name', 'woothemes'), 'singular_name' => _x('Careers', 'post type singular name', 'woothemes'), 'add_new' => _x('Add New', 'career', 'woothemes'), 'add_new_item' => __('Add New Careers', 'woothemes'), 'edit_item' => __('Edit Careers', 'woothemes'), 'new_item' => __('New Careers', 'woothemes'), 'view_item' => __('View Careers', 'woothemes'), 'search_items' => __('Search Careers', 'woothemes'), 'not_found' => __('No careers found', 'woothemes'), 'not_found_in_trash' => __('No careers found in Trash', 'woothemes'), 'parent_item_colon' => '' ); $args = array( 'labels' => $labels, 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'query_var' => true, 'rewrite' => array('slug' => 'careers'), 'capability_type' => 'post', 'hierarchical' => true, 'menu_icon' => '/wp-content/themes/canvas/includes/images/slides.png', 'menu_position' => null, '_builtin' => false, 'supports' => array('title','editor'/*, 'thumbnail','comments','excerpt','author'*/) ); register_post_type('career',$args); } /*-----------------------------------------------------------------------------------*/ /* Custom Post Type - Games */ /*-----------------------------------------------------------------------------------*/ add_action('init', 'woo_add_game'); function woo_add_game() { $labels = array( 'name' => _x('Games', 'post type general name', 'woothemes'), 'singular_name' => _x('Games', 'post type singular name', 'woothemes'), 'add_new' => _x('Add New', 'game', 'woothemes'), 'add_new_item' => __('Add New Games', 'woothemes'), 'edit_item' => __('Edit Games', 'woothemes'), 'new_item' => __('New Games', 'woothemes'), 'view_item' => __('View Games', 'woothemes'), 'search_items' => __('Search Games', 'woothemes'), 'not_found' => __('No Games found', 'woothemes'), 'not_found_in_trash' => __('No Games found in Trash', 'woothemes'), 'parent_item_colon' => '' ); $args = array( 'labels' => $labels, 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'query_var' => true, 'rewrite' => array('slug' => 'game'), 'capability_type' => 'post', 'hierarchical' => true, 'menu_icon' => '/wp-content/themes/canvas/includes/images/slides.png', 'menu_position' => null, '_builtin' => false, 'supports' => array('title','editor', 'thumbnail','page-attributes'/*'comments','excerpt','author'*/) ); register_post_type('game',$args); } /*** META BOXES ***/ // Add more custom fields function woo_metaboxes_add($woo_metaboxes) { //CHECK FOR HOMEPAGE $post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'] ; $template_file = get_post_meta($post_id,'_wp_page_template',TRUE); //HOMEPAGE META BOXES if ($template_file == 'template-home.php' || ! get_post_type()){ $woo_metaboxes['home_large_image'] = array ( "name" => "home_large_image", "label" => "Large Image", "type" => "upload", "desc" => "Upload an image to display in the center of the page. Ideally width - 687px, height - 361px" ); $woo_metaboxes['home_large_image_alt'] = array ( "name" => "home_large_image_alt", "label" => "Large Image Alt Text", "type" => "text", "desc" => "Descriptive alt text for image (SEO)" ); $woo_metaboxes['home_large_image_link'] = array ( "name" => "home_large_image_link", "label" => "Large Image Link", "type" => "text", "desc" => "Full URL" ); $woo_metaboxes['home_small_image'] = array ( "name" => "home_small_image", "label" => "Small Image", "type" => "upload", "desc" => "Upload an image (PNG) to display on the right of the page." ); $woo_metaboxes['home_small_image_alt'] = array ( "name" => "home_small_image_alt", "label" => "Small Image Alt Text", "type" => "text", "desc" => "Descriptive alt text for image (SEO)" ); $woo_metaboxes['home_small_image_link'] = array ( "name" => "home_small_image_link", "label" => "Small Image Link", "type" => "text", "desc" => "Full URL" ); $woo_metaboxes['home_nav_image'] = array ( "name" => "home_nav_image", "label" => "Nav Image", "type" => "upload", "desc" => "Transparent PNG with ALL nav elements included (240px x 60px) with nav text included. See current nav image" ); $woo_metaboxes['home_bg_image'] = array ( "name" => "home_bg_image", "label" => "Background Image", "type" => "upload", "desc" => "Tiling PNG. To use a non-tiling background CSS will have to be edited. See current background image" ); //get banners $args = array( 'numberposts' => 99, 'post_type' => "banner" ); $banners = get_posts( $args ); //create array to hold page titles $pages = array(); foreach( $banners as $post ) : setup_postdata($post); array_push($pages,get_the_title($post->ID)); endforeach; $woo_metaboxes['page_banner'] = array ( "name" => "page_banner", "label" => "Banner", "desc" => "Which banner would you like to display?", "type" => "select", "options" => $pages ); wp_reset_query(); } // Check for post type = page if( get_post_type() == 'page' && $template_file != 'template-home.php' || ! get_post_type()){ $woo_metaboxes['page_heading'] = array ( "name" => "page_heading", "label" => "Page Heading", "type" => "text", "desc" => "Use this field if you want the page content title tag to be different from the page name, otherwise leave blank" ); $woo_metaboxes['page_inset'] = array ( "name" => "page_inset", "label" => "Page Inset Image", "type" => "upload", "desc" => "Upload an image to display on right side of page. Max width - 307px, Max height - 379px" ); /*$woo_metaboxes['page_image'] = array ( "name" => "page_image", "label" => "Page Image", "type" => "upload", "desc" => "Upload an image to appear in right column" );*/ } // CHECK FOR POST TYPE BANNER if( get_post_type() == 'banner' || ! get_post_type()) { $woo_metaboxes['banner_info'] = array ( "name" => "banner_info", "label" => "Banner how to:", "type" => "info", "desc" => "Use the WordPress image uploader indicated above with a photo icon in the Upload/Insert section to create a new banner. You can upload a single image or multiple to create a banner image rotation." ); } // CHECK FOR POST TYPE NEWS if( get_post_type() == 'news' || ! get_post_type()) { $woo_metaboxes['news_source'] = array ( "name" => "news_source", "label" => "News source", "type" => "text", "desc" => "Enter name of news publication (if applicable)" ); $woo_metaboxes['news_link'] = array ( "name" => "news_link", "label" => "News Link", "type" => "text", "desc" => "Enter full link URL to external news source (if applicable)" ); $woo_metaboxes['news_document'] = array ( "name" => "news_document", "label" => "PDF Document", "type" => "upload", "desc" => "Upload a PDF (if applicable)" ); } // CHECK FOR CONTACT/CAREERS PAGE if( $post_id == 166 || ! get_post_type()) { $woo_metaboxes['careers_intro'] = array ( "name" => "careers_intro", "label" => "Intro Text", "type" => "text", "desc" => "Enter text to preceed list of careers" ); } // CHECK FOR POST TYPE CAREER if( get_post_type() == 'career' || ! get_post_type()) { $woo_metaboxes['career_document'] = array ( "name" => "career_document", "label" => "PDF Document", "type" => "upload", "desc" => "Upload a PDF" ); } // CHECK FOR POST TYPE GAME if( get_post_type() == 'game' || ! get_post_type()) { $woo_metaboxes['game_icon'] = array ( "name" => "game_icon", "label" => "Game Icon / Character Image", "type" => "upload", "desc" => "200px max width" ); $woo_metaboxes['game_title_image'] = array ( "name" => "game_title_image", "label" => "Game Title Image", "type" => "upload", "desc" => "450px max width" ); $woo_metaboxes['game_ios_link'] = array ( "name" => "game_ios_link", "label" => "iOS SKU", "type" => "text" ); $woo_metaboxes['game_android_link'] = array ( "name" => "game_android_link", "label" => "Android SKU", "type" => "text" ); $woo_metaboxes['game_chrome_link'] = array ( "name" => "game_chrome_link", "label" => "Chrome SKU", "type" => "text" ); } // CHECK FOR POST TYPE PRODUCT if( get_post_type() == 'product' || ! get_post_type()) { $woo_metaboxes['product_faq_android'] = array ( "name" => "product_faq_android", "label" => "Android FAQ", "type" => "text", "desc" => "URL to Android FAQ page" ); $woo_metaboxes['product_faq_ios'] = array ( "name" => "product_faq_ios", "label" => "iOS FAQ", "type" => "text", "desc" => "URL to iOS FAQ page" ); } return $woo_metaboxes; } /*** HELPER FUNCTIONS ***/ //GET POST THUMBNAIL SOURCE function getThumbnailSource($id) { $thumb = get_the_post_thumbnail($id); $pattern= "/(?<=src=['|\"])[^'|\"]*?(?=['|\"])/i"; preg_match($pattern, $thumb, $thePath); $theSrc = $thePath[0]; return $theSrc; } //GET FEATURED IMAGE CAPTION function the_post_thumbnail_caption() { global $post; $thumbnail_id = get_post_thumbnail_id($post->ID); $thumbnail_image = get_posts(array('p' => $thumbnail_id, 'post_type' => 'attachment')); return $thumbnail_image[0]->post_excerpt; } //CREATE HOMEPAGE BANNER ROTATION function banner_rotation() { $gallery = stm_get_post_images(1); // Output image gallery for slider if ( $gallery ) { foreach ( $gallery as $attachment) { //check for caption if($attachment['caption'] != ""): echo ''; echo woo_image('key=image&src='.$attachment['url'].'&width=690&height=111&class=gallery-img&link=img'); echo ''; else: echo woo_image('key=image&src='.$attachment['url'].'&width=690&height=111&class=gallery-img&link=img'); endif; } } } function banner_rotation_2($id) { $gallery = get_banner_images($id,0); // Output image gallery for slider if ( $gallery ) { foreach ( $gallery as $attachment) { //check for caption if($attachment['caption'] != ""): echo ''; echo woo_image('key=image&src='.$attachment['url'].'&width=690&height=111&class=banner-images&link=img'); echo ''; else: echo woo_image('key=image&src='.$attachment['url'].'&width=690&height=111&class=banner-images&link=img'); endif; } } } function doBanner() { if(the_post_thumbnail_caption() != ""): ?> <? the_title();?> <? the_title();?> <? the_title();?> $id, 'numberposts' => $repeat, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order date') ); if ( !empty($attachments) ) : $output = array(); $count = 0; foreach ( $attachments as $att_id => $attachment ) { $count++; if ($count <= $offset) continue; $url = wp_get_attachment_image_src($att_id, $photo_size, true); if ( $url[0] != $exclude ) $output[] = array( "url" => $url[0], "caption" => $attachment->post_excerpt, "content" => $attachment->post_content ); } endif; return $output; } } /*-----------------------------------------------------------------------------------*/ /* Get Banner Post image attachments */ /*-----------------------------------------------------------------------------------*/ /* Description: This function will get all the attached post images that have been uploaded via the WP post image upload and return them in an array. */ function get_banner_images($id, $offset = 0) { // Arguments $repeat = 100; // Number of maximum attachments to get $photo_size = 'large'; // The WP "size" to use for the large image $attachments = get_children( array( 'post_parent' => $id, 'numberposts' => $repeat, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order date') ); if ( !empty($attachments) ) : $output = array(); $count = 0; foreach ( $attachments as $att_id => $attachment ) { $count++; if ($count <= $offset) continue; $url = wp_get_attachment_image_src($att_id, $photo_size, true); //if ( $url[0] != $exclude ) if ( $url[0] ) $output[] = array( "url" => $url[0], "caption" => $attachment->post_excerpt ); } endif; return $output; } //GET POST BY TITLE function get_banner_by_title($page_title, $output = OBJECT) { global $wpdb; $post = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_title = %s AND post_type='banner'", $page_title )); if ( $post ) return get_post($post, $output); return null; } function is_subpage() { global $post; // if outside the loop if ( is_page() && $post->post_parent ) { // This is a subpage return true; } else { // This is not a subpage return false; } } ?> SilverTree Media | Contact & Careers

News

ID,'page_banner',true); $banner = get_banner_by_title($banner_title); banner_rotation_2($banner->ID); else: doBanner(); endif; ?>
post_content); $title = $careers_page->post_title; // Get title
$intro = get_post_meta($page_id,'careers_intro',true); ?>
ID,'page_heading',true); if($heading == "") {$heading = get_the_title($post->ID);} ?>
Contact
post_status == 'publish') : ?>
Careers
post_status == 'publish') : ?>
Contact
Careers

ID,'career_document',true); ?> (pdf)

ID,'page_inset',true); if ($inset) : ?> <? the_title();?>