[wp-hackers] Wordpress plugin system

Denis de Bernardy denis at semiologic.com
Mon May 30 22:47:28 GMT 2005


Well, in my case, it was more on the lines of apply smart links this way
when the post is the 'main' post, and that way when it is not. I predict
disasters in the long term for relying on wp globals to do this.

Likewise, feedwordpress changes the url of all of the permalinks of my
recent posts plugins when I enable the 'posts point to their original
source' option.

In any event, the point remains. To take the example of my recent comments
plugin, I would feel much more comfortable with:

$comment = apply_filters('comment_meta', $comment);

Than with:

if ( $comment->comment_author != '' )
	$comment_author = apply_filters('get_comment_author',
$comment->comment_author);
else
	$comment_author = apply_filters('get_comment_author',
$anonymous_name);
$comment_author = apply_filters('comment_author', $comment_author);
$comment_author_email = apply_filters('get_comment_author_email',
$comment->comment_author_email);
$comment_author_email = apply_filters('comment_author',
$comment_author_email);
$comment_author_url = apply_filters('get_comment_author_url',
$comment->comment_author_url);
$comment_author_url = apply_filters('comment_url', $comment_author_url);
$comment_date = mysql2date($date_format, $comment->comment_date);
$comment_date = apply_filters('get_comment_date', $comment_date);
$comment_date_normalized = mysql2date('Y-m-d H:i:s',
$comment->comment_date);
if ( $comment->comment_type == '' )
	$comment->comment_type = 'comment';
$comment_type = apply_filters('get_comment_type', $comment->comment_type);
$comment_excerpt = apply_filters('get_comment_excerpt',
$comment->comment_content);
$comment_excerpt = apply_filters('comment_excerpt', $comment_excerpt);
$comment_excerpt = strip_tags($comment_excerpt);
$comment_excerpt = preg_replace( "/\s+\S{". ($max_word_length+1)
.",}(\s|\S)+/", "...", $comment_excerpt);
$comment_excerpt = preg_replace ( "/^\s*(\S+(\s+\S+){". ($excerpt_length-1)
."})(...)?\s*(\S|\s)*/", "$1...", $comment_excerpt);

D.

> -----Original Message-----
> From: wp-hackers-bounces at lists.automattic.com 
> [mailto:wp-hackers-bounces at lists.automattic.com] On Behalf Of 
> Jeff Minard
> Sent: Monday, May 30, 2005 9:54 PM
> To: wp-hackers at lists.automattic.com
> Subject: Re: [wp-hackers] Wordpress plugin system
> 
> 
> Denis de Bernardy wrote:
> >>There are already seperate filters for the_title,
> >>the_excerpt, the_content and so on. What exactly are you asking?
> > 
> > 
> > Well, I can filter the_title, straight and simple. But if I want to 
> > filter the_title this way when post meta blah blah is this, 
> and that 
> > way when it's that, but not when that other post meta is so...
> 
> Wait a sec. You want to change formatting of "the_title" when 
> the post 
> has a meta key of X value, and do it differently when it has 
> a post meta 
> key of Y value? That should be possible...
> 
> function title_meta_filter($r) {
> 	global $id;
> 	if( get_post_meta($id, 'meta_keyX', true) ) {
> 		//filter for X
> 	} else if( get_post_meta($id, 'meta_keyY', true) ) {
> 		// filter for Y
> 	}
> 
> 	return $r;
> }
> 
> Something like that should do the trick in that case.
> 
> Or are you seeking something else?
> 
> Jeff
> _______________________________________________
> 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