WordPress.org

Make WordPress Core

Opened 21 months ago

Closed 3 weeks ago

#44408 closed enhancement (fixed)

Add classes to .post-attributes-label-wrapper paragraphs to make them unique

Reported by: garrett-eclipse Owned by: garrett-eclipse
Milestone: 5.4 Priority: normal
Severity: normal Version: 4.9.6
Component: Editor Keywords: has-patch commit
Focuses: css Cc:

Description

Hello,

Currently the Post Attributes meta box markup for the individual post attributes doesn't allow for easy targetting for either css or js.

<div class="inside">
<p class="post-attributes-label-wrapper"><label class="post-attributes-label" for="parent_id">Parent</label></p>
<select name="parent_id" id="parent_id"></select>
<p class="post-attributes-label-wrapper"><label class="post-attributes-label" for="page_template">Template</label></p>
<select name="page_template" id="page_template"></select>
<p class="post-attributes-label-wrapper"><label class="post-attributes-label" for="menu_order">Order</label></p>
<input name="menu_order" type="text" size="4" id="menu_order" value="0">
<p>Need help? Use the Help tab above the screen title.</p>
</div>

Could each attribute either be wrapped in a div with ID or class on it. Otherwise can an ID or unique class be added to the post-attributes-label-wrapper paragraphs in order to target them.

Personally I prefer an entire div wrapping to allow better targetting the attribute as a whole to hide or style it or update it.

Thank you

Attachments (5)

44408.patch (2.2 KB) - added by sathyapulse 3 months ago.
44408.patch
44408.1.patch (2.2 KB) - added by sathyapulse 3 months ago.
44408.1.patch
44408.2.patch (2.5 KB) - added by sathyapulse 3 months ago.
44408.2.patch
44408.3.patch (2.2 KB) - added by sathyapulse 3 months ago.
44408.3.patch
44408.4.patch (2.2 KB) - added by sathyapulse 3 months ago.
44408.4.patch

Download all attachments as: .zip

Change History (15)

This ticket was mentioned in Slack in #core by noisysocks. View the logs.


3 months ago

#2 @noisysocks
3 months ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to Future Release

Makes sense! I think this would be a good simple enhancement.

@sathyapulse
3 months ago

44408.patch

#3 @sathyapulse
3 months ago

@noisysocks As we discussed in the APAC meeting, I have attached the patch to the ticket. I have additionally added class to "Help text" as well.

CC: @garrett-eclipse

#4 @noisysocks
3 months ago

  • Keywords has-patch added; needs-patch removed

@sathyapulse
3 months ago

44408.1.patch

@sathyapulse
3 months ago

44408.2.patch

@sathyapulse
3 months ago

44408.3.patch

#5 @sathyapulse
3 months ago

@garrett-eclipse I have generated the patch outside of src directory. Please use the latest 44408.3.patch file.

#6 @sabernhardt
3 months ago

To avoid any chance of duplicating an ID used in a plugin or theme, I would recommend using classes instead (unless these paragraph tags do need an ID attribute, for example, if a link might direct to them).

<p class="post-attributes-label-wrapper parent-id-label-wrapper">

@sathyapulse
3 months ago

44408.4.patch

#7 @sabernhardt
3 months ago

Thanks @sathyapulse! I tested 44408.3.patch and 44408.4.patch, and both patches applied the classes and/or IDs as I expected. (Though I prefer # 4, I figured I ought to check both ways.)

#8 @sabernhardt
3 weeks ago

  • Keywords 2nd-opinion added

@garrett-eclipse Do you see any benefit to using an ID instead of a class for these? I checked wpdirectory.net and did not find any of these class/ID names in any of those plugins or themes. (There's still a slight possibility one is used in a paid or custom plugin/theme.)

#9 @garrett-eclipse
3 weeks ago

  • Focuses css added
  • Keywords commit added; 2nd-opinion removed
  • Milestone changed from Future Release to 5.4
  • Owner set to garrett-eclipse
  • Status changed from new to accepted

Thanks for testing @sabernhardt and the patches @sathyapulse let's move forward with classes (Patch 44408.4.patch as there's no real benefit with IDs and there's the slight possibility of duplicated IDs so classes in this case are safer. Marking for commit.

#10 @SergeyBiryukov
3 weeks ago

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

In 47228:

Editor: Add unique classes to .post-attributes-label-wrapper paragraphs for easier JS or CSS targeting.

Props sathyapulse, sabernhardt, garrett-eclipse, noisysocks.
Fixes #44408.

Note: See TracTickets for help on using tickets.