Making WordPress.org

Opened 7 weeks ago

Closed 2 weeks ago

Last modified 2 weeks ago

#7981 closed defect (bug) (fixed)

Fix category ID selector in WordPress.tv editor

Reported by: nilovelez's profile nilovelez Owned by: dd32's profile dd32
Milestone: Priority: normal
Component: WordPress.tv Keywords: has-patch
Cc:

Description

In one of the last versions of WordPress, the code for each checkbox in the categories meta tag of the classic editor has changed from:

<input value="107686937" type="checkbox" name="post_category[]" id="in-category-107686937">

to:

<input value="107686937" type="checkbox" name="post_category[]" id="in-category-107686937-2">

That "-2" breaks the selector of the javascript used in the WPTV editor to apply categories.

The change has tobe made in line 523 of https://meta.svn.wordpress.org/sites/trunk/wordpress.tv/public_html/wp-content/themes/wptv2/plugins/wordpresstv-anon-upload/anon-upload.php

I include the required patch, with base in
https://meta.svn.wordpress.org/sites/trunk/wordpress.tv/public_html/wp-content/themes/wptv2/

Attachments (2)

anon-upload.php.patch (665 bytes) - added by nilovelez 7 weeks ago.
Patch file to add the "-2" sufix
22-05-2025-05-56-48.png (9.1 KB) - added by nilovelez 7 weeks ago.
Broken category links in the editor

Download all attachments as: .zip

Change History (8)

@nilovelez
7 weeks ago

Patch file to add the "-2" sufix

@nilovelez
7 weeks ago

Broken category links in the editor

#1 @dd32
7 weeks ago

Why has the -2 appeared here? Do you have any link to the changeset / etc that's caused it? Just to avoid changing this only for it to reappear sometime.

#2 @nilovelez
7 weeks ago

I can't find the changeset, but the HTML of the elements in the categories metabox is now like this:

<li id="in-category-2757063-1">
    <label class="selectit">
        <input value="2757063" type="checkbox" name="post_category[]" id="in-category-2757063-2" checked="checked"> 2025
    </label>
</li>

The <li> tag has now a -1 and the checkbox a -2 to prevent duplicate ids

The javascript from the editor uses that id to query the element, grab the title and check it when clicked.

There's a hundred better ways of doing this, but for now it's just a hotfix until we have a new version.

This ticket was mentioned in Slack in #wptv by nilovelez. View the logs.


3 weeks ago

#4 @dd32
2 weeks ago

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

In 14472:

WordPress.TV: Fix the category selector.

Props nilovelez.
Fixes #7981.

#5 @dd32
2 weeks ago

Source of the change in IDs https://core.trac.wordpress.org/changeset/58894

Sync'd to WordPress.com and deployed there too now.

Sorry for the delay @nilovelez

#6 @nilovelez
2 weeks ago

Tested and working, thank you!

Note: See TracTickets for help on using tickets.