[wp-trac] [WordPress Trac] #28687: Removing background image and/or reverting background color to default doesn't remove custom-background body class and remove theme mods

WordPress Trac noreply at wordpress.org
Mon Feb 19 14:23:14 UTC 2024


#28687: Removing background image and/or reverting background color to default
doesn't remove custom-background body class and remove theme mods
---------------------------+----------------------
 Reporter:  slobodanmanic  |       Owner:  ocean90
     Type:  defect (bug)   |      Status:  closed
 Priority:  normal         |   Milestone:  4.2
Component:  Themes         |     Version:  3.9
 Severity:  normal         |  Resolution:  fixed
 Keywords:  has-patch      |     Focuses:
---------------------------+----------------------

Comment (by jnvrllms):

 The issue you're describing with the WordPress theme mods not being
 properly removed when reverting the background color or removing the
 background image is indeed a significant concern. It appears to be a bug
 in the system where the custom-background body class is still being added
 even after the background settings have been reverted to default or
 removed entirely.

 This behavior can be problematic for several reasons:

 CSS Conflicts: The presence of the custom-background body class may lead
 to conflicts with CSS stylesheets, especially if the background settings
 have been reverted or removed. This could result in unexpected layout or
 design issues on the website.

 Performance Impact: Unnecessary theme mods can increase the size of the
 database and potentially impact website performance. It's important to
 remove any unused or redundant data to maintain optimal performance.

 Inconsistency: The presence of residual theme mods can lead to
 inconsistencies in the website's appearance and behavior, particularly if
 the user expects the background settings to be fully reverted to default.

 To address this issue, a patch should be developed to ensure that when the
 background color or image is reverted to default or removed, the
 corresponding theme mods are also properly removed from the database. This
 would involve updating the relevant functions or hooks responsible for
 handling background settings to include logic for removing associated
 theme mods.

 Additionally, thorough testing should be conducted to ensure that the
 patch resolves the issue without introducing any regressions or unexpected
 side effects. This may involve testing various scenarios, such as setting
 custom background colors and images, reverting them to default, removing
 them entirely, and verifying that the custom-background body class is
 added or removed accordingly, and that the theme mods are updated
 accordingly.

 Once the patch has been developed and tested, it can be submitted as a
 contribution to the WordPress project, either through the official Trac
 system or via a pull request on GitHub if the theme in question is hosted
 there. This will allow the patch to be reviewed by the WordPress community
 and potentially included in a future release, ensuring that the issue is
 addressed for all users of the affected theme.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/28687#comment:24>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list