Git Product home page Git Product logo

display-categories-widget's Introduction

Display-Categories-Widget

Wordpress plugin to display categories on sidebar with more customization options from the backend https://wordpress.org/plugins/display-categories-widget/

Display Categories Widget will display Child categories on your sidebar. Can be placed on widget in sidebar.

Features:

  1. Limit number of categories that appears.
  2. Exclude categories from display.
  3. Restrict levels of categories that can be shown.
  4. Display categories as list or dropdown.
  5. Hide categories that does not have any posts.
  6. Display/Hide number of posts available in categories.

display-categories-widget's People

Contributors

andrea-calligaris avatar frozzare avatar iteamweb avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

display-categories-widget's Issues

Still displays title HTML tag even if title is actually empty

In line 213, variable $title is defined like so :

$title = empty($instance['title']) ? ' ' : apply_filters('widget_title', $instance['title']);

So $title is never actually empty (there's at least one space).

And then, in line 228, it checks $title and therefore always displays a heading tag :

if (!empty($title)) echo $before_title . $title . $after_title;

I believe you should leave $title as an empty string if none is provided.

Feature request: add links to title

Great plugin, so useful for me.

I currently use it to list post categories in 4 columns, using 4 separate widgets.
It displays the title of the parent category, followed by the list of sub categories (1 level only), and that's exactly what I needed.

There's just one more thing I need : could we have the possibility to have a link on the parent category? Right now I don't think this is possible, it justs displays the title within a H2 tag.

Thanks

Removing Deprecated Constructor Method

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; DisplayCategoriesWidget has a deprecated constructor in /vagrant/web/wp-content/plugins/display-categories-widget/display_categories_widget.php on line 12

suggestion: age limit for posts

Maybe a simple and nice feature to add is the possibility of setting an age limit for the displayed posts. For example, this would allow to display a "hot news" category that would indeed contain only brand new information.

However, as a php/wordpress newbee, I am not the most efficient person for this task. If anybody has the strength to solve this quickly, I would be very grateful.

Issue With "??" in Line 214 (Solved)

Just replace the code from line 214 until 226:

$cat_id = $instance['category'] ?? 0;
$dcw_limit = $instance['dcw_limit'] ?? 'Categories';
$dcw_option_name = $instance['dcw_option_name'] ?? '';
$dcw_exclude = $instance['dcw_exclude'] ?? '';
$dcw_depth = $instance['dcw_depth'] ?? 0;
$display_empty_categories = $instance['display_empty_categories'] ?? 0;
$showcount_value = $instance['showcount_value'] ?? 0;
$use_desc_for_title = $instance['use_desc_for_title'] ?? 0;
$sort_order_by = $instance['sort_order_by'] ?? 'name';
$sort_order_as = $instance['sort_order_as'] ?? 'ASC';
$show_format = $instance['show_format'] ?? 0;
$dcw_column = $instance['dcw_column'] ?? 1;
$dcw_display_parent = $instance['display_parent'] ?? 0;

Replace to this:

$cat_id = $instance['category'] ? $instance['category'] : 0;
$dcw_limit = $instance['dcw_limit'] ? $instance['dcw_limit'] : 'Categories';
$dcw_option_name = $instance['dcw_option_name'] ? $instance['dcw_option_name'] : '';
$dcw_exclude = $instance['dcw_exclude'] ? $instance['dcw_exclude'] : '';
$dcw_depth = $instance['dcw_depth'] ? $instance['dcw_depth'] : 0;
$display_empty_categories = $instance['display_empty_categories'] ? $instance['display_empty_categories'] : 0;
$showcount_value = $instance['showcount_value'] ? $instance['showcount_value'] : 0;
$use_desc_for_title = $instance['use_desc_for_title'] ? $instance['use_desc_for_title'] : 0;
$sort_order_by = $instance['sort_order_by'] ? $instance['sort_order_by'] : 'name';
$sort_order_as = $instance['sort_order_as'] ? $instance['sort_order_as'] : 'ASC';
$show_format = $instance['show_format'] ? $instance['show_format'] : 0;
$dcw_column = $instance['dcw_column'] ? $instance['dcw_column'] : 1;
$dcw_display_parent = $instance['display_parent'] ? $instance['display_parent'] : 0;

Issue with Style in Line 238 (Solved)

For this issue the float style makes the categories layout overflow, so I just remove the style because it's not necessary at all:

echo "<style>.dcw_c1 {float:left; width:100%} .dcw_c2 {float:left; width:50%} .dcw_c3 {float:left; width:33%}</style>";
echo "<ul class='dcw'>";
wp_list_categories('orderby='.$sort_order_by.'&order='.$sort_order_as.'&use_desc_for_title='.$use_desc_for_title.'&show_count=' . $showcount_value . '&child_of=' . $cat_id . '&hide_empty=' . $display_empty_categories . '&title_li=&number=' . $dcw_limit . '&exclude=' . $dcw_exclude . '&depth=' . $dcw_depth);
echo "</ul>";
$class_definer = "dcw_c" . $dcw_column;
echo "<script>jQuery('ul.dcw').find('li').addClass('$class_definer');</script>";    

Replace to:

// echo "<style>.dcw_c1 {float:left; width:100%} .dcw_c2 {float:left; width:50%} .dcw_c3 {float:left; width:33%}</style>";
echo "<ul class='dcw'>";
wp_list_categories('orderby='.$sort_order_by.'&order='.$sort_order_as.'&use_desc_for_title='.$use_desc_for_title.'&show_count=' . $showcount_value . '&child_of=' . $cat_id . '&hide_empty=' . $display_empty_categories . '&title_li=&number=' . $dcw_limit . '&exclude=' . $dcw_exclude . '&depth=' . $dcw_depth);
echo "</ul>";
// $class_definer = "dcw_c" . $dcw_column;
// echo "<script>jQuery('ul.dcw').find('li').addClass('$class_definer');</script>";

I just comment the code that not functional for me.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.