Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions inc/other-widget/widget-taxonomies.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static function veu_widget_description() {

function widget( $args, $instance ) {
$instance = static::get_defaults( $instance );

if ( ! isset( $instance['tax_name'] ) ) {
$instance['tax_name'] = 'category';
}
Expand All @@ -32,9 +32,11 @@ function widget( $args, $instance ) {
if ( ! isset( $instance['form_design'] ) ) {
$instance['form_design'] = 'list';
}
if ( ! isset( $instance['form_sort'] ) ) {
$instance['form_sort'] = 'asc';
}



?>
<?php echo $args['before_widget']; ?>
<div class="sideWidget widget_taxonomies widget_nav_menu">
Expand All @@ -53,6 +55,8 @@ function widget( $args, $instance ) {
'hierarchical' => true,
'title_li' => '',
'taxonomy' => $instance['tax_name'],
'orderby' => 'title',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MasayaMORIMOTO @drill-lancer

RICKさんご指摘の通り、
https://rishuntrading.co.jp/blog/php/sort_post_type_data/
の記事は投稿の並び替えの解説で、
今回はカテゴリーを取得する wp_list_categories() で、
wp_list_categories() の場合は タイトル順は name, slug 順は slug を使う感じなので、name の方が無難かなと。
https://developer.wordpress.org/reference/classes/wp_term_query/get_terms/

Suggested change
'orderby' => 'title',
'orderby' => 'name',

'order' => $instance['form_sort']
);
$tax_args = apply_filters( 'veu_widget_taxlist_args', $tax_args ); // 9.13.0.0

Expand All @@ -76,6 +80,8 @@ function widget( $args, $instance ) {
'taxonomy' => $instance['tax_name'],
'name' => $name,
'value_field' => 'slug',
'orderby' => 'title',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'orderby' => 'title',
'orderby' => 'name',

'order' => $instance['form_sort']
);
$tax_args = apply_filters( 'veu_widget_taxlist_args', $tax_args ); //

Expand Down Expand Up @@ -106,7 +112,7 @@ public static function get_defaults( $instance = array() ) {
function form( $instance ) {
$instance = static::get_defaults( $instance );
$taxs = get_taxonomies( array( 'public' => true ), 'objects' );
?>
?>

<!-- タイトル -->
<div style="margin-top:15px;">
Expand Down Expand Up @@ -140,7 +146,15 @@ function form( $instance ) {
<input style="margin-top:3px" type="checkbox" id="<?php echo $this->get_field_id( 'hide_empty' ); ?>" name="<?php echo $this->get_field_name( 'hide_empty' ); ?>" value="true"<?php if ( $instance['hide_empty'] ) { echo ' checked';} ?>
/>
<label for="<?php echo $this->get_field_id( 'hide_empty' ); ?>"><?php _e( 'Do not display terms without posts', 'vk-all-in-one-expansion-unit' ); ?></label>
</p>

<!-- [ Form sort ] -->
<div>
<label for="<?php echo $this->get_field_id( 'form_sort' ); ?>">Display order:</label>
<select name="<?php echo $this->get_field_name( 'form_sort' ); ?>" class="admin-custom-input">
<option value="asc" <?php selected( $instance['form_sort'], 'asc' ); ?>>ascending order</option>
<option value="desc" <?php selected( $instance['form_sort'], 'desc' ); ?>>descending order</option>
</select>
</div>

<script type="text/javascript">
jQuery(document).ready(function($){
Expand Down Expand Up @@ -178,6 +192,7 @@ function update( $new_instance, $old_instance ) {

$instance['form_design'] = $new_instance['form_design'];

$instance['form_sort'] = $new_instance['form_sort'];
return $instance;
}
}
Expand All @@ -190,4 +205,4 @@ function( $options ) {
},
10,
1
);
);
6 changes: 4 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ e.g.

== Changelog ==

[ Add setting ][ Category list ] Enable to specify ascending/descending order

= 9.99.6 =
[ Bug fix ][ Child Page List ] Fixed an issue related to a PHP error.

Expand All @@ -102,7 +104,7 @@ e.g.

= 9.99.0 =
[ Specification Change ][ Page top button ] Add #top on body for pagetop btn
[ Specification Change ][ Taxonomy Widget ] Add dropdown mode.
[ Specification Change ][ Taxonomy Widget ] Add dropdown mode.
[ Specification Change ] Foce Load JS from footer is abolished.
[ Fix ] Add a title attribute on Google Tag Manager (noscript)
[ Bug fix ] Fix XSS of Widgets, CTA, Custom Post Type Manager.
Expand Down Expand Up @@ -130,7 +132,7 @@ e.g.
[ Add setting ][ Post Type Manager ] Add a custom field setting.
[ Specification Change ][ Post Type Manager ] Change so that "with_front" can be specified as false in permalink settings
[ Bug Fix ][ SNS ] Fix OGP description on password protected page.
[ Bug Fix ][ Contact Section ] Fixed an issue where icons do not display when input in <i> tag format.
[ Bug Fix ][ Contact Section ] Fixed an issue where icons do not display when input in <i> tag format.
[ Design Bug Fix ][ Child Page List ] Fixed an issue where a blank space appeared above the excerpt.

= 9.95.0 =
Expand Down
Loading