Most commented last 24h, week, month, year and all time – posts_where

Where? The WP_Comment_Query class has the following filter for its clauses: $pieces = array( ‘fields’, ‘join’, ‘where’, ‘orderby’, ‘order’, ‘limits’, ‘groupby’ ); $clauses = apply_filters_ref_array( ‘comments_clauses’, array( compact( $pieces ), &$this ) ); That means you can hook into comments_clauses and filter the $clauses[‘where’] part. How? Since WP 3.7, we got a WP_Date_Query class. It … Read more

Do I need to deal with WordPress SQL Injection

Higher-level API functions like this in WP typically do the $wpdb->prepare() call to protect against MySQL injections. As for content by default comments do allow HTML, however it isn’t just anything. If you examine default-filters.php there are quite a few sanitizing functions hooked to processing comment data, including wp_kses_post() which limits HTML to white listed … Read more

save_post action hook for comments

You can try the edit_comment hook that’s fired within the wp_update_comment() function, called by the edit_comment() function when you edit a comment in the backend. This hook is fired after the comment is updated in the database. Example: add_action( ‘edit_comment’, function( $comment_ID ) { // … your code here … } ); Notice the following … Read more

API Hook for After Commenting (for sharing on Facebook)

Have you tried comment_post action? It’s fired right after the comment is inserted into the database. function share_comment_on_facebook( $comment_ID ) { $commentdata = get_comment( $comment_ID ); if ( $commentdata[‘comment_approved’] ) { // fire up the code to launch pop up } } add_action( ‘comment_post’, ‘share_comment_on_facebook’ );