[wp-hackers] fallback for empty values [general thought about filter call position]

Otto otto at ottodestruct.com
Tue Sep 16 13:37:00 GMT 2008


Agreed, the return should skip down to the filter and pass in false to it.

Corrected function:
function get_tags_to_edit( $post_id ) {
	$post_id = (int) $post_id;
	if ( !$post_id )
		return false;

	$tags = wp_get_post_tags($post_id);

	if ( $tags ) {
		foreach ( $tags as $tag )
			$tag_names[] = $tag->name;
		$tags_to_edit = join( ',', $tag_names );
		$tags_to_edit = attribute_escape( $tags_to_edit );
	} else {
		$tags_to_edit = false;
	}
	$tags_to_edit = apply_filters( 'tags_to_edit', $tags_to_edit );
	return $tags_to_edit;
}


On Mon, Sep 15, 2008 at 11:14 PM, Malaiac <malaiac at gmail.com> wrote:
> exemple :
> function get_tags_to_edit() // in wp-admin/includes/taxonomy.php
> {
> $tags = wp_get_post_tags($post_id);
> if ( !$tags ) return false;
> <tags cleaning>
> $tags_to_edit = apply_filters('tags_to_edit',$tags_to_edit);
> return $tags_to_edit;
> }
>
> What if the $tags are empty ? The function return false, with no way
> to act on that.
> Why couldn't it be
> if ( !$tags ) return apply_filters('tags_to_edit',false);
> ?
>
> Malaiac
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list