WordPress.org

Make WordPress Core

Opened 8 years ago

Closed 7 years ago

#5567 closed enhancement (fixed)

Search widget doesn't use searchform.php

Reported by: Pixelstyle Owned by: ionfish
Milestone: 2.6 Priority: normal
Severity: normal Version: 2.3.2
Component: Template Keywords: search widget has-patch tested
Focuses: Cc:

Description

The search widget doesn't use rthe standard searchform.php

I've found two tickets about the search widget, but none of them suggests the most logical solution to the probnlem, namely to make the widget use searchform.php.

It might be that this is a conscious choice because not all themes have a searchform.php. But then it would be logical to make it an option on the search widget option button (use searchform.php: tickbox).

Attachments (4)

search-widget.diff (941 bytes) - added by DerFichtl 8 years ago.
searchwidget.diff (972 bytes) - added by ionfish 8 years ago.
Same as above but diffed from WP root for convenience.
searchwidget-2.diff (907 bytes) - added by ionfish 7 years ago.
searchwidget-3.diff (1.1 KB) - added by ionfish 7 years ago.

Download all attachments as: .zip

Change History (22)

comment:1 @ionfish8 years ago

  • Keywords needs-patch added

+1

The default theme has a searchform.php which the widget should default to if the current theme has no searchform.php file.

comment:2 @lloydbudd8 years ago

  • Milestone changed from 2.4 to 2.5

No patch, milestone defaults to current+1.

comment:3 @DerFichtl8 years ago

  • Owner changed from anonymous to DerFichtl

@DerFichtl8 years ago

comment:4 @DerFichtl8 years ago

  • Keywords has-patch needs-testing added

comment:5 @ffemtcj8 years ago

  • Keywords needs-patch removed

comment:6 @ionfish8 years ago

  • Keywords tested added; needs-testing removed
  • Milestone changed from 2.6 to 2.5

Works fine for me, both with a theme's searchform.php and with the default one when the theme has no searchform.php file.

@ionfish8 years ago

Same as above but diffed from WP root for convenience.

@ionfish7 years ago

comment:7 @ionfish7 years ago

  • Owner changed from DerFichtl to ionfish

Attached an improved patch which doesn't reveal the origin of the search form publicly and has more WordPressy syntax.

comment:8 @Otto427 years ago

+1 to this, however it would be nice if the default search box had an id of "searchsubmit" on the submit button.

<input type="submit" id="searchsubmit" value="<?php echo attribute_escape(__('Search')); ?>" />

This is in line with the existing searchform.php file in the default theme, and makes styling of the submit button possible.

comment:9 @ionfish7 years ago

Sorry Otto, I'm not sure I follow. The patch makes the search widget use either the theme's searchform.php or the default theme's searchform.php if the theme doesn't have one. If the default theme's searchform.php has an id of "searchsubmit" then search widgets will get that simply in virtue of them using the same source file.

comment:10 @ionfish7 years ago

  • Status changed from new to assigned

Any more comments or a chance of getting this in for 2.5?

comment:11 @ionfish7 years ago

  • Milestone changed from 2.5 to 2.6

Bumping to 2.6.

comment:12 @Otto427 years ago

  • Milestone changed from 2.6 to 2.5.2

Any chance of this getting into 2.5.2 already?

comment:13 @JohnLamansky7 years ago

+1 for getting this into 2.5.2

comment:14 follow-up: @ryan7 years ago

It's not uncommon for people to delete the default theme. If the current theme doesn't supply a search form, let's just emit one and forgo looking at the default theme.

comment:15 in reply to: ↑ 14 @Otto427 years ago

Replying to ryan:

It's not uncommon for people to delete the default theme. If the current theme doesn't supply a search form, let's just emit one and forgo looking at the default theme.

There's several places in the core code where it looks at the default theme for stuff like this. I refer you to get_header, get_footer, get_sidebar...

We often say on the support forums that deleting the default theme is not recommended because of that fact.

And quite frankly, I think that it *is* uncommon for people to delete the default theme.

So I'm going to go with leaving it to look for one in the default theme directory, because of all those reasons.

comment:16 @ryan7 years ago

With the advent of WP_CONTENT_DIR, it will become more common. I don't have the default theme in my WP_CONTENT_DIR.

get_header() and friends have the advantage that a theme almost never calls them if it doesn't also supply the corresponding files. The same cannot be said for a widget.

comment:17 @ionfish7 years ago

  • Milestone changed from 2.5.2 to 2.6

Updated patch reflecting Ryan's point attached.

@ionfish7 years ago

comment:18 @ryan7 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

(In [8250]) Use searchform.php for search widget, if available. Props ionfish. fixes #5567

Note: See TracTickets for help on using tickets.