WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 5 years ago

#7000 closed enhancement (duplicate)

On Write Post screen, Checked Categories should be on top of the list

Reported by: mdawaffe Owned by:
Milestone: Priority: high
Severity: normal Version: 2.5.1
Component: Administration Keywords: needs-patch
Focuses: Cc:

Description

In WP 2.3, a post's current categories were listed at the top of the categories list for easy identification.

Since the move to the Walker class, that is no longer true.

Attached

  1. Uses the Walker twice to put checked categories first.
  2. Does not change the DB queries. It post-processes the old ones. We could only query for categories that are/aren't checked for that post, but the post-processing method means that the query is the same for all posts. Good for query/object caching.
  3. Passes $popular_categories to wp_category_checklist() to save a query, reduce inconsistencies.
  4. Tweaks JS/AJAX.

2.5.2?

Attachments (4)

7000.diff (5.9 KB) - added by mdawaffe 6 years ago.
7000.002.diff (608 bytes) - added by AaronCampbell 6 years ago.
Adds filter for $args
selected-cat-hierarchy.1.diff (1.6 KB) - added by sivel 5 years ago.
7000.003.diff (1.5 KB) - added by aaroncampbell 5 years ago.

Download all attachments as: .zip

Change History (27)

mdawaffe6 years ago

comment:1 ryan6 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [7956]) Put checked categories at the top of the checlist. Props mdawaffe. fixes #7000 for trunk

comment:2 AaronCampbell6 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

This is an extremely annoying UI issue. Along with putting things out of order (and thus making them harder to find), it causes checked sub categories to look like main categories! I'd prefer to see it reverted (ASAP), but can we at least add in a hook that will let us adjust "$args" to empty $argsselected_cats??

Maybe something like: $args = apply_filter('wp_category_checklist', $args); somewhere around line 214?

Again, I'd rather see it reverted, but I'm attaching a patch anyway.

AaronCampbell6 years ago

Adds filter for $args

comment:3 AaronCampbell6 years ago

  • Keywords needs-patch added; has-patch needs-testing removed

Ok, I chatted with Matt in IRC for a bit, and he's not a fan of the falter as a solution to this problem (although he said the filter could be useful, it needs to be in ADDITION to a fix for this). The main problem seems to be that if you select a sub category, you lose the context of the hierarchy (checked categories have no hierarchy). There are a couple cases where this can get REALLY confusing. Say (among others)you have a these categories:

Dogs->Shows
Cats->Shows

And you check Dogs->Shows. When you edit that post, you no longer get the context, and "Shows" is ambiguous. The same can happen if you have:

WordPress
Plugins->WordPress

matt said:

it seems like rather than not having the checked ones at the top, a better solution might be showing some of the hierarchy inline with checked-at-top categories

comment:4 mdawaffe6 years ago

I'm pretty sure that's how it used to work.

comment:5 Viper007Bond6 years ago

Yeah, this drives me nuts too (the children showing up as parents), but I can somewhat understand why it was done.

Still doesn't mean I'm in favor if it though. ;)

comment:6 DD326 years ago

What i'd like to see is:

C Prefixes: PHP
C WordPress Plugin
U Blah
U Prefixes
U   Opinion
U   Other Prefix

C = Checked, U = Unchecked, If its not visible, 'PHP' is a subcat of the 'Prefixes' category..

comment:7 AaronCampbell6 years ago

As an alternative, you could do something like:

U Prefixes
C   PHP
C WordPress Plugin
U Blah
U Prefixes
U   Opinion
U   Other Prefix

The advantage is that it keeps some consistency as far as children are indented and under their parent. The disadvantage is that it leaves you with "Prefixes" on the list twice.

I'm still wondering what milestone this should be. To me, it was a bug introduced in 2.6 (I'd love to see it make it into the 2.6 branch, 2.7 isn't due out for 3 months). Unfortunately, 2.7 may be more realistic.

comment:8 AaronCampbell6 years ago

  • Milestone changed from 2.6 to 2.6.2

Fixing the milestone to something current.

comment:10 mrmist5 years ago

See also #6920 duplication of category names which is still an issue in the 2.7 beta1.

comment:11 ryan5 years ago

  • Milestone changed from 2.7 to 2.9

This won't make 2.7. Postponing.

comment:12 codestyling5 years ago

  • Milestone changed from 2.9 to 2.8
  • Priority changed from normal to high

