Plugin Directory

Changeset 3022975


Ignore:
Timestamp:
01/17/2024 02:24:52 PM (2 years ago)
Author:
india-web-developer
Message:

released new version 2.4

Location:
wp-categories-widget
Files:
9 added
2 edited

Legend:

Unmodified
Added
Removed
  • wp-categories-widget/trunk/readme.txt

    r2955245 r3022975  
    44Tags: Category Widget, Posts Widget, Taxonomy Widget, Custom Widget, product categories widget
    55Requires at least: 5.6
    6 Tested up to: 6.3
    7 Stable tag: 2.3
     6Tested up to: 6.4.2
     7Stable tag: 2.4
    88Requires PHP: 7.3
    99License: GPLv2 or later
     
    9797== Changelog ==
    9898
     99= 2.4 =
     100 * Tested with wordpress version 6.4.2
     101 * Added dropdown display option
     102 
    99103= 2.1 =
    100104 * Tested with wordpress version 5.8
  • wp-categories-widget/trunk/wp-categories-widget.php

    r2955343 r3022975  
    77Author URI: https://wp-experts.in
    88Plugin URI: https://www.wp-experts.in/products/wp-categories-widget-addon/
    9 Version: 2.3
     9Version: 2.4
    1010*/
    1111
    12 /*  Copyright 2018-23  wp-categories-widget  (email : [email protected])
     12/*  Copyright 2018-24  wp-categories-widget  (email : [email protected])
    1313
    1414    This program is free software; you can redistribute it and/or modify
     
    134134            $title = '<h2 class="widget-title">' . __( $instance['wcw_title'], 'wp-experts.in' ) . '</h2>';
    135135        }
     136       
     137        $widgetstyle    = !empty($instance['wcw_style']) ? $instance['wcw_style'] : 'list';
     138
    136139        // add css     
    137140        //do_action('wcw_style','wcw_style_func');
     
    159162                if($excludeCat && $wcw_action_on_cat!='')
    160163                $queryargs[$wcw_action_on_cat] = $excludeCat;
    161                 //print_r($queryargs);         
     164                //print_r($queryargs);     
     165               
     166                if( $widgetstyle=='list' ) {
    162167                $categories = wp_list_categories($queryargs);
    163168                $cat_html = preg_replace( '~\((\d+)\)(?=\s*+<)~', '<span class="post-count">$1</span>', $categories );
     
    166171                    printf( '<ul class="%s">%s</ul>', $args['widget_id'],$cat_html );
    167172                 }
     173                }else{
     174                   
     175                    $parent_terms = get_terms($queryargs);
     176if ( $parent_terms ) {
     177   echo $title;
     178   
     179    echo '<select class="wcwpro-list" id="'.$args['widget_id'].'" onchange="this.options[this.selectedIndex].value && (window.location = this.options[this.selectedIndex].value);">';
     180   
     181    if( $parent_terms ) {
     182       
     183        foreach ( $parent_terms as $pterm ) {
     184            $queryargs['parent'] = $pterm->term_id;
     185            $terms = get_terms($queryargs);
     186            echo '<option class="cat-item '.($terms && !$depth ? ' cat-have-child ': '').$parentcatclass.'" id="cat-item-'.$pterm->term_id.'" value="'.get_term_link( $pterm ).'" '.selected($currentterm,$pterm->term_id) .'>'. $pterm->name.'</option>';
     187                       
     188            //Get the Child terms
     189            if($terms && !$depth) {
     190                foreach ( $terms as $term ) {
     191                        echo '<option class="child-cat-item" id="term-'.$term->term_id.'" value="' . get_term_link( $term ) . '" '.selected($currentterm,$pterm->term_id) .'>' . $term->name.'</option>';
     192                       
     193                    }
     194                }
     195            }
     196
     197    }
     198            echo '</select>';
     199
     200}
     201                }
    168202           
    169203            }   
     
    189223        $wcw_action_on_cat          = ! empty( $instance['wcw_action_on_cat'] ) ? $instance['wcw_action_on_cat'] : esc_html__( '', 'wp-experts.in' );
    190224        $wcw_hide_count             = ! empty( $instance['wcw_hide_count'] ) ? $instance['wcw_hide_count'] : esc_html__( '', 'wp-experts.in' );
     225        $wcw_style                  = ! empty( $instance['wcw_style'] ) ? $instance['wcw_style'] : esc_html__( '', 'wp-experts.in' );
     226
    191227        ?>
    192228        <p>
     
    278314          </div>
    279315        </div>
     316       
     317        <p><label for="<?php echo esc_attr( $this->get_field_id( 'wcw_style' ) ); ?>"><?php _e( esc_attr( 'Category Style' ) ); ?>&nbsp;&nbsp;</label> <br>
     318        <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'wcw_style' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'wcw_style' ) ); ?>" type="radio" value="list" <?php checked( $wcw_style, 'list' ); ?>> List &nbsp;
     319        <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'wcw_style' ) ); ?>-1" name="<?php echo esc_attr( $this->get_field_name( 'wcw_style' ) ); ?>" type="radio" value="dropdown" <?php checked( $wcw_style, 'dropdown' ); ?>> Drop Down
     320        </p>
    280321        <p>
    281322        <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'wcw_hide_count' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'wcw_hide_count' ) ); ?>" type="checkbox" value="1" <?php checked( $wcw_hide_count, 1 ); ?>>
     
    353394        $instance['wcw_action_on_cat']          = ( ! empty( $new_instance['wcw_action_on_cat'] ) ) ? $new_instance['wcw_action_on_cat'] : '';
    354395        $instance['wcw_hide_count']             = ( ! empty( $new_instance['wcw_hide_count'] ) ) ? strip_tags( $new_instance['wcw_hide_count'] ) : '';
     396        $instance['wcw_style']                  = ( ! empty( $new_instance['wcw_style'] ) ) ? strip_tags( $new_instance['wcw_style'] ) : '';
    355397        return $instance;
    356398    }
Note: See TracChangeset for help on using the changeset viewer.