[wp-trac] [WordPress Trac] #34058: Proposal: wp_get_archives_object() function

WordPress Trac noreply at wordpress.org
Tue Sep 29 19:36:59 UTC 2015


#34058: Proposal: wp_get_archives_object() function
------------------------------------------+-----------------------------
 Reporter:  davetgreen                    |       Owner:
     Type:  feature request               |      Status:  new
 Priority:  normal                        |   Milestone:  Future Release
Component:  General                       |     Version:  4.3.1
 Severity:  normal                        |  Resolution:
 Keywords:  needs-patch needs-unit-tests  |     Focuses:  template
------------------------------------------+-----------------------------
Changes (by boonebgorges):

 * keywords:   => needs-patch needs-unit-tests
 * focuses:   => template
 * milestone:  Awaiting Review => Future Release


Comment:

 Hi davetgreen - Thanks for the ticket!

 I agree 100% that there should be a separation of concerns here -
 `wp_get_archives()` has been a bugbear for me in the past, too. Whether
 it's a separate function or an 'echo' parameter for the existing function
 doesn't matter much to me.

 Assuming you had a separate function - which, as pathartl notes, would
 have to be the one returning structured data, since we can't change the
 default behavior of `wp_get_archives()` - what exactly would it be
 returning? You say "the archives object", but I'm not sure what that
 means. Maybe it'd be a structured array of links? Something like:

 {{{
 array(
     [2015] => array(
         [09] => 'http://example.com/2015/09/',
         [11] => 'http://example.com/2015/11/',
     ),
     [2014] => array(
         // etc
     ),
 )
 }}}

 Or do you have in mind an actual object, which would presumably have
 methods like `get_years()` and `get_month( $year )`, etc? (This is a neat
 idea, but not very WordPress-y.)

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


More information about the wp-trac mailing list