spiff06
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: how to disable notifications for contributorsCan look at this hook, should do the trick. You can also prune the $reply_to variable inclusion at the bottom to prevent viewing the commenter’s email address entirely.
Also, if you’re using multiple themes and are allowing visitors to select their theme, make sure to include the function in all themes available.
Forum: Fixing WordPress
In reply to: Comment Notification LOOK/DESIGN / FORMATSorry for resurrecting a two-month-old thread, but a user just cringed at the fact that there was too much information posted on notifications, and requested some things, such as IP address, should be taken out.
The culprit is function wp_notify_postauthor(), in /wp-includes/pluggable.php. But it’s also enclosed in a hook to check whether the function’s been defined before, so it can be overridden in functions.php, like all other pluggable functions.
I pasted the following in my theme’s functions.php file:
if ( ! function_exists('wp_notify_postauthor') ) : /** * Notify an author of a comment/trackback/pingback to one of their posts. * * @since 1.0.0 * * @param int $comment_id Comment ID * @param string $comment_type Optional. The comment type either 'comment' (default), 'trackback', or 'pingback' * @return bool False if user email does not exist. True on completion. */ function wp_notify_postauthor($comment_id, $comment_type='') { $comment = get_comment($comment_id); $post = get_post($comment->comment_post_ID); $user = get_userdata( $post->post_author ); if ('' == $user->user_email) return false; // If there's no email to send the comment to $comment_author_domain = @gethostbyaddr($comment->comment_author_IP); $blogname = get_option('blogname'); if ( empty( $comment_type ) ) $comment_type = 'comment'; if ('comment' == $comment_type) { $notify_message = sprintf( __('New comment on your post #%1$s "%2$s"'), $comment->comment_post_ID, $post->post_title ) . "\r\n"; $notify_message .= sprintf( __('Author : %1$s'), $comment->comment_author ) . "\r\n"; $notify_message .= __('Comment: ') . "\r\n" . $comment->comment_content . "\r\n\r\n"; $notify_message .= __('You can see all comments on this post here: ') . "\r\n"; $subject = sprintf( __('[%1$s] Comment: "%2$s"'), $blogname, $post->post_title ); } elseif ('trackback' == $comment_type) { $notify_message = sprintf( __('New trackback on your post #%1$s "%2$s"'), $comment->comment_post_ID, $post->post_title ) . "\r\n"; $notify_message .= sprintf( __('Website: %1$s'), $comment->comment_author ) . "\r\n"; $notify_message .= __('Excerpt: ') . "\r\n" . $comment->comment_content . "\r\n\r\n"; $notify_message .= __('You can see all trackbacks on this post here: ') . "\r\n"; $subject = sprintf( __('[%1$s] Trackback: "%2$s"'), $blogname, $post->post_title ); } elseif ('pingback' == $comment_type) { $notify_message = sprintf( __('New pingback on your post #%1$s "%2$s"'), $comment->comment_post_ID, $post->post_title ) . "\r\n"; $notify_message .= sprintf( __('Website: %1$s'), $comment->comment_author ) . "\r\n"; $notify_message .= __('Excerpt: ') . "\r\n" . sprintf('[...] %s [...]', $comment->comment_content ) . "\r\n\r\n"; $notify_message .= __('You can see all pingbacks on this post here: ') . "\r\n"; $subject = sprintf( __('[%1$s] Pingback: "%2$s"'), $blogname, $post->post_title ); } $notify_message .= get_permalink($comment->comment_post_ID) . "#comments\r\n\r\n"; $notify_message .= sprintf( __('Delete it: %s'), admin_url("comment.php?action=cdc&c=$comment_id") ) . "\r\n"; $notify_message .= sprintf( __('Spam it: %s'), admin_url("comment.php?action=cdc&dt=spam&c=$comment_id") ) . "\r\n"; $wp_email = 'wordpress@' . preg_replace('#^www\.#', '', strtolower($_SERVER['SERVER_NAME'])); if ( '' == $comment->comment_author ) { $from = "From: \"$blogname\" <$wp_email>"; if ( '' != $comment->comment_author_email ) $reply_to = "Reply-To: $comment->comment_author_email"; } else { $from = "From: \"$comment->comment_author\" <$wp_email>"; if ( '' != $comment->comment_author_email ) $reply_to = "Reply-To: \"$comment->comment_author_email\" <$comment->comment_author_email>"; } $message_headers = "$from\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n"; if ( isset($reply_to) ) $message_headers .= $reply_to . "\n"; $notify_message = apply_filters('comment_notification_text', $notify_message, $comment_id); $subject = apply_filters('comment_notification_subject', $subject, $comment_id); $message_headers = apply_filters('comment_notification_headers', $message_headers, $comment_id); @wp_mail($user->user_email, $subject, $notify_message, $message_headers); return true; } endif;It prunes the IP/WhoIS/email information from the email.
Untested, but should work.
Hope this helps.Forum: Fixing WordPress
In reply to: Database Bloat – RevisionsWell, I think something’s corrupt in that one installation of mine then. Neither the Revision Control plugin, nor setting that constant does the trick for me. Perhaps I need to clear the database of revisions, or something.
Revision Control has been the only plugin active on that website. Surely the theme wouldn’t affect revisions/autosaves.
Edit: Should also mention that the website currently has only pages, no blog posts.
Forum: Fixing WordPress
In reply to: Database Bloat – RevisionsTo be more precise on post above: my problem is with revisions on pages. Is there a way/plugin to disable revision control for pages?
I tried the plugin as mentioned above, and also adding “define(‘WP_POST_REVISIONS’, false);” in the wp-config.php file.
This leaves me quite puzzled, as setting WP_POST_REVISIONS to false should do the trick for both pages and posts, shouldn’t it?
Forum: Themes and Templates
In reply to: posting form to custom template results in 404Lots of wasted time here too, glad I found this post though. Thanks loads.
Odd though, that a form with a name set to “name” would fail to parse. This has to be a WordPress cleanup issue, or a security “feature” perhaps? Did anyone investigate this?
Forum: Fixing WordPress
In reply to: Database Bloat – RevisionsThe “View the Autosave” thing is now driving me nuts. 🙂
Forum: Fixing WordPress
In reply to: Database Bloat – RevisionsI installed Revision Control, but it seems WordPress 2.7.1 bypasses it. Even though all pages created are set to “No revision”, I still get the red warning “A revision of this page exists! etc.”. Any ideas?
Forum: Fixing WordPress
In reply to: Database Bloat – RevisionsSame. Revisions aren’t always needed. Integrating the Revision control plugin would be quite useful.
Forum: Installing WordPress
In reply to: Auto upgrade to 2.7.1 doesnt finish.Off-topic, Fred, but see here for some workarounds. This is a server-side memory issue, probably have too many scripts running, consuming too much memory, or possibly a memory leak somewhere.
Forum: Installing WordPress
In reply to: Auto upgrade to 2.7.1 doesnt finish.That may depend on servers, Otto, as you probably know. Perhaps a permissions issue prevents it in some cases on those servers. I know it’s meant to be deleted and the devs didn’t forget about it; can’t always account for all server quirks.
Like said, great job 🙂
Forum: Installing WordPress
In reply to: Auto upgrade to 2.7.1 doesnt finish.Same here.
I’d like to just pitch in and say that, in spite of the failure to remove that .maintenance file, which appears to be causing the issue in most cases, this built-in automatic upgrade, simply, rocks.
Forum: Everything else WordPress
In reply to: How do I change my forum email addressSame.
Yet it proved necessary when I upgraded a client’s blog to the latest version three weeks ago, on a Yahoo Small Business account.
Just for kicks, I just uninstalled Mark’s Canonical URL there, refreshed the front page, clicked on the first link, which was canonical, and watched Firefox go into an endless “Waiting/Connected” loop, ending in a “Redirect Loop” error. I reinstalled the plugin, and the canonical URL loaded instantly.
So, yes, Otto42, it should not be necessary. But it still is, with the latest version of WordPress (2.6.5), on this particular installation on Yahoo.
Forum: Fixing WordPress
In reply to: Recent posts in sidebarSorry for the response to this old thread, but the answer above is misleading. We’re seeing quite a few posts lately from folks who get blank pages, because the loop posts were consumed by a call to query_posts() before the call to the main loop is made. The above will work perfectly well if your sidebar is called after the post content is displayed, but will show blank pages if it’s called before the Loop.
So, let’s just highlight this important note:
Important note
The query_posts function is intended to be used to modify the main page Loop only. It is not intended as a means to create secondary Loops on the page. If you want to create separate Loops outside of the main one, you should create separate WP_Query objects and use those instead. Use of query_posts on Loops other than the main one can result in your main Loop becoming incorrect and possibly displaying things that you were not expecting.
The query_posts function overrides and replaces the main query for the page. To save your sanity, do not use it for any other purpose.
What you need is something like what was mentioned here:
Recent <ul class="recent-posts"> <?php $archive_query = new WP_Query('showposts=5'); while ($archive_query->have_posts()) : $archive_query->the_post(); ?> <li><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></li> <?php endwhile; ?> </ul>