Skip to content

Value of "id" and "checked" isn't being displayed in checkbox options  #213

@KevHaitch

Description

@KevHaitch

The "input_checkbox_callback" function isn't displaying the values for "id" and "checked" when echoing "wp_kses". The "Options" UI therefore always shows these as "unchecked / false" so users may accidentally overwrite these setting if saved without re-checking the desired options.

I believe the following code fixes this:

  /**
   * Checkboxes' Callbacks
   */
  public function input_checkbox_callback( $args ) {
    $this->options = get_option( 'wpscss_options' );
    $html = "";
    $option_name = esc_attr( $args['name']);
    if($option_name == 'always_recompile' && defined('WP_SCSS_ALWAYS_RECOMPILE') && WP_SCSS_ALWAYS_RECOMPILE){
      $html .= '<input type="checkbox" id="' . $option_name . '" name="wpscss_options[' . $option_name . ']" value="1"' . checked( 1, isset( $this->options[$option_name] ) ? $this->options[$option_name] : 1, false ) . ' disabled=disabled/>';
      $html .= '<label for="' . $option_name . '">Currently overwritten by constant <code>WP_SCSS_ALWAYS_RECOMPILE</code></label>';
    }else{
      $html .= '<input type="checkbox" id="' . $option_name . '" name="wpscss_options[' . $option_name . ']" value="1"' . checked( 1, isset( $this->options[$option_name] ) ? $this->options[$option_name] : 0, false ) . '/>';
      $html .= '<label for="' . $option_name . '"></label>';
    }

    echo wp_kses($html, array('input' => array('type' => array(), 'id' => array(), 'name' => array(), 'value' => array(), 'checked' => array(), 'disabled' => array()), 'label' => array('for' => array()) ));
  }  

I'll submit a pull request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions