Make WordPress Core

Opened 13 months ago

Last modified 3 months ago

#45984 reviewing enhancement

Twenty Nineteen: Improve code organisation in template-functions.php

Reported by: allancole Owned by: SergeyBiryukov
Milestone: 5.4 Priority: normal
Severity: normal Version:
Component: Bundled Theme Keywords: good-first-issue has-patch
Focuses: Cc:
PR Number:


Originally reported by @grapplerulrich in the Twenty Nineteen GitHub repo:

The header in the template-functions.php file is described as:

Functions which enhance the theme by hooking into WordPress

According to that description, all of the functions within template-functions.php should hook into either a filter or an action of WordPress.

This is not the case for the following functions:

  • twentynineteen_can_show_post_thumbnail()
  • twentynineteen_image_filters_enabled()
  • twentynineteen_post_thumbnail_sizes_attr()
  • twentynineteen_get_avatar_size()
  • twentynineteen_is_comment_by_post_author()
  • twentynineteen_get_discussion_data()
  • twentynineteen_hsl_hex()

These are helper functions that would fit best in another file like inc/helper-functions.php.

Also, twentynineteen_add_dropdown_icons() could be moved to icon-functions.php to join twentynineteen_nav_menu_social_icons().

Original ticket here: https://github.com/WordPress/twentynineteen/issues/548

Attachments (1)

45984.diff (11.7 KB) - added by akshayar 3 months ago.

Download all attachments as: .zip

Change History (3)

3 months ago

#1 @akshayar
3 months ago

  • Keywords has-patch added; needs-patch removed

I have moved the common functions in inc/helper-functions.php.

Also, twentynineteen_add_dropdown_icons() is moved to icon-functions.php (containing the required code).

#2 @SergeyBiryukov
3 months ago

  • Milestone changed from Awaiting Review to 5.4
  • Owner set to SergeyBiryukov
  • Status changed from new to reviewing
Note: See TracTickets for help on using tickets.