WordPress.org

Make WordPress Core

Opened 5 weeks ago

#45984 new enhancement

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

Reported by: allancole Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Bundled Theme Keywords: needs-patch good-first-issue
Focuses: Cc:

Description

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

Change History (0)

Note: See TracTickets for help on using tickets.