'Sidebar', 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', )); } //GPL image grab code by Justin Tadlock of http://justintadlock.com function get_the_image($args = array()) { $defaults = array( 'custom_key' => array('Thumbnail','thumbnail'), 'post_id' => false, // Build functionality in later 'attachment' => true, 'default_size' => 'thumbnail', 'default_image' => false, 'order_of_image' => 1, 'link_to_post' => true, 'image_class' => false, 'image_scan' => false, 'width' => false, 'height' => false, 'echo' => true ); $args = apply_filters('get_the_image_args', $args); $args = wp_parse_args($args, $defaults); extract($args); if(!is_array($custom_key)) : $custom_key = str_replace(' ', '', $custom_key); $custom_key = str_replace(array('+'), ',', $custom_key); $custom_key = explode(',', $custom_key); $args['custom_key'] = $custom_key; endif; if($custom_key && $custom_key !== 'false' && $custom_key !== '0') $image = image_by_custom_field($args); if(!$image && $attachment && $attachment !== 'false' && $attachment !=='0') $image = image_by_attachment($args); if(!$image && $image_scan) $image = image_by_scan($args); if(!$image && $default_image) $image = image_by_default($args); if($image) $image = display_the_image($args, $image); else $image = ''; if($echo && $echo !== 'false' && $echo !== '0') echo $image; else return $image; } function image_by_custom_field($args = array()) { extract($args); if(!$post_id) global $post; if(isset($custom_key)) : foreach($custom_key as $custom) : $image = get_post_meta($post->ID, $custom, true); if($image) : break; endif; endforeach; if(!$image) : return false; endif; endif; return array('image' => $image); } function image_by_attachment($args = array()) { extract($args); if(!$post_id) global $post; if(function_exists('wp_enqueue_style')) : $attachments = get_children(array('post_parent' => $post->ID, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID')); else : $attachments = get_children("post_parent=$post->ID&post_type=attachment&post_mime_type=image&orderby=\"menu_order ASC, ID ASC\""); endif; if($attachments) : foreach($attachments as $id => $attachment) : $i++; if($i == $order_of_image) : $image = wp_get_attachment_image_src($id, $default_size); $image = $image[0]; break; endif; endforeach; endif; return array('image' => $image); } function image_by_scan($args = array()) { if(!$post_id) global $post; preg_match_all('||i', $post->post_content, $matches); if(isset($matches)) $image = $matches[1][0]; if($matches) return array('image' => $image); else return false; } function image_by_default($args = array()) { extract($args); $image = $default_image; return array('image' => $image); } function display_the_image($args = array(), $arr = false) { global $post; extract($arr); if(!$image) return; extract($args); if($width) $width = ' width="' . $width . '"'; if($height) $height = ' height="' . $height . '"'; return $image; } $themename = "Smooth Real Estate"; $shortname = "sre"; $options = array ( array( "name" => "Color Hex For Menus", "desc" => "This is where you enter the main color hex for the menu. You must enter a hex in this field for any of the color hexes to work.", "id" => $shortname."_color_hex", "std" => "Enter your color hex.", "type" => "text"), array( "name" => "Color Hex For Sub Menus", "desc" => "This is where you enter a color hex for the sub menu.", "id" => $shortname."_color_hex_sub", "std" => "Enter your color hex.", "type" => "text"), array( "name" => "Link Color Hex", "desc" => "This is where you enter a color hex for the link colors.", "id" => $shortname."_link_color_hex", "std" => "Enter your color hex.", "type" => "text"), ); function mytheme_add_admin() { global $themename, $shortname, $options; if ( $_GET['page'] == basename(__FILE__) ) { if ( 'save' == $_REQUEST['action'] ) { foreach ($options as $value) { if($value['type'] != 'multicheck'){ update_option( $value['id'], $_REQUEST[ $value['id'] ] ); }else{ foreach($value['options'] as $mc_key => $mc_value){ $up_opt = $value['id'].'_'.$mc_key; update_option($up_opt, $_REQUEST[$up_opt] ); } } } foreach ($options as $value) { if($value['type'] != 'multicheck'){ if( isset( $_REQUEST[ $value['id'] ] ) ) { update_option( $value['id'], $_REQUEST[ $value['id'] ] ); } else { delete_option( $value['id'] ); } }else{ foreach($value['options'] as $mc_key => $mc_value){ $up_opt = $value['id'].'_'.$mc_key; if( isset( $_REQUEST[ $up_opt ] ) ) { update_option( $up_opt, $_REQUEST[ $up_opt ] ); } else { delete_option( $up_opt ); } } } } header("Location: themes.php?page=functions.php&saved=true"); die; } else if( 'reset' == $_REQUEST['action'] ) { foreach ($options as $value) { if($value['type'] != 'multicheck'){ delete_option( $value['id'] ); }else{ foreach($value['options'] as $mc_key => $mc_value){ $del_opt = $value['id'].'_'.$mc_key; delete_option($del_opt); } } } header("Location: themes.php?page=functions.php&reset=true"); die; } } add_theme_page($themename." Options", "$themename Options", 'edit_themes', basename(__FILE__), 'mytheme_admin'); } function mytheme_admin() { global $themename, $shortname, $options; if ( $_REQUEST['saved'] ) echo '

'.$themename.' settings saved.

'; if ( $_REQUEST['reset'] ) echo '

'.$themename.' settings reset.

'; ?>

options

" /> $option) { $radio_setting = get_settings($value['id']); if($radio_setting != ''){ if ($key == get_settings($value['id']) ) { $checked = "checked=\"checked\""; } else { $checked = ""; } }else{ if($key == $value['std']){ $checked = "checked=\"checked\""; }else{ $checked = ""; } }?> />
/>  < $option) { $pn_key = $value['id'] . '_' . $key; $checkbox_setting = get_settings($pn_key); if($checkbox_setting != ''){ if (get_settings($pn_key) ) { $checked = "checked=\"checked\""; } else { $checked = ""; } }else{ if($key == $value['std']){ $checked = "checked=\"checked\""; }else{ $checked = ""; } }?> />

: