ID, '_kirmom_splash_meta', true ); echo '#' . $meta['bg-color']; } function kirmom_color( $color = '' ) { global $post; $meta = get_post_meta( $post->ID, '_kirmom_splash_meta', true ); echo '#' . $meta[$color . '-color']; } function kirmom_quadrants() { return array( 'top-left' => 'Top Left', 'top-right' => 'Top Right', 'bottom-left' => 'Bottom Left', 'bottom-right' => 'Bottom Right' ); } function kirmom_layouts() { return array( 'top-left_top-right', 'top-left_bottom-left', 'top-left_bottom-right', 'top-right_bottom-left', 'top-right_bottom-right', 'bottom-left_bottom-right', ); } function kirmom_alignments() { return array( 'left', 'right', ); } function kirmom_contents() { return array( 'none' => 'No Content', 'content' => 'Page Content', 'nav' => 'Title and Navigation', ); } function kirmom_colors() { return array( 'bg' => 'Background', 'text' => 'Text', 'link1' => 'Link 1', 'link2' => 'Link 2', ); } function kirmom_display_quadrants() { $quadrants = array_keys( kirmom_quadrants() ); ?>
ID, '_kirmom_splash_meta', true ); $areas = explode( '_', $meta['layout'] ); foreach ( $areas as $area => $q ) { if ( $quadrant == $q ) { $align = $meta['quadrant' . ( $area + 1 ) . '-alignment']; if ( in_array( $align, kirmom_alignments() ) ) $class = ' class="align' . $align . '"'; echo ""; switch ( $meta['quadrant' . ( $area + 1 ) . '-content'] ) { case 'nav': kirmom_navigation(); break; case 'content': the_content(); break; case 'none': default: break; } echo ''; } } } function kirmom_navigation() { global $post; if ( is_home() || is_front_page() ) { echo '

' . get_bloginfo( 'name' ) . '

'; wp_nav_menu( array( 'theme_location' => 'primary' ) ); } else { echo '

' . get_the_title() . '

'; if ( $post->post_parent ) echo '

← ' . get_the_title( $post->post_parent ) . '

'; else echo '

← ' . __( 'Home' ) . '

'; } } /* Special thanks to Dimas for the following tutorials on custom meta boxes! http://www.farinspace.com/page-specific-wordpress-meta-box/ http://www.farinspace.com/how-to-create-custom-wordpress-meta-box/ */ function kirmom_post_meta_init() { $post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID']; if ( 'splash.php' == get_post_meta( $post_id, '_wp_page_template', true ) ) { add_meta_box( 'kirmom_post_meta', 'Splash Options', 'kirmom_post_meta_setup', 'page', 'normal', 'high' ); add_action( 'save_post', 'kirmom_post_meta_save' ); wp_enqueue_style( 'farbtastic'); wp_enqueue_script( 'splash-colorpickers', get_stylesheet_directory_uri() . '/colorpickers.js', array( 'jquery', 'farbtastic' ) ); } } add_action( 'admin_init', 'kirmom_post_meta_init' ); function kirmom_post_meta_setup() { global $post; // using an underscore, prevents the meta variable from showing up in the custom fields section $meta = get_post_meta( $post->ID, '_kirmom_splash_meta', true ); ?>

The background of the splash page will use the Featured Image. For best results, use an image at least 1024x1024 pixels in size.

Colors

$description ) { echo "

$description: " . __( 'Select a Color' ) . "

"; } ?>

Layout

Need better images here.

'; } ?>

Quadrants (designated by number in the selected layout above)

: aligned displaying

ID ) . '" />'; } function kirmom_post_meta_save( $post_id ) { if ( !wp_verify_nonce( $_POST['kirmom_post_meta_noncename'], 'kirmom-post-meta-save_postid_' . $post_id ) ) return $post_id; if ( 'page' != $_POST['post_type'] || !current_user_can( 'edit_page', $post_id ) ) return $post_id; $current_data = get_post_meta( $post_id, '_kirmom_splash_meta', true ); $new_data = kirmom_post_meta_clean( $_POST['_kirmom_splash_meta'] ); if ( $current_data ) { if ( is_null( $new_data ) ) delete_post_meta( $post_id, '_kirmom_splash_meta' ); else update_post_meta( $post_id, '_kirmom_splash_meta', $new_data ); } elseif ( !is_null( $new_data ) ) { add_post_meta( $post_id, '_kirmom_splash_meta', $new_data, true ); } return $post_id; } function kirmom_post_meta_clean( $data ) { $allowed_layouts = kirmom_layouts(); $allowed_alignments = kirmom_alignments(); $allowed_contents = array_keys( kirmom_contents() ); $allowed_colors = array_keys( kirmom_colors() ); if ( !in_array( $data['layout'], $allowed_layouts ) ) $data['layout'] = $allowed_layouts[0]; for ( $i = 1; $i < 3; $i++ ) { if ( !in_array( $data['quadrant' . $i . '-alignment'], $allowed_alignments ) ) $data['quadrant' . $i . '-alignment'] = $allowed_alignments[0]; if ( !in_array( $data['quadrant' . $i . '-content'], $allowed_contents ) ) $data['quadrant' . $i . '-content'] = $allowed_contents[0]; } foreach ( $allowed_colors as $color ) { $data[$color . '-color'] = str_replace( '#', '', $data[$color . '-color'] ); if ( empty( $data[$color . '-color'] ) || !preg_match( '/^[a-f0-9]{6}$/i', $data[$color . '-color'] ) ) $data[$color . '-color'] = 'ffffff'; } return $data; }