Plugin Directory

Changeset 587972


Ignore:
Timestamp:
08/20/2012 08:57:26 PM (13 years ago)
Author:
jascott
Message:

Elements bug fixes

Location:
kickpress/trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • kickpress/trunk/elements/class-checkbox.php

    r583190 r587972  
    4545        extract( $params, EXTR_SKIP );
    4646       
    47         return self::_html_input( 'checkbox', $name, 1, array(
     47        return self::_html_input( 'checkbox', $name, 'enable', array(
    4848            'id'      => $id,
    4949            'class'   => $class,
    50             'checked' => 'enable' == $value
     50            'checked' => kickpress_boolean( $value )
    5151        ) );
     52    }
     53   
     54    public function validate_input( $data ) {
     55        return kickpress_boolean( $data ) ? 'enable' : 'disable';
    5256    }
    5357}
  • kickpress/trunk/includes/js/kickpress-ajax.js

    r570596 r587972  
    11jQuery(document).ready( function($) {
    2     $('a.ajax-reload').live('click', function(e) {
     2    $('a.ajax-reload').on('click', function(e) {
    33        var wrapper = $('div#' + this.rel);
    44       
  • kickpress/trunk/kickpress-api.php

    r586895 r587972  
    639639        );
    640640       
     641        $post_type = $this->params['post_type'];
     642       
     643        $filter_array = apply_filters( "kickpress_filter_array", $filter_array );
     644        $filter_array = apply_filters( "kickpress_filter_array_{$post_type}", $filter_array );
     645       
    641646        return $filter_array;
    642647    }
     
    17191724                    if ( !isset( $this->params['id'] ) )
    17201725                        $this->params['id'] = $post_id;
    1721    
     1726                   
     1727                    // this returns custom fields from the original API,
     1728                    // not the current post type
    17221729                    $fields = $this->get_custom_fields( true );
    17231730                   
     
    27482755        }
    27492756
    2750         $custom_fields = $this->get_custom_fields( $this->params['merge_base_fields'] == 'true' );
     2757        $custom_fields = $this->get_custom_fields( $this->params['merge_base_fields'] == 'enable' );
    27512758
    27522759        foreach ( $custom_fields as $key => $field ) {
  • kickpress/trunk/kickpress-form-elements.php

    r586927 r587972  
    6666   
    6767        if ( ! isset( $value ) ) $value = null;
    68         $attr = isset( $properties ) ? $properties : array();
    69        
    70         $attr['id']    = $id;
    71         $attr['class'] = $class;
     68       
     69        $attr = $this->get_attributes( $params );
    7270       
    7371        return self::_html_input( 'text', $name, $value, $attr );
     
    8785    }
    8886
     87    protected function get_attributes( $params ) {
     88        extract( $params, EXTR_SKIP );
     89       
     90        $attr = isset( $properties ) ? $properties : array();
     91        $attr['id']    = $id;
     92        $attr['class'] = $class;
     93       
     94        return $attr;
     95    }
     96
    8997    /**
    9098     * This method SHOULD be over-ridden in child classes
    9199     */
    92     public function validate_input( $data ) {
    93         return $data;
     100    public function validate_input( $value ) {
     101        return $value;
    94102    }
    95103   
     
    136144       
    137145        return self::_html_select( $name, $value, $options, $attr );
     146    }
     147   
     148    /**
     149     *
     150     */
     151    public static function filter_alpha( $value ) {
     152        return preg_replace( '/[^a-z]/i', '', $value );
     153    }
     154   
     155    /**
     156     *
     157     */
     158    public static function filter_alnum( $value ) {
     159        return preg_replace( '/[^0-9a-z]/i', '', $value );
     160    }
     161   
     162    /**
     163     *
     164     */
     165    public static function filter_digit( $value ) {
     166        return preg_replace( '/[^0-9]/', '', $value );
     167    }
     168   
     169    /**
     170     *
     171     */
     172    public static function filter_xdigit( $value ) {
     173        return preg_replace( '/[^0-9a-f]/i', '', $value );
    138174    }
    139175   
  • kickpress/trunk/kickpress-functions.php

    r586895 r587972  
    696696 * if one is provided, or FALSE otherwise.
    697697 */
    698 function kickpress_boolean( $param = null, $default = false ) {
     698function kickpress_boolean( $value = null, $default = false ) {
    699699    // ensure that the default is a boolean value
    700700    if ( ! is_bool( $default ) )
    701701        $default = kickpress_boolean( $default );
    702702   
    703     if ( is_null( $param ) )
     703    if ( is_null( $value ) ) {
    704704        return $default;
    705     elseif ( 'enable' == strtolower( $param ) )
    706         return true;
    707     elseif ( 'disable' == strtolower( $param ) )
    708         return false;
    709     elseif ( 'false' == strtolower( $param ) )
    710         return false;
    711     elseif ( is_string( $param ) )
    712         return (bool) trim( $param );
    713     elseif ( is_scalar( $param ) )
    714         return (bool) $param;
     705    } elseif ( is_string( $value ) ) {
     706        $true_strings  = array( 'true',  'enable' );
     707        $false_strings = array( 'false', 'disable' );
     708       
     709        $lower_value = strtolower( $value );
     710       
     711        if ( in_array( $lower_value, $true_strings ) )
     712            return true;
     713        elseif ( in_array( $lower_value, $false_strings ) )
     714            return false;
     715       
     716        return (bool) trim( $value );
     717    } elseif ( is_scalar( $value ) ) {
     718        return (bool) $value;
     719    }
    715720   
    716721    return $default;
  • kickpress/trunk/kickpress-post-types.php

    r586932 r587972  
    2525    $show_in_menu = current_user_can( 'manage_options' );
    2626
    27     register_taxonomy($cat_slug, 'custom-post-types', array(
     27    register_taxonomy( $cat_slug, 'custom-post-types', array(
    2828            'public'             => false,
    2929            'publicly_queryable' => false,
  • kickpress/trunk/kickpress-relationships.php

    r587447 r587972  
    399399            var slug = form.attr('id').substr(16);
    400400           
    401             var label = $('<label/>').text($(this).text());
     401            var input_id = 'rel_posts-' + slug + '-' + post_id;
     402           
     403            var label = $('<label/>', {
     404                'for': input_id
     405            }).text(' ' + $(this).text());
     406           
    402407            var input = $('<input/>', {
    403                 'type':  'hidden',
     408                'id': input_id,
     409                'type':  'checkbox',
    404410                'name':  'rel_posts[' + slug + '][]',
    405                 'value': post_id
     411                'value': post_id,
     412                'checked': 'checked'
    406413            });
    407414           
     
    411418            list.append($('<div/>', {
    412419                'class': 'related-post'
    413             }).append($('<a/>', {
    414                 'href':  '#',
    415                 'title': 'Remove Related Post',
    416                 'class': 'remove-post'
    417             }).text('Remove Related Post')).append(label).append(input));
     420            }).append(input).append(label));
    418421           
    419422            form.hide('blind', null, 'fast');
     
    488491    <div id="related-posts-<?php echo $slug; ?>" class="related-posts">
    489492        <?php if ( ! empty( $rel_posts ) ) : ?>
    490         <?php if ( 'many' == $rel->object_qty ) : foreach ( $rel_posts as $rel_post ) : ?>
     493        <?php if ( 'many' == $rel->object_qty ) : foreach ( $rel_posts as $rel_post ) :
     494            $input_id = "rel_posts-{$slug}-{$rel_post->ID}"; ?>
    491495        <div class="related-post">
    492             <a href="#" title="Remove Related Post" class="remove-post">Remove Related Post</a>
    493             <label><?php echo $rel_post->post_title; ?></label>
    494             <input type="hidden" name="rel_posts[<?php echo $slug; ?>][]" value="<?php echo $rel_post->ID; ?>">
     496            <input id="<?php esc_attr_e( $input_id ); ?>"
     497                type="checkbox" checked="checked"
     498                name="rel_posts[<?php echo $slug; ?>][]"
     499                value="<?php echo $rel_post->ID; ?>">
     500            <label for="<?php esc_attr_e( $input_id ); ?>">
     501                <?php echo $rel_post->post_title; ?>
     502            </label>
    495503        </div>
    496504        <?php endforeach; elseif ( 'one' == $rel->object_qty ) : ?>
  • kickpress/trunk/kickpress-workflows.php

    r498767 r587972  
    291291   
    292292    foreach ( $kickpress_post_types as $type ) {
    293         if ( 'false' == $type['api']->params['builtin'] ) {
     293        if ( kickpress_boolean( $type['api']->params['builtin'] ) ) {
    294294            $slug = $type['post_type'] . '-workflow';
    295295           
Note: See TracChangeset for help on using the changeset viewer.