| 11 | | '''Option 2.''' New way or the highway: Check if the third argument is a string, and if it is then call `_doing_it_wrong` but otherwise just drop the argument. |
| | 11 | {{{ |
| | 12 | /** |
| | 13 | * Retrieve a post's terms as a list with specified format. |
| | 14 | * |
| | 15 | * The following information has to do with additional arguments in the $args parameter: |
| | 16 | * |
| | 17 | * 'before' string Optional. Before list. |
| | 18 | * 'sep' string Optional. Separate items using this. |
| | 19 | * 'after' string Optional. After list. |
| | 20 | * |
| | 21 | * @since 2.5.0 |
| | 22 | * |
| | 23 | * @see wp_get_object_terms() for reference on the $args param |
| | 24 | * |
| | 25 | * @param int $id Post ID. |
| | 26 | * @param string $taxonomy Taxonomy name. |
| | 27 | * @param array $args Accepts the same arguments as the $args param for wp_get_object_terms, |
| | 28 | as well as some additions listed above. |
| | 29 | * @return string|bool|WP_Error A list of terms on success, false or WP_Error on failure. |
| | 30 | */ |
| | 31 | function get_the_term_list( $id, $taxonomy, $args = array(), $deprecated_1 = '', $deprecated_2 = '', $deprecated_3 = array() ) { |
| | 32 | if ( is_string( $args ) ) { |
| | 33 | _doing_it_wrong( __FUNCTION__, sprintf( __( 'get_the_term_list expects the third argument to be a $args array, you can specify $before, $sep, and $after in the array.' ), '4.0' ); |
| | 34 | $before = $args; |
| | 35 | $sep = $deprecated_1; |
| | 36 | $after = $deprecated_2; |
| | 37 | $args = $deprecated_3; |
| | 38 | } else { |
| | 39 | $before = isset( $args[ 'before' ] ) ? $args[ 'before' ] : ''; |
| | 40 | $sep = isset( $args[ 'sep' ] ) ? $args[ 'sep' ] : ''; |
| | 41 | $after = isset( $args[ 'after' ] ) ? $args[ 'after' ] : ''; |
| | 42 | } |
| | 43 | }}} |
| | 44 | |
| | 45 | '''Option 2.''' New way or the highway: Check if the third argument is a string, and if it is then call `_doing_it_wrong` but otherwise just drop the argument. Something like: |
| | 46 | |
| | 47 | {{{ |
| | 48 | /** |
| | 49 | * Display the terms in a list. |
| | 50 | * |
| | 51 | * The following information has to do with additional arguments in the $args parameter: |
| | 52 | * |
| | 53 | * 'before' string Optional. Before list. |
| | 54 | * 'sep' string Optional. Separate items using this. |
| | 55 | * 'after' string Optional. After list. |
| | 56 | * |
| | 57 | * @since 2.5.0 |
| | 58 | * |
| | 59 | * @param int $id Post ID. |
| | 60 | * @param string $taxonomy Taxonomy name. |
| | 61 | * @param array $args Accepts the same arguments as the $args param for wp_get_object_terms, |
| | 62 | as well as some additions listed above. |
| | 63 | * @return null|bool False on WordPress error. Returns null when displaying. |
| | 64 | */ |
| | 65 | function the_terms( $id, $taxonomy, $args = array() ) { |
| | 66 | if ( is_string( $args ) ) { |
| | 67 | _doing_it_wrong( __FUNCTION__, sprintf( __( 'the_terms expects the third argument to be a $args array, you can specify $before, $sep, and $after in the array.' ), '4.0' ); |
| | 68 | } |
| | 69 | }}} |
| | 70 | |
| | 71 | Having coded them out in outline, I vote for not making the change or going for Option 2, to keep the code simpler. |