Make WordPress Core

Opened 2 years ago

Closed 18 months ago

#26604 closed enhancement (fixed)

remove dead code (and unused options?) from dashboard.php after 3.8

Reported by: kitchin Owned by: SergeyBiryukov
Milestone: 4.0 Priority: normal
Severity: normal Version: 3.8
Component: Administration Keywords: has-patch commit
Focuses: Cc:


The option 'dashboard_widget_options' is unused by core now. Would be nice to delete its unused core keys: 'dashboard_recent_comments', 'dashboard_incoming_links', 'dashboard_primary', 'dashboard_secondary'. Why? Because it's super annoying to do a MySQL search when migrating a site and find your old url in the options table. :)

The option 'dashboard_widget_options' is still needed for plugins that put RSS feeds on the Dashboard though, see below.

Here's a quick survey of the functions in wp-admin/includes/dashboard.php. Maybe there's more dead or deprecatable code I missed:

function wp_dashboard_setup:

  • These lines are dead code:
    21	        $update = false;
    22	        $widget_options = get_option( 'dashboard_widget_options' );
    23	        if ( !$widget_options || !is_array($widget_options) )
    24	                $widget_options = array();
    86	        if ( $update )
    87	                update_option( 'dashboard_widget_options', $widget_options );

function wp_add_dashboard_widget:
function _wp_dashboard_control_callback:
function wp_dashboard:
function wp_dashboard_right_now:
function wp_network_dashboard_right_now:
function wp_dashboard_quick_press:
function wp_dashboard_recent_drafts:
function _wp_dashboard_recent_comments_row:
function wp_dashboard_site_activity:
function wp_dashboard_recent_posts:
function wp_dashboard_recent_comments:
function wp_dashboard_rss_output:

  • Unused in core. Plugins may use it to display RSS feeds.

function wp_dashboard_cached_rss_widget:
function wp_dashboard_trigger_widget_control:

  • Maybe unused in core? Plugins need it to work for a widgets with a form for 'number'. The core widgets all post to post.php. Nothing has a 'widget_id' $_POST field.

function wp_dashboard_rss_control:

  • Unused in core. Plugins may use it to mod display of RSS feeds. Does update_option('dashboard_widget_options',) for two fields: 'number' from $_POST, and 'title' from fetch_feed().
  • Note this is the only place in core that can update 'dashboard_widget_options'.

function wp_dashboard_primary:
function wp_dashboard_primary_output:
function wp_dashboard_plugins_output:
function wp_dashboard_quota:
function wp_dashboard_browser_nag:
function dashboard_browser_nag_class:
function wp_check_browser_version:
function wp_dashboard_empty:

  • A no-op function {}. Unused in core. It's so js/ajax plugins have a string compatible with call_user_func() ?

function wp_welcome_panel:

I can make a patch for the dead code removal. Not sure about the option key deprecation, maybe it's been done before?

These dashboard_incoming_links bugs can be closed now, so I'll comment on them: #21225, #20379.

Attachments (1)

dashboard.php.patch (882 bytes) - added by kitchin 2 years ago.
Remove dead code.

Download all attachments as: .zip

Change History (5)

#1 @kitchin
2 years ago


function wp_dashboard_trigger_widget_control:

  • Unused by core widgets. Plugins need it to work for mod-able dashboard widgets. The core widgets all post to post.php. Nothing has a 'widget_id' $_POST field.

2 years ago

Remove dead code.

#2 @kitchin
19 months ago

To clarify, the patch removes truly dead code.

The list of unused functions and options is a separate issue for consideration, whether they should be deprecated.

#3 @SergeyBiryukov
18 months ago

  • Keywords has-patch commit added
  • Milestone changed from Awaiting Review to 4.0

Missed in [26144].

#4 @SergeyBiryukov
18 months ago

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

In 28592:

Remove obsolete code from wp_dashboard_setup().

props kitchin.
fixes #26604.

Note: See TracTickets for help on using tickets.