rendered paste body<?phpif ( function_exists('register_sidebar') ) register_sidebar(array( 'before_widget' => '<li id="%1$s" class="widget %2$s">', 'after_widget' => '</li>', 'before_title' => '<h2 class="widgettitle">', 'after_title' => '</h2>', ));function applyColor() { $colorField = get_post_custom_values('_stckd_post_color'); switch ($colorField[0]) { case "Blue": echo "-blue"; break; case "Orange": echo "-orange"; break; case "Pink": echo "-pink"; break; case "Green": echo "-green"; break; case "Yellow": echo "-yellow"; break; case "Magenta": echo "-magenta"; break; default: echo "-white"; } }/* For checking if the visitor uses Safari */function isSafari() { $agent = $_SERVER['HTTP_USER_AGENT']; if (stristr($agent, 'AppleWebKit') === FALSE) { //echo '<!--NOT SAFARI-->'; return FALSE; } else { //echo '<!--THIS IS SAFARI-->'; return TRUE; }}function isOpera() { $agent = $_SERVER['HTTP_USER_AGENT']; if (stristr($agent, 'Opera') === FALSE) { //echo '<!--NOT SAFARI-->'; return FALSE; } else { //echo '<!--THIS IS SAFARI-->'; return TRUE; }}add_action('edit_form_advanced', 'postOptions');function postOptions() { global $post_ID; ?> <script type="text/javascript" language="JavaScript"><!-- function setComboColor() { var obj = document.getElementById("_stckd_post_color"); var display = document.getElementById("_stckd_post_color_display"); var i = obj.selectedIndex; display.style.backgroundColor = obj.options[i].value; } //--></script> <h2>Stck'd Options</h2> <div id="stckd_options" class="postbox if-js-closed"> <h3>Color Combinations</h3> <div class="inside"> <table id="stckd" cellspacing="3" cellpadding="3"> <tbody> <tr> <td>Sticky color for this post:</td> <td> <?php echo createColorSelect(get_post_meta($post_ID,'_stckd_post_color', true)); ?> </td> <td style="width:10%;background-color:<?php echo get_post_meta($post_ID,'_stckd_post_color', true);?>" id="_stckd_post_color_display"></td> </tr> </tbody> </table> </div> </div><?php } ?><?phpadd_action('edit_post', 'add_custom_field');add_action('publish_post', 'add_custom_field');add_action('save_post', 'add_custom_field');add_action('edit_page_form', 'add_custom_field'); function add_custom_field($id) { //delete the existing field delete_post_meta($id, '_stckd_post_color'); //Get the value from your form $userEnteredValue = $_POST["_stckd_post_color"]; //Add your value as a custom field with the key 'myKey' //but only if the form data exists if (isset($userEnteredValue) && !empty ($userEnteredValue)){ add_post_meta($id, '_stckd_post_color', $userEnteredValue);}}function createColorSelect($selected) { $colors = array('White', 'Green', 'Orange', 'Blue', 'Pink', 'Magenta', 'Yellow'); $output = '<select id="_stckd_post_color" onchange="setComboColor();" tabindex="7" name="_stckd_post_color">'; $output .= '<option value="">- Use default Color -</option>'; foreach ($colors as $color) { if ($selected == $color) { $output .= '<option selected value="'.$color.'">'.$color.'</option>'; } else { $output .= '<option value="'.$color.'">'.$color.'</option>'; } } $output .= '</select>'; return $output; }function createBackgroundSelect($selected) { $backgrounds = array('Paper', 'Paper 2', 'Wood', 'Wood 2', 'Light Wood', 'Solid'); $output = '<select id="_stckd_background" tabindex="7" name="_stckd_background">'; $output .= '<option value="">- Use default Background -</option>'; foreach ($backgrounds as $background) { if ($selected == $background) { $output .= '<option selected value="'.$background.'">'.$background.'</option>'; } else { $output .= '<option value="'.$background.'">'.$background.'</option>'; } } $output .= '</select>'; return $output; }?>