=== Collapsing Categories === Contributors: robfelty Donate link: http://robfelty.com/donate Plugin URI: http://robfelty.com/plugins Tags: categories, sidebar, widget, navigation Requires at least: 5.0 Tested up to: 6.3.1 Stable tag: 3.0.4 Adds a widget which uses Javascript to dynamically expand or collapse the set of posts for each category. == Description == Collapsing Categories creates an expandable list of categories and subcategories. It can also expand to show posts. The primary usage is as a widget, but you can also use the code in your theme manually if you wish (see installation instructions) == Installation == IMPORTANT! Please deactivate before upgrading, then re-activate the plugin. Unpackage contents to wp-content/plugins/ so that the files are in a collapsing-categories directory. = Widget installation = Activate the plugin, then simply go the Presentation > Widgets section and drag over the Collapsing Categories Widget. = Manual installation = Activate the plugin, then insert the following into your template: (probably in sidebar.php). See the Options section for more information on specifying options. ` \n"; if (function_exists('collapsCat')) { collapsCat(); } else { wp_get_categories('your_options_here'); } echo "\n"; ?> ` == Frequently Asked Questions == = How do I use different symbols for collapsing and expanding? = If you want to use images, you can upload your own images to http://yourblogaddress/wp-content/plugins/collapsing-categories/img/collapse.gif and expand.gif There is an option for this. = I have selected a category to expand by default, but it doesn't seem to work = If you select a sub-category to expand by default, but not the parent category, you will not see the sub-category expanded until you expand the parent category. You probably want to add both the parent and the sub-category into the expand by default list. = I can't get including or excluding to work = Make sure you specify category names, not ids. = There seems to be a newline between the collapsing/expanding symbol and the category name. How do I fix this? = If your theme has some css that says something like #sidebar li a {display:block} that is the problem. You probably want to add a float:left to the .sym class = No categories are showing up! What's wrong?" = Are you using categories or tags? By default, collapsing categories only lists categories. Please check the options in the settings page (or in the widget if you are using the widget) = How do I change the style of the collapsing categories lists? = As of version 2.0, there are several default styles that come with collapsing-categories. You can choose from these in the widget settings , or you can create your own custom style. A good strategy is to choose a default, then modify it slightly to your needs. The following classes are used: * collapsing-categories - applied to all ul and li elements * list - applied to the top-level ul * item - applied to each li which has no sub-elements * expand - applied to a category which can be expanded (is currently collapsed) * collapse - applied to a category which can be collapsed (is currently expanded) * sym - class for the expanding / collapsing symbol An example: ` \n"; ?> ``` == Demo == I use this plugin in my blog at http://robfelty.com == CAVEAT == Currently this plugin relies on Javascript to expand and collapse the links. If a user's browser doesn't support javascript they won't see the links to the posts, but the links to the categories will still work (which is the default behavior in wordpress anyways) == CHANGELOG == = 3.0.4 (2023.09.12) = * Fixed issue with including/excluding categories in the settings = 3.0.3 (2023.03.28) = * Added back in accordion option * Fixed COOKIES * added SameSite to cookies * Fixed sub-category post counts * Some other code cleanup = 3.0.2 (2023.03.27) = * Some fixes based on testing feedback = 3.0.1 (2023.03.25) = * More testing = 3.0.0 (2023.03.24) = * Converted to Gutenberg block to be usable by block themes * Got rid of dependency on jQuery (no more animations) * Compatible with PHP 7.4 and PHP 8.2 = 2.2.7 (2020.08.25) = * Some fixes for manual use (not as a widget) * Tested with WordPress 5.5 = 2.2.6 (2020.04.21) = * Fixed bug which would exclude categories without subcategories when not showing posts = 2.2.5 (2020.04.20) = * Fix possible unset index error * Updating jQuery to remove deprecated "live" function ( thanks Torsten Wirth for the suggested fix) = 2.2.4 (2020.04.10) = * Fix for when a category description has line breaks in it = 2.2.3 (2020.04.09) = * Tested on Wordpress 5.4 * Fixed an issue which caused some sites not to have javascript loaded properly * Fixed a number of PHP / WP_DEBUG warnings = 2.2.2 (2020.04.01) = * Fixed bug with non-numerical value https://wordpress.org/support/topic/warning-a-non-numeric-value-encountered-in-collapscatlist-php-on-line-267/ = 2.2.1 (2020.04.01) = * Fixed bug with possible undefined variable warning introduced in 2.2.0 = 2.2.0 (2020.03.29) = * Compatible with PHP 7.4 * Compatible with Wordpress 5.3 * Fixed bug where if $posts is not an array, it would generate a PHP warning * Unregistering filters based on https://wordpress.org/support/topic/breaks-taxonomies-tag-cloud-because-of-filters-not-unregistered/ * Stripping tags from title attributes https://wordpress.org/support/topic/strip-tags-from-title-attributes/ * Fix for custom taxonomies from https://wordpress.org/support/topic/currently-viewed-item-does-not-display-properly-with-custom-taxonomies/ * Added option to display categories asynchronoously using WP Rest API and AJAX = 2.1.3 (2019.05.02) = * Compatible with PHP 7.2 * Compatible with Wordpress 5.1 = 2.1.2 (2017.12.13) = * Fixed another bug with "active" class when displaying category archive = 2.1.1 (2017.12.12) = * Compatible with WP 4.9 * Fixed bug with "active" class when displaying category archive = 2.1 (2017.11.06) = * Compatible with WP 4.8.3 * Added "active" class to categories which correspond to category of current post = 2.0.9 (2017.08.18) = * Compatible with WP 4.8 * General code cleanup to avoid warnings = 2.0.8 (2016.08.23) = * Fixed bug with displaying html entities in titles (props to harnwerd for reporting the bug) = 2.0.7 (2015.11.01) = * Replaced deprecated API calls with newer ones = 2.0.6 (2015.08.12) = * Compatible with WP 4.3 = 2.0.5 (2014.09.05) = * Compatible with WP 4.0 = 2.0.4 (2013.08.02) = * fixed bug where a sub-category with newlines in the description would break expanding and collapsing = 2.0.3 (2012.06.20) = * fixed jquery loading for WP 3.4 = 2.0.2 (2011.11.01) = * removed link to spammy site = 2.0.1 (2011.08.08) = * fixed include category option = 2.0 (2011.07.29) = * Can now use custom taxonomies * Don't display any tags for title if title is empty * Easier style handling * Updated settings page * Fixed bug with extraneous li when not showing posts (thanks neoen for pointing it out) * Fixed bugs with styling in IE * Added option to show empty categories * Added accordion option * Added ability to sort posts by menu order = 1.2.2 (2010.08.05) = * fixed self class for category archive pages (error pointed out by ltache) = 1.2.1 (2010.07.25) = * Fixed bug where top-level categories did not show up if only had posts in sub-sub categories. * Fixed post counting errors = 1.2 (2010.06.18) = * Added option to automatically expand categories to which a post is assigned on single post pages * Storing posts in a javascript array and only adding to the DOM when requested (speeds page load) * fixed bug where empty subcategory with non-empty subsubcategory doesn't show up = 1.1.1 (2010.01.28) = * Added option to display posts before categories * Fixed bug with assigning self class to posts in sub-categories * Refactored code to reduce number of database reads when using multiple instances of the widget * Switched from scriptaculous to jquery. No longer conflicts with plugins which use mootools (e.g. featured content gallery) * Changed css class called "post" to "item" to avoid conflicts with other commonly used css classes = 1.1 (2010.01.03) = * Bug fixes * Fixed xhtml validation error (thanks Mathie) * Fixed incorrect link bug (thanks andydv) * Fixed some css issues * Manual version works even if no options are given * Fixed include option * Fixed self class problems * Fixed link to settings page from widget options (thanks wp.Man) * Fixed rss options (thanks wp.Man) * New options and features * Added option to hide top level category names * Changed css classes to make them more consistent with other collapsing plugins (thanks Bernhard Reiter) * Internationalization and localization * Added Russian localization * Added German localization (thanks Bernhard Reiter) = 1.0.2 (2009.07.19) = * Fixed older than option * Added advanced options section in configuration * Added advanced option to remember expanding and collapsing for each visitor (using cookies) * Now issuing a correct id for each ul when using widgets * Small change in manual installation * TODO: Added advanced option to expand category when viewing the category archive page * Permalinks which use author now work correctly = 1.0.1 (2009.06.22) = * Fixed some problems with cookies on page load = 1.0.beta (2009.06.08) = * Added option to show post date * Fixed some options that were broken in 1.0.alpha = 1.0.alpha (2009.05.01) = * Compatible with wordpress 2.8 widget api (incompatible with 2.7.1 and earlier) * Can now add options manually when using manually instead of widget * When using tags, link now points to correct location = 0.9.8 (2009.04.17) = * Fixed triangle problem = 0.9.7 (2009.04.16) = * fixed a few bugs introduced in 0.9.6 = 0.9.6 (2009.04.15) = * Added option to group posts into misc category * Switched role handling to proper API use (to control whether or not the settings page shows up) * Added option for custom symbols * No longer requires footer * Updated javascript file * Cleaned up code a bunch = 0.9.5 (2009.03.22) = * Fixed some more settings panel issues * Truncate post title now working for posts in sub-categories * Works even faster now for blogs with many posts * Fixed option to show only tags * Fixed previews for style settings * Categories which do not have any posts due to date exclusion no longer show up * Restored compatibility with my category order plugin * Better internationalization support = 0.9.4 (2009.03.09) = * Fixed issue with multiple instances = 0.9.3 (2009.03.08) = * Fixed links to sub-categories = 0.9.2 (2009.03.07) = * Tweaked default style * Fixed bug when not using permalinks = 0.9.1 (2009.03.02) = * Fixed bug where top level categories would not be displayed if they have no subcategories, and show only sub-categories is selected * Can leave sidebar ID option blank if desired = 0.9 (2009.03.01) = * Added option to exclude posts older than certain number of days * Widened widget options interface * Updated text of widget options some * Categories no longer get nested if for some reasons there are no posts showing up for a category * Added option to exclude post X in categories A and B when either A or B is excluded * Post count is now more accurate * Better internationalization for post and category titles * Added truncate post title option * Settings panel only available for admin * fixed settings panel problems * greatly increased speed for blogs with lots of posts and categories * added new style selection method * If current page is in category X, then category X will be expanded (thanks to Bernhard Reiter) = 0.8.5 (2009.01.23) = * fixed settings panel problems = 0.8.4 (2009.01.15) = * fixed sql queries, which seems to be working for most people now * Got rid of empty quotes in query when no in/exclude is used * Added option to list categories, tags, or both = 0.8.3 (2009.01.08) = * Refixed settings page for manual usage * Changed category query in the hopes that it works for more people = 0.8.2: (2009.01.07) = * Added nofollow option * Added version to javascript * not loading unnecessary code for admin pages (fixes interference with akismet stats page * fixed settings page for manual usage = 0.8.1 (2009/01/06) = * Finally fixed disappearing widget problem when trying to add to sidebar * Added debugging option to show the query used and the output * Moved style option to options page = 0.8 (2008/12/08) = * fixed javascript bug where thisli.parentNode was null * made javascript more flexible so that all collapsing X plugins can share more code * Now adds default options to database upon activation for use manually * styling now done through an option * inline javascript moved to footer for faster page loading = 0.7.1 (2008/12/01) = * fixed javascript bug in IE7 = 0.7 (2008/11/22) = * Cookie handling now affects categories that are expanded by default too * Can now be used either as a widget or manually * Got rid of the stupid float left from 0.6.6 = 0.6.6 (2008/11/21) = * Added a float left to .sym css to make it compatible with more themes = 0.6.5 (2008/11/18) = * Now uses cookies to keep categories expanded if they have been clicked on = 0.6.4 (2008/11/10) = * Fixed a minor bug in with animation option not being properly set by default = 0.6.3 (2008/10/03) = * Added option to animate expanding and collapsing * Added option to add rss feeds for each category = 0.6.2 (2008/09/11) = * Fixed display of expand and collapse symbols when using images * Improved font handling and styling of text symbols = 0.6.1 (2008/09/01) = * Improved styling so that collapsing and expanding symbols use a fixed-width font, but category names do not * When using the option to have category names trigger expansion, and not showing posts, categories with no subcategories now link to the category * Added option to use images instead of html for collapse/expand characters * +/- now uses UTF-8 encoding instead of html entities (may not work for pages not encoded in UTF-8 = 0.6 (2008/08/27) = * Can have multiple instances of widgets, each with separate options * No longer works as non-widget * All options are stored in one database row * Added more sorting options * Added option to include or exclude certain categories * Added option to expand certain categories by default * Added option to have category names either link to category archive or to activate expanding and collapsing = 0.5.10 (2008/08/20) = * minor bug fix. Fixed option to optionally show pages = 0.5.9 (2008/08/07) = * minor bug fix - added space before category count * Added option to sort by category (term) order * Added option to sort by category (term) count (note that it sorts by the count of the parent category, so categories with many subcategories, but not many posts themselves will be out of order * Added option to sort posts within categories = 0.5.8 (2008/06/15) = * bug fix - category description now correctly appears in title attribute if there is a description for a given category * implemented a few more changes to work towards internationalization = 0.5.7 (2008/05/23) = * fixed misnamed class in javascript (collapsArch -> collapsCat) * added font-family definition to css to make it monospace for +/- * added another option with brackets around the +/- = 0.5.6 (2008/05/23) = * fixed bug such that subcategories would not display the expand and collapse icons * fixed bug that categories with subcategories that have posts, but do not have posts themselves will be displayed * Thanks to [Andy] (http://www.onkelandy.com/blog) for both of these bug notices = 0.5.5 (2008/05/19) = * fixed bug - html now validates when not displaying posts * new option - choose between arrows or +- for expanding and collapsing * tweaked exclude option to function better with collapsing categories = 0.5.4 = * fixed bug - was using hard-coded wp_ prefix in one SQL query. Now using $wpdb-> instead = 0.5.3 = * count is now correct for all subcategories = 0.5.2 = * Added option to exclude certain categories * Added option to sort categories by slug = 0.5.1 = * options in widget seem to work now * removed duplicate entries due to tag + category = 0.5 = * Added option to not show posts * Added option to change title in widget * Now is condensed into one plugin = 0.4.4 = * using unicode number codes in css stylesheet * fixed bug with duplicate entries in subcategories = 0.4.3 = * nicer list indenting * re-fixed permalink bug introduced sometime after version 0.3.5 = 0.4.2 = * fixed bug with extraneous