15 )
$number = 15;
if ( !$comments = wp_cache_get( 'recent_comments-'.$sitepress->get_current_language(), 'widget' ) ) {
$comments = $wpdb->get_results("
SELECT * FROM {$wpdb->comments} c
JOIN {$wpdb->prefix}icl_translations t ON c.comment_post_id = t.element_id AND t.element_type='post_post'
WHERE comment_approved = '1' AND language_code = '".$sitepress->get_current_language()."'
ORDER BY comment_date_gmt DESC LIMIT {$number}
");
wp_cache_add( 'recent_comments-'.$sitepress->get_current_language(), $comments, 'widget' );
}
?>
get_current_language(), 'widget' );
}
add_action( 'comment_post', 'icl_wp_delete_recent_comments_cache' );
add_action( 'wp_set_comment_status', 'icl_wp_delete_recent_comments_cache' );
/**
* Display and process recent comments widget options form.
*
* @since 2.2.0
*/
function icl_wp_widget_recent_comments_control() {
$options = $newoptions = get_option('widget_recent_comments');
if ( isset($_POST["recent-comments-submit"]) ) {
$newoptions['title'] = strip_tags(stripslashes($_POST["recent-comments-title"]));
$newoptions['number'] = (int) $_POST["recent-comments-number"];
}
if ( $options != $newoptions ) {
$options = $newoptions;
update_option('widget_recent_comments', $options);
icl_wp_delete_recent_comments_cache();
}
$title = attribute_escape($options['title']);
if ( !$number = (int) $options['number'] )
$number = 5;
?>
'widget_recent_comments', 'description' => __( 'The most recent comments', 'sitepress') );
wp_register_sidebar_widget('recent-comments', __('Recent Comments', 'sitepress'), 'icl_wp_widget_recent_comments', $widget_ops);
wp_register_widget_control('recent-comments', __('Recent Comments', 'sitepress'), 'icl_wp_widget_recent_comments_control');
if ( is_active_widget('icl_wp_widget_recent_comments') )
add_action('wp_head', 'icl_wp_widget_recent_comments_style');
}
add_action('init', 'icl_wp_widget_recent_comments_register', 1);
?>