views:

87

answers:

1

I want to be able to understand the standard function description that is provided for Wordpress functions. In particular, could someone explain the following example from here:

Usage

<?php wp_list_categories( $args ); ?> 

Default Usage

<?php $args = array(
    'show_option_all'    => ,
    'orderby'            => 'name',
    'order'              => 'ASC',
    'show_last_update'   => 0,
    'style'              => 'list',
    'show_count'         => 0,
    'hide_empty'         => 1,
    'use_desc_for_title' => 1,
    'child_of'           => 0,
    'feed'               => ,
    'feed_type'          => ,
    'feed_image'         => ,
    'exclude'            => ,
    'exclude_tree'       => ,
    'include'            => ,
    'current_category'   => 0,
    'hierarchical'       => true,
    'title_li'           => __( 'Categories' ),
    'number'             => NULL,
    'echo'               => 1,
    'depth'              => 0 ); ?>

I can guess most of it, but in particular I can't guess:

  • What does blank after the comma mean? Empty string?
  • What is the __?
  • How do I call the function? Keyword like python, positional arguments or do I have to pass an array?
  • Is there anything else about Wordpress function descriptions which isn't covered in this example?

Thanks,

Chris

+2  A: 
  • that trailing comma would be a parse error - in that documentation, I believe it is just showing an option value with no default.
  • the __() function is a language localization function, which takes an English language literal string, and returns the a translated string for an application-defined locale.
  • the function is called by passing in an array as a parameter, defined as detailed. In fact, internally this uses wp_parse_args which allows you to pass an array, an object, or a urlencoded style string of options.
  • please note this is just an idiom rather than the way all PHP functions are called. In this case, most likely the designer of the function wanted a wide range of optional arguments, coupled with the ability to add new arguments without breaking older code.
Paul Dixon
Casebash
Looking at the wordpress source code, it can take an array with the given keys, an object with the given member variables, or a urlencoded style string.
Paul Dixon