WordPress.org

Support

Support » Themes and Templates » [Resolved] JSColor color picker intergrate problem

[Resolved] JSColor color picker intergrate problem

  • Hi everyone!

    I started creating a theme, and I encountered a serious problem, as I’m not an advanced JS or PHP programmer. A color value after clicking “save” is not actually saved for my color picker. Every other field, no matter it’s a text field, text area, radio button or else is being saved properly, except unfortunate color picker field. I downloaded my picker from http://jscolor.com/. Maybe there is someone who could help me a bit.

    few code samples:

    field settings –

    array( "name" => "Bg Color",
    "desc" => "#abcd01.",
    "id" => $shortname."_background",
    "type" => "picker",
    "std" => "abcdef"),

    input settings –

    case 'picker': ?>
    
    <tr><td><p><label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label></p></td>
    <td><p><input <input name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" value="<?php if ( get_settings( $value['id'] ) != "") { echo stripslashes(get_settings( $value['id'])  ); } else { echo $value['std']; } ?>" class="color" />
    <small><?php echo $value['desc']; ?></small></p></td></tr>
    
    <?php break;

    save function settings –

    [ Moderator Note: Please post code or markup snippets between backticks or use the code button. Single quote does not work. ]

    function theme_settings_page() {
    	global $themename,$theme_options;
    	$i=0;
    	$message='';
    		if ( 'save' == $_REQUEST['action'] ) {
    
    			foreach ($theme_options as $value) {
    		update_option( $value['id'], $_REQUEST[ $value['id'] ] ); }
    
    			foreach ($theme_options as $value) {
    		if( isset( $_REQUEST[ $value['id'] ] ) ) { update_option( $value['id'], $_REQUEST[ $value['id'] ]  ); } else { delete_option( $value['id'] ); } }
    $message='saved';
    }
    
    else if( 'reset' == $_REQUEST['action'] ) {
    
    			foreach ($theme_options as $value) {
    		delete_option( $value['id'] ); }
    $message='reset';
    }
    		if ( $message=='saved' && $i==0 )  echo '<div id="message" class="apply"><strong>Ustawienia zachowane.</strong></div>' ;
    		if ( $message=='reset' ) echo '<div id="message" class="reset"><strong>Ustawienia zresetowane.</strong></div>';
    
    ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • I need to specify my previous post, picker is displayed correctly, everything works fine, but after saving value in text field goes back to initial value, which is stored as ‘std’.

    Nevermind, other text field had the same id, I didn’t notice until now, problem fixed!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] JSColor color picker intergrate problem’ is closed to new replies.
Skip to toolbar