Plugin Directory

Changeset 3071992


Ignore:
Timestamp:
04/16/2024 11:01:59 PM (2 years ago)
Author:
celloexpressions
Message:

List Custom Taxonomy Widget: Version 4.2, see readme.

Location:
list-custom-taxonomy-widget
Files:
3 added
2 edited

Legend:

Unmodified
Added
Removed
  • list-custom-taxonomy-widget/trunk/list-custom-taxonomy-widget.php

    r1603696 r3071992  
    44 * Plugin URI: http://celloexpressions.com/plugins/list-custom-taxonomy-widget
    55 * Description: Widget that displays category listings for custom post types (custom taxonomies).
    6  * Version: 4.1
     6 * Version: 4.2
    77 * Author: Nick Halsey
    88 * Author URI: http://celloexpressions.com/
     
    1212 
    1313=====================================================================================
    14 Copyright (C) 2017 Nick Halsey
     14Copyright (C) 2024 Nick Halsey
    1515
    1616This program is free software; you can redistribute it and/or
     
    6060            $this_taxonomy = '';
    6161        }
    62         $hierarchical = !empty( $instance['hierarchical'] ) ? '1' : '0';
     62        $hierarchical = !empty( $instance['hierarchical'] ) ? 1 : 0;
    6363        $inv_empty = !empty( $instance['empty'] ) ? '0' : '1'; // invert to go from UI's "show empty" to WP's "hide empty"
    6464        $showcount = !empty( $instance['count'] ) ? '1' : '0';
     
    9999        }
    100100        // Output
    101         $tax = $this_taxonomy;
     101        $tax = esc_html( $this_taxonomy );
    102102        echo $before_widget;
    103103        echo '<div id="lct-widget-'.$tax.'-container" class="list-custom-taxonomy-widget">';
    104         if ( $title ) echo $before_title . $title . $after_title;
     104        if ( $title ) echo $before_title . esc_html( $title ) . $after_title;
    105105        if($dropdown){
    106106            $taxonomy_object = get_taxonomy( $tax );
     
    130130                'walker'            => $walker,
    131131            );
    132             echo '<form action="'. get_bloginfo('url'). '" method="get">';
    133             wp_dropdown_categories($args);
     132            echo '<form action="'. esc_attr( get_bloginfo('url') ) . '" method="get">';
     133            wp_dropdown_categories( $args );
    134134            $dropdown_submit_text = apply_filters( 'list_custom_taxonomy_widget_dropdown_submit_text', __( 'go &raquo;', 'list-custom-taxonomy-widget' ) );
    135135            echo '<input type="submit" value"' . esc_attr( $dropdown_submit_text ) . '" /></form>';
     
    163163                );
    164164            echo '<ul id="lct-widget-'.$tax.'">';
    165             wp_list_categories($args);
     165            wp_list_categories( $args );
    166166            echo '</ul>';
    167167        }
     
    173173        $instance = $old_instance;
    174174       
    175         $instance['title']  = strip_tags( $new_instance['title'] );
    176         $instance['taxonomy'] = strip_tags( $new_instance['taxonomy'] );
    177         $instance['orderby'] = $new_instance['orderby'];
    178         $instance['ascdsc'] = $new_instance['ascdsc'];
    179         $instance['exclude'] = $new_instance['exclude'];
    180         $instance['expandoptions'] = $new_instance['expandoptions'];
    181         $instance['childof'] = $new_instance['childof'];
     175        $instance['title']  = sanitize_text_field( $new_instance['title'] );
     176        $instance['taxonomy'] = sanitize_text_field( $new_instance['taxonomy'] );
     177        $instance['orderby'] = sanitize_text_field( $new_instance['orderby'] );
     178        $instance['ascdsc'] = sanitize_text_field( $new_instance['ascdsc'] );
     179        $instance['exclude'] = sanitize_text_field( $new_instance['exclude'] );
     180        $instance['expandoptions'] = sanitize_text_field( $new_instance['expandoptions'] );
     181        $instance['childof'] = sanitize_text_field( $new_instance['childof'] );
    182182        $instance['hierarchical'] = !empty($new_instance['hierarchical']) ? 1 : 0;
    183183        $instance['empty'] = !empty($new_instance['empty']) ? 1 : 0;
     
    192192    **/
    193193    function form( $instance ) {
    194         //for showing/hiding advanced options; wordpress moves this script to where it needs to go
    195             wp_enqueue_script('jquery');
    196             ?><script>
    197             jQuery(document).ready(function(){
    198                 var status = jQuery('#<?php echo $this->get_field_id('expandoptions'); ?>').val();
    199                 if ( status === 'expand' ) {
    200                     jQuery('.lctw-expand-options').hide();
    201                     jQuery('.lctw-all-options').show();
    202                 } else {
    203                     jQuery('.lctw-all-options').hide();
    204                 }
    205             });
    206             function lctwExpand(id){
    207                 jQuery('#' + id).val('expand');
    208                 jQuery('.lctw-all-options').show(500);
    209                 jQuery('.lctw-expand-options').hide(500);
    210             }
    211             function lctwContract(id){
    212                 jQuery('#' + id).val('contract');
    213                 jQuery('.lctw-all-options').hide(500);
    214                 jQuery('.lctw-expand-options').show(500);
    215             }
    216             </script><?php
    217194          // instance exist? if not set defaults
    218195            if ( $instance ) {
     
    242219                $dropdown = false;
    243220            }
     221        //for showing/hiding advanced options; wordpress moves this script to where it needs to go
     222            wp_enqueue_script('jquery');
     223            ?><script>
     224            jQuery(document).ready(function(){
     225                var status = jQuery('#<?php echo esc_js( $expandoptions ); ?>').val();
     226                if ( status === 'expand' ) {
     227                    jQuery('.lctw-expand-options').hide();
     228                    jQuery('.lctw-all-options').show();
     229                } else {
     230                    jQuery('.lctw-all-options').hide();
     231                }
     232            });
     233            function lctwExpand(id){
     234                jQuery('#' + id).val('expand');
     235                jQuery('.lctw-all-options').show(500);
     236                jQuery('.lctw-expand-options').hide(500);
     237            }
     238            function lctwContract(id){
     239                jQuery('#' + id).val('contract');
     240                jQuery('.lctw-all-options').hide(500);
     241                jQuery('.lctw-expand-options').show(500);
     242            }
     243            </script><?php
    244244           
    245245        // The widget form ?>
    246246            <p>
    247247                <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e( 'Title:', 'list-custom-taxonomy-widget' ); ?></label>
    248                 <input id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" class="widefat" />
     248                <input id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" class="widefat" />
    249249            </p>
    250250            <p>
     
    267267            </select>
    268268            </p>
    269             <h4 class="lctw-expand-options"><a href="javascript:void(0)" onclick="lctwExpand('<?php echo $this->get_field_id('expandoptions'); ?>')" ><?php _e( 'More Options&hellip;', 'list-custom-taxonomy-widget' ); ?></a></h4>
    270             <div class="lctw-all-options">
     269            <h4 class="lctw-expand-options" <?php if ( 'contract' !== $expandoptions ) { echo 'style="display:none"'; } ?>><a href="javascript:void(0)" onclick="lctwExpand('<?php echo $this->get_field_id('expandoptions'); ?>')" ><?php _e( 'More Options&hellip;', 'list-custom-taxonomy-widget' ); ?></a></h4>
     270            <div class="lctw-all-options" <?php if ( 'contract' === $expandoptions ) { echo 'style="display:none"'; } ?>>
    271271                <h4 class="lctw-contract-options"><a href="javascript:void(0)" onclick="lctwContract('<?php echo $this->get_field_id('expandoptions'); ?>')" ><?php _e( 'Hide Extended Options', 'list-custom-taxonomy-widget' ); ?></a></h4>
    272272                <input type="hidden" value="<?php echo $expandoptions; ?>" id="<?php echo $this->get_field_id('expandoptions'); ?>" name="<?php echo $this->get_field_name('expandoptions'); ?>" />
     
    295295                <p>
    296296                    <label for="<?php echo $this->get_field_id('exclude'); ?>">Exclude (comma-separated list of ids to exclude)</label><br/>
    297                     <input type="text" class="widefat" name="<?php echo $this->get_field_name('exclude'); ?>" value="<?php echo $exclude; ?>" />
     297                    <input type="text" class="widefat" name="<?php echo $this->get_field_name('exclude'); ?>" value="<?php echo esc_attr( $exclude ); ?>" />
    298298                </p>
    299299                <p>
    300300                    <label for="<?php echo $this->get_field_id('exclude'); ?>">Only Show Children of (category id)</label><br/>
    301                     <input type="text" class="widefat" name="<?php echo $this->get_field_name('childof'); ?>" value="<?php echo $childof; ?>" />
     301                    <input type="text" class="widefat" name="<?php echo $this->get_field_name('childof'); ?>" value="<?php echo esc_attr( $childof ); ?>" />
    302302                </p>
    303303                <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('dropdown'); ?>" name="<?php echo $this->get_field_name('dropdown'); ?>"<?php checked( $dropdown ); ?> />
  • list-custom-taxonomy-widget/trunk/readme.txt

    r2968084 r3071992  
    33Tags: custom taxonomy, custom tax, widget, sidebar, category, categories, taxonomy, custom category, custom categories, post types, custom post types, custom post type categories
    44Requires at least: 3.3
    5 Tested up to: 6.3
    6 Stable tag: 4.1
     5Tested up to: 6.5
     6Stable tag: 4.2
    77Description: Widget that list terms in a custom taxonomy (often used as categories or category types for a custom post type).
    88License: GPLv2
     
    2929
    3030== Changelog ==
     31= 4.2 =
     32* Fix default extended options display.
     33* Add additional escaping and sanitization.
     34
    3135= 4.1 =
    3236* Add support for selective refresh in the customizer, available in WordPress 4.5.
Note: See TracChangeset for help on using the changeset viewer.