[wp-trac] [WordPress Trac] #24202: Self-explanatory argument values for new media functions

WordPress Trac noreply at wordpress.org
Fri Apr 26 13:19:24 UTC 2013


#24202: Self-explanatory argument values for new media functions
--------------------------------------+--------------------
 Reporter:  SergeyBiryukov            |       Owner:
     Type:  enhancement               |      Status:  new
 Priority:  normal                    |   Milestone:  3.6
Component:  Media                     |     Version:  trunk
 Severity:  normal                    |  Resolution:
 Keywords:  dev-feedback 2nd-opinion  |
--------------------------------------+--------------------
Description changed by SergeyBiryukov:

Old description:

> We've introduced a bunch of functions, some with a relatively long list
> of arguments, which accept booleans:
> {{{
> function get_content_media( $type, &$content, $html = true, $remove =
> false, $limit = 0 )
> function get_content_audio( &$content, $html = true, $remove = false )
> function get_embedded_audio( &$content, $remove = false )
> function get_content_video( &$content, $html = true, $remove = false )
> function get_embedded_video( &$content, $remove = false )
> function get_content_images( &$content, $html = true, $remove = false,
> $limit = 0 )
> function get_content_image( &$content, $html = true, $remove = false )
> function get_content_galleries( &$content, $html = true, $remove = false,
> $limit = 0 )
> function get_post_galleries( $post_id = 0, $html = true )
> function get_post_gallery( $post_id = 0, $html = true )
> function get_content_chat( &$content, $remove = false )
> function get_content_quote( &$content, $remove = false, $replace = '' )
> function get_content_url( &$content, $remove = false )
> }}}
> I wonder if we can convert them to use arrays instead for future-proof
> changes, or at least switch from booleans to self-explanatory values, per
> our [http://make.wordpress.org/core/handbook/coding-standards/php/#self-
> explanatory-flag-values-for-function-arguments coding standards].
>
> Otherwise, we might fall into a trap of `submit_button()`: #20492.

New description:

 We've introduced a bunch of functions, some with a relatively long list of
 arguments, which accept booleans:
 {{{
 function get_content_media( $type, &$content, $html = true, $remove =
 false, $limit = 0 )
 function get_embedded_media( $type, &$content, $remove = false, $limit = 0
 )
 function get_content_audio( &$content, $html = true, $remove = false )
 function get_embedded_audio( &$content, $remove = false )
 function get_content_video( &$content, $html = true, $remove = false )
 function get_embedded_video( &$content, $remove = false )
 function get_content_images( &$content, $html = true, $remove = false,
 $limit = 0 )
 function get_content_image( &$content, $html = true, $remove = false )
 function get_content_galleries( &$content, $html = true, $remove = false,
 $limit = 0 )
 function get_post_galleries( $post_id = 0, $html = true )
 function get_post_gallery( $post_id = 0, $html = true )
 function get_content_chat( &$content, $remove = false )
 function get_content_quote( &$content, $remove = false, $replace = '' )
 function get_content_url( &$content, $remove = false )
 }}}
 I wonder if we can convert them to use arrays instead for future-proof
 changes, or at least switch from booleans to self-explanatory values, per
 our [http://make.wordpress.org/core/handbook/coding-standards/php/#self-
 explanatory-flag-values-for-function-arguments coding standards].

 Otherwise, we might fall into a trap of `submit_button()`: #20492.

--

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/24202#comment:2>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list