Because my new report has been closed as duplicate http://trac.wordpress.org/ticket/8521 and pointed to this one, i will try to explain my issue here again.
The category box displays 2 kinds of views:

  • tree view of all categories
  • linear view of mostly used

In my opinion, if a tree view will be used to show parent/child relationships, this tree have to be always consistent. That's why it is counterproductive to rupture this by isolating assigned post categories and leave unassigned linear at the end of tree.

A practical example would be tree based categories, where the main nodes stand for languages like english, german, italian etc. and the childs are the real language dependend categories. Handling this by current behavoir, this extracts some language dependend childs and put them out of order at the end of tree. This also prevents injected admin javascripts to hide some main trees node (and their child implicitely) not nessessary for current posts language, because the extracted loose childs at the end remains while not longer linked to parent.
My suggestion would be to extend the box with 3 possible visual kinds:

  1. tree view of all (keeps always correct order)
  2. linear list of all (sorts assigned cats at start)
  3. linear list of mostly used (sorts assigned cats at start)

The box has to remember, what user prefere so you will provide for all user needs the way of correct displayment.

comment:13 ryan5 years ago

  • Type changed from defect (bug) to UI adjustment

comment:14 ryan5 years ago

  • Type changed from UI adjustment to enhancement

comment:15 sivel5 years ago

Just figured I would try to revive this a little. One problem with doing something like:

U Prefixes
C   PHP
C WordPress Plugin
U Blah
U Prefixes
U   Opinion
U   Other Prefix

Is you have to take into account that if a user clicks the top 'Prefixes' box that the bottom one needs checked also.

I'm thinking something like the following would be better:

U Prefixes
C   PHP
U   Opinion
U   Other Prefix
C WordPress Plugin
U Blah

comment:16 sivel5 years ago

  • Cc matt@… added
  • Keywords has-patch dev-feedback added; needs-patch removed

Just put together a quick patch that will lay out the items as DD32 had mentioned:

C Prefixes: PHP
C WordPress Plugin
U Blah
U Prefixes
U   Opinion
U   Other Prefix

There may be a quicker/easier way to do what is in this patch, but like I said it was a quick attempt.

comment:17 follow-up: aaroncampbell5 years ago

How deep can the category structure go? Do we need to take into account:

Great Grandparent: Grandparent: Parent: Category

comment:18 in reply to: ↑ 17 sivel5 years ago

Replying to aaroncampbell:

How deep can the category structure go? Do we need to take into account:

Great Grandparent: Grandparent: Parent: Category

Ah...good catch. My test was only done with Parent->child. I imagine this could get ugly.

The categories page only shows at most Grand Parent->Parent->Child

The list on the edit/write posts page on shows hierarchy for Parent->Child or Grand Parent->Parent

So currently the listing doesn't on the edit/write posts page, while it displays more than the categories page will only shows a 2 level hierarchy. I would say that unless we want to change the display on the categories page that maybe 3 levels is the most we should handle.

comment:19 aaroncampbell5 years ago

I'm going to work on this one for the 24hour marathon. I'm thinking that creating a get_root_category() function to use would be a relatively simple solution.

aaroncampbell5 years ago

comment:20 aaroncampbell5 years ago

The new patch is based off the one one by sivel, and properly displays all the ancestors using get_category_parents(). There is however, another problem. If you have a category structure like this:

Prefixes
  Other
  PHP
    test
  Something
Uncategorized

Now, if you check test it works great like this:

C Prefixes:PHP:test
U Prefixes
U   Other
U   PHP
U   Something
U Uncategorized

However, if you check only PHP you get this:

C Prefixes:PHP
U Prefixes
U   Other
U   Something
U Uncategorized
U test

Notice that the test category has been orphaned at the bottom. What do you think should be done in this case?

comment:21 Denis-de-Bernardy5 years ago

  • Keywords needs-patch added; has-patch dev-feedback removed

maybe the full list should be included with some options being selected twice? it won't hurt much if they are, if they're sync'd using js.

maybe this could also be done using js: on load, we move the ones that are checked to the top. on check they move to the top, on uncheck they revert to their original position.

comment:23 Denis-de-Bernardy5 years ago

  • Milestone 2.8 deleted
  • Resolution set to duplicate
  • Status changed from reopened to closed

#3130 has a nice suggestion as an improvement btw. So closing this one.

Note: See TracTickets for help on using tickets.