Make WordPress Core

Opened 10 years ago

Closed 10 years ago

#26661 closed enhancement (fixed)

Add before/after hooks to override output of wp_widget_control()

Reported by: westonruter's profile westonruter Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 3.9 Priority: normal
Severity: normal Version:
Component: Widgets Keywords: has-patch docs-feedback
Focuses: Cc:

Description

As part of the widgets improvements being worked on for core, we need to override the default output of wp_widget_control(). One way to do this is to add a before/after actions around the output generated by the function:

  • src/wp-admin/includes/widgets.php

     
    188188        $widget_title = esc_html( strip_tags( $sidebar_args['widget_name'] ) );
    189189        $has_form = 'noform';
    190190
     191        do_action( 'temp_wp_widget_control_before', $sidebar_args );
    191192        echo $sidebar_args['before_widget']; ?>
    192193        <div class="widget-top">
    193194        <div class="widget-title-action">
     
    237238        </div>
    238239<?php
    239240        echo $sidebar_args['after_widget'];
     241        do_action( 'temp_wp_widget_control_after', $sidebar_args, $has_form !== 'noform' );
    240242        return $sidebar_args;
    241243}

Such hooks seem useful on a permanent basis as well, so perhaps the temp_ prefix can be dropped to begin with.

See related discussion on IRC (up until the end of the day): https://irclogs.wordpress.org/chanlog.php?channel=wordpress-ui&day=2013-12-16&sort=asc#m144514

Related to #25368

Attachments (4)

widgets.php.patch (692 bytes) - added by westonruter 10 years ago.
widgets.php.2.patch (669 bytes) - added by westonruter 10 years ago.
Pass $has_form variable into action as-is, and remove temp_ prefix
widgets.php.3.patch (1.7 KB) - added by westonruter 10 years ago.
Remove temp_ prefixes and add docs to new action hooks wp_widget_control_before and wp_widget_control_after
widgets.php.4.patch (2.4 KB) - added by westonruter 10 years ago.
Applying some more hook docs improvements gleaned from DrewAPicture in #25368

Download all attachments as: .zip

Change History (16)

#1 @westonruter
10 years ago

  • Keywords has-patch added

#2 @SergeyBiryukov
10 years ago

  • Milestone changed from Awaiting Review to 3.9

This ticket was mentioned in IRC in #wordpress-dev by westonruter. View the logs.


10 years ago

#4 @SergeyBiryukov
10 years ago

Can we just pass $has_form rather than $has_form !== 'noform' as the last argument to wp_widget_control_after?

@westonruter
10 years ago

Pass $has_form variable into action as-is, and remove temp_ prefix

#5 @SergeyBiryukov
10 years ago

In 26865:

Add temporary hooks for the widgets feature team to wp_widget_control().

props westonruter.
see #26661.

#6 @SergeyBiryukov
10 years ago

In 26866:

Add comments for temporary hooks. see #26661.

#7 @SergeyBiryukov
10 years ago

On second thought, 'noform' !== $has_form seems to make sense, so I decided to leave it as is.

We'd need to document the new hooks if they are going to stay.

@westonruter
10 years ago

Remove temp_ prefixes and add docs to new action hooks wp_widget_control_before and wp_widget_control_after

#8 @SergeyBiryukov
10 years ago

  • Keywords docs-feedback added

@westonruter
10 years ago

Applying some more hook docs improvements gleaned from DrewAPicture in #25368

#9 @westonruter
10 years ago

  • Resolution set to maybelater
  • Status changed from new to closed

It turns out that we actually didn't need this, since the widget icons are being supplied via CSS as dashicons instead of as inline image elements.

#10 follow-up: @SergeyBiryukov
10 years ago

  • Resolution maybelater deleted
  • Status changed from closed to reopened

Do we still need temporary hooks added in [26865]? If not, let's remove them.

#11 in reply to: ↑ 10 @westonruter
10 years ago

Replying to SergeyBiryukov:

Do we still need temporary hooks added in [26865]? If not, let's remove them.

They can be removed, yes, unless @shaunandrews objects.

#12 @SergeyBiryukov
10 years ago

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

In 27324:

Remove temporary hooks added in [26865].

fixes #26661.

Note: See TracTickets for help on using tickets.