function alaya_recent_comment($number) { $commentNum = 1; // Get the comments $recent_comments = get_comments(array('number' => $number, 'status' => 'approve', 'type' => 'comment')); $commentList = '<ul>'; foreach ($recent_comments as $comment) { $commentList .= '<li> <header class="clearfix"> <figure> <a href="' . get_permalink($comment->comment_post_ID) . '"> ' . get_avatar($comment->comment_author_email, '40') . ' </a> <span class="comment-author-name"> ' . $comment->comment_author . ' </span> <div class="comment-order">' . $commentNum . '</div> </figure> <a class="comment-post" href="' . esc_url(get_permalink($comment->comment_post_ID)) . '#comment-' . esc_attr($comment->comment_ID) . '"> ' . esc_attr(get_the_title($comment->comment_post_ID)) . ' </a> </header> <div class="comment-text"> <div class="up-arrow"></div> ' . wp_trim_words($comment->comment_content, 30) . ' </div> </li>'; $commentNum++; } $commentList .= '</ul>'; return $commentList; }
/** * Process a refund if supported * @param int $order_id * @param float $amount * @param string $reason * @return bool|wp_error True or false based on success, or a WP_Error object */ public function process_refund($order_id, $amount = null, $reason = '') { $order = wc_get_order($order_id); $transaction_id = null; $args = array('post_id' => $order->id, 'approve' => 'approve', 'type' => ''); remove_filter('comments_clauses', array('WC_Comments', 'exclude_order_comments')); $comments = get_comments($args); foreach ($comments as $comment) { if (strpos($comment->comment_content, 'Transaction ID: ') !== false) { $exploded_comment = explode(": ", $comment->comment_content); $transaction_id = $exploded_comment[1]; } } add_filter('comments_clauses', array('WC_Comments', 'exclude_order_comments')); if (!$order || !$transaction_id) { return false; } // Add transaction-specific details to the request $transaction_details = array('username' => $this->username, 'password' => $this->password, 'type' => 'refund', 'transactionid' => $transaction_id, 'ipaddress' => $_SERVER['REMOTE_ADDR']); if (!is_null($amount)) { $transaction_details['amount'] = number_format($amount, 2, '.', ''); } // Send request and get response from server $response = $this->post_and_get_response($transaction_details); // Check response if ($response['response'] == 1) { // Success $order->add_order_note(__('Inspire Commerce refund completed. Refund Transaction ID: ', 'woocommerce') . $response['transactionid']); return true; } else { // Failure $order->add_order_note(__('Inspire Commerce refund error. Response data: ', 'woocommerce') . http_build_query($response)); return false; } }
function siiimple_comments($args) { extract($args, EXTR_SKIP); echo $before_widget . "\n"; echo $before_title . 'Recent Comments' . $after_title . "\n"; $comments = get_comments('status=approve&number=5'); if ($comments) { echo '<ul id="recent_comments">'; foreach ($comments as $comment) { echo '<li><a href="' . get_permalink($comment->comment_post_ID) . '#comment-' . $comment->comment_ID . '" title="' . $comment->comment_author . ' | ' . get_the_title($comment->comment_post_ID) . '">' . get_avatar($comment->comment_author_email, $img_w); echo '<span class="recent_comment_name">' . $comment->comment_author . '</span><br/>'; $comment_string = $comment->comment_content; $comment_excerpt = substr($comment_string, 0, 20); echo $comment_excerpt; if (strlen($comment_excerpt) > 25) { echo ' ...'; } echo '</a></li>'; } echo '</ul>'; } else { echo '<ul id="recent_comments"> <li>No Comments Yet</li> </ul>'; } echo $after_widget . "\n"; }
/** * Add the reaction buttons to the post content. * @param string $content The content HTML * @return string The content HTML, with the react buttons attached */ public function the_content($content) { $post_id = get_the_ID(); if (!$post_id) { return $content; } $reactions = get_comments(array('post_id' => $post_id, 'type' => 'reaction')); $reactions_summary = array(); foreach ($reactions as $reaction) { if (!isset($reactions_summary[$reaction->comment_content])) { $reactions_summary[$reaction->comment_content] = 0; } $reactions_summary[$reaction->comment_content]++; } $content .= '<div class="emoji-reactions">'; foreach ($reactions_summary as $emoji => $count) { $content .= "<div data-emoji='{$emoji}' data-count='{$count}' data-post='{$post_id}' class='emoji-reaction'><div class='emoji'>{$emoji}</div><div class='count'>{$count}</div></div>"; } if (comments_open($post_id)) { /* translators: This is the emoji used for the "Add new emoji reaction" button */ $content .= "<div data-post='{$post_id}' class='emoji-reaction-add'><div class='emoji'>" . __('😃+', 'react') . '</div></div>'; } $content .= '</div>'; return $content; }
function wp_count_comments_override($comments, $post_id = 0) { add_filter('comments_clauses', array('CommentsInterceptor_RS', 'wp_count_comments_clauses'), 99, 2); $count = get_comments(array('post_id' => $post_id)); remove_filter('comments_clauses', array('CommentsInterceptor_RS', 'wp_count_comments_clauses'), 99, 2); // remainder of this function ported from WP 3.2 function wp_count_comments() $total = 0; $approved = array('0' => 'moderated', '1' => 'approved', 'spam' => 'spam', 'trash' => 'trash', 'post-trashed' => 'post-trashed'); foreach ((array) $count as $row) { $row = (array) $row; // RS modification // Don't count post-trashed toward totals if ('post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved']) { $total += $row['num_comments']; } if (isset($approved[$row['comment_approved']])) { $stats[$approved[$row['comment_approved']]] = $row['num_comments']; } } $stats['total_comments'] = $total; foreach ($approved as $key) { if (empty($stats[$key])) { $stats[$key] = 0; } } $stats = (object) $stats; return $stats; }
/** * Query the database for specific liveblog entries * * @param array $args the same args for the core `get_comments()`. * @return array array of `WPCOM_Liveblog_Entry` objects with the found entries */ private function get($args = array()) { $defaults = array('post_id' => $this->post_id, 'orderby' => 'comment_date_gmt', 'order' => 'DESC', 'type' => $this->key, 'status' => $this->key); $args = wp_parse_args($args, $defaults); $comments = get_comments($args); return self::entries_from_comments($comments); }
/** * widget function. * * @see WP_Widget * @access public * @param array $args * @param array $instance * @return void */ public function widget($args, $instance) { global $comments, $comment, $woocommerce; if ($this->get_cached_widget($args)) { return; } ob_start(); extract($args); $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base); $number = absint($instance['number']); $comments = get_comments(array('number' => $number, 'status' => 'approve', 'post_status' => 'publish', 'post_type' => 'product')); if ($comments) { echo $before_widget; if ($title) { echo $before_title . $title . $after_title; } echo '<ul class="product_list_widget">'; foreach ((array) $comments as $comment) { $_product = get_product($comment->comment_post_ID); $rating = intval(get_comment_meta($comment->comment_ID, 'rating', true)); $rating_html = $_product->get_rating_html($rating); echo '<li><a href="' . esc_url(get_comment_link($comment->comment_ID)) . '">'; echo $_product->get_image(); echo $_product->get_title() . '</a>'; echo $rating_html; printf('<span class="reviewer">' . _x('by %1$s', 'by comment author', 'woocommerce') . '</span>', get_comment_author()); echo '</li>'; } echo '</ul>'; echo $after_widget; } $content = ob_get_clean(); echo $content; $this->cache_widget($args, $content); }
static function getWordpressData() { /** * Get all global page data */ $blogDataParams = array( 'url', 'wpurl', 'description', 'rdf_url' , 'rss_url', 'rss2_url' , 'atom_url', 'comments_atom_url', 'comments_rss2_url', 'pingback_url' , 'stylesheet_url', 'stylesheet_directory', 'template_directory' , 'template_url', 'admin_email', 'charset', 'html_type', 'version' , 'language', 'text_direction', 'name' ); $blogData = array(); foreach($blogDataParams as $blogDataParam) { $blogData[self::toCamelCase($blogDataParam)] = get_bloginfo($blogDataParam); } $blogData = array_merge($blogData, array( 'title' => wp_title(' | ', false, 'right') . get_bloginfo('name'), 'archiveLinksHTML' => wp_get_archives('type=monthly&limit=5&format=link&echo=0'), 'bodyClasses' => self::getEchoFunctionContents('body_class'), 'posts' => array() )); /** * Get posts data */ while (have_posts()) { the_post(); $postId = get_the_ID(); // Get category data $categories = get_the_category(); $categoryNames = array(); foreach($categories as $category) { array_push($categoryNames, $category->cat_name); } // Add all relevant post data to the posts array array_push( $blogData['posts'], array_merge( get_object_vars(get_post($postId)), array( 'classes' => get_post_class(), 'comments' => get_comments(array('post_id' => $postId)), 'custom' => get_post_custom(), 'permalink' => get_permalink(), 'categories' => $categories, 'categoryNames' => $categoryNames, 'categoriesStr' => implode(',', $categoryNames) ) ) ); } return $blogData; }
function get_most_recent_comments($args = null) { global $most_recent_comments_args; // You can pass any of these arguments as well as any argument supported by get_comments() $defaults = array('passworded_posts' => false, 'showpings' => false, 'post_types' => array('post', 'page'), 'post_statuses' => array('publish', 'static'), 'number' => 5, 'status' => 'approve'); $most_recent_comments_args = wp_parse_args($args, $defaults); // Create the cache key $key = md5(serialize($most_recent_comments_args)); $last_changed = wp_cache_get('last_changed', 'comment'); if (!$last_changed) { $last_changed = time(); wp_cache_set('last_changed', $last_changed, 'comment'); } $cache_key = "most_recent_comments:{$key}:{$last_changed}"; // Check to see if we already have results for this request if ($cache = wp_cache_get($cache_key, 'comment')) { return $cache; } // Modify the get_comments() SQL query add_filter('comments_clauses', '_mrc_modify_comments_clauses'); // Get the comments // The custom arguments will be ignored by get_comments() $comments = get_comments($most_recent_comments_args); // Remove the get_comments() SQL query filter remove_filter('comments_clauses', '_mrc_modify_comments_clauses'); // Cache these results wp_cache_add($cache_key, $comments, 'comment'); return $comments; }
function show_comments_page($dbconn, $diary_login) { $nid = (int) $_GET['nid']; // Get Note $sql = "SELECT u.uid, n.* FROM " . TABLE_USERS . " AS u, " . TABLE_NOTES . " AS n WHERE u.login='******' AND n.uid=u.uid AND n.nid='" . $nid . "' LIMIT 1"; $result = pg_query($sql) or die(pg_last_error($dbconn)); if (pg_num_rows($result) == 0) { show_error_page($dbconn, $diary_login, "no such note!"); return; } else { $datanote = pg_fetch_object($result, NULL); pg_free_result($result); $sql = "SELECT u.uid, s.format_note, s.page_comments, s.format_comment FROM " . TABLE_SETTINGS . " AS s, " . TABLE_USERS . " AS u WHERE u.login='******' AND s.uid=u.uid LIMIT 1"; $result = pg_query($sql) or die(pg_last_error($dbconn)); $dataformat = pg_fetch_object($result, NULL); // Strip link to add comment and number of comments $dataformat->format_note = preg_replace('/(<a.* href="{hrefcomment}")(.+)(.*>)/', '', $dataformat->format_note); $dataformat->format_note = preg_replace('/(.?{commentscount}.?)/', '', $dataformat->format_note); $note = assign_vars($dataformat->format_note, array('{subject}' => $datanote->subject, '{contents}' => $datanote->contents, '{date}' => date("d-m-Y", $datanote->timestamp), '{time}' => date("H:i:s", $datanote->timestamp))); $comments = get_comments($dbconn, $diary_login, $dataformat->format_comment, $nid); $sql = "SELECT COUNT(c.*) AS commentscount FROM " . TABLE_USERS . " AS u, " . TABLE_COMMENTS . " AS c WHERE c.nid='" . $nid . "' AND c.uid=u.uid AND u.login='******'"; $result = pg_query($sql) or die(pg_last_error($dbconn)); $datacount = pg_fetch_object($result, NULL); pg_free_result($result); $commentscount = (int) $datacount->commentscount; echo assign_vars($dataformat->page_comments, array('{login}' => $diary_login, '{note}' => $note, '{comments}' => $comments, '{commentscount}' => $commentscount, '{hrefcommentadd}' => 'http://' . $_SERVER['SERVER_NAME'] . '/' . PAGE_COMMENTS . '&nid=' . $nid . '&action=add')); } }
/** * Get a list of comments for a given type * * @param string $type Type of comments to fetch * @return array Array of comment objects */ function anno_internal_comments_get_comments($type, $post_id) { remove_filter('comments_clauses', 'anno_internal_comments_clauses'); $comments = get_comments(array('type' => $type, 'post_id' => $post_id)); add_filter('comments_clauses', 'anno_internal_comments_clauses'); return $comments; }
function gen_comment_msg($t, $id) { $comments = get_comments($t, $id); $msg = html_of_speaker($id) . "\n"; $msg .= html_of_comments($comments) . "\n"; return $msg; }
function widget_lmee_by_talk($args) { extract($args); echo $before_widget; $lmee_popular_options = get_option('widget_lmee_popular'); $title = '灌水区-这里很热闹'; //设置默认的标题 echo $before_title . $title . $after_title; $page_ID = 789; //用来作为公告栏的页面或者文章id $num = 5; //显示公告的条数 echo '<ul class="by_talk">'; $announcement = ''; $comments = get_comments("number={$num}&post_id={$page_ID}"); if (!empty($comments)) { $flg = 1; foreach ($comments as $comment) { if ($flg == 1) { $li_title = $comment->comment_content; if (similar_text($li_title, "<") > 0) { //echo "is"; $start = stripos($li_title, "<"); //从前往后查找 $__li_title = strrev($li_title); //反转字符串 $length = strlen($li_title) - $start - stripos($__li_title, ">"); $_li_title = substr_replace($li_title, "含引用", $start, $length); $_li_html = substr_replace($li_title, "", $start, $length); $announcement .= '<li class="by-talk-first"><a href="' . get_page_link($page_ID) . '#comment-' . $comment->comment_ID . '" title="' . $_li_title . '" rel="nofollow" target="_blank">' . $_li_html . '</a><br /><span style="color:#999;text-align:right;">(' . get_comment_date('Y/m/d H:i', $comment->comment_ID) . ')</span></li><hr />'; } else { //echo "un"; $announcement .= '<li class="by-talk-first"><a href="' . get_page_link($page_ID) . '#comment-' . $comment->comment_ID . '" title="' . $li_title . '" rel="nofollow" target="_blank">' . convert_smilies($comment->comment_content) . '</a><br /><span style="color:#999;text-align:right;">(' . get_comment_date('Y/m/d H:i', $comment->comment_ID) . ')</span></li><hr />'; } $flg++; } else { $li_title = $comment->comment_content; if (similar_text($li_title, "<") > 0) { //echo "is"; $start = stripos($li_title, "<"); //从前往后查找 $__li_title = strrev($li_title); //反转字符串 $length = strlen($li_title) - $start - stripos($__li_title, ">"); $_li_title = substr_replace($li_title, "含引用", $start, $length); $_li_html = substr_replace($li_title, "", $start, $length); $announcement .= '<li><a href="' . get_page_link($page_ID) . '#comment-' . $comment->comment_ID . '" title="' . $_li_title . '" rel="nofollow" target="_blank">' . $_li_html . '</a><br /><span style="color:#999;text-align:right;">(' . get_comment_date('Y/m/d H:i', $comment->comment_ID) . ')</span></li><hr />'; } else { //echo "un"; $announcement .= '<li><a href="' . get_page_link($page_ID) . '#comment-' . $comment->comment_ID . '" title="' . $li_title . '" rel="nofollow" target="_blank">' . convert_smilies($comment->comment_content) . '</a><br /><span style="color:#999;text-align:right;">(' . get_comment_date('Y/m/d H:i', $comment->comment_ID) . ')</span></li><hr />'; } } } } //if ( empty($announcement) ) $announcement = '<li>还没有人灌水奥!</li>'; echo $announcement; echo '</ul>'; echo "<p style='text-align:right;'>[<a href='" . get_page_link($page_ID) . "#respond' rel='nofollow'>说两句</a>]</p>"; echo $after_widget; }
/** * Outputs the content for the current Recent Comments widget instance. * * @param array $args Display arguments including 'before_title', 'after_title', * 'before_widget', and 'after_widget'. * @param array $instance Settings for the current Recent Comments widget instance. */ public function widget($args, $instance) { if (!isset($args['widget_id'])) { $args['widget_id'] = $this->id; } $title = !empty($instance['title']) ? $instance['title'] : __('Recent Comments'); /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */ $title = apply_filters('widget_title', $title, $instance, $this->id_base); $number = !empty($instance['number']) ? absint($instance['number']) : 5; if (!$number) { $number = 5; } $show_date = isset($instance['show_date']) ? $instance['show_date'] : false; /** * Filter the arguments for the Recent Comments widget. * * @since 3.4.0 * * @see WP_Comment_Query::query() for information on accepted arguments. * * @param array $comment_args An array of arguments used to retrieve the recent comments. */ $comments = get_comments(apply_filters('widget_comments_args', array('number' => $number, 'status' => 'approve', 'post_status' => 'publish'))); if (is_array($comments) && $comments) { // Prime cache for associated posts. (Prime post term cache if we need it for permalinks.) $post_ids = array_unique(wp_list_pluck($comments, 'comment_post_ID')); _prime_post_caches($post_ids, strpos(get_option('permalink_structure'), '%category%'), false); $args['title'] = $title; $args['comments'] = $comments; $args['show_date'] = $show_date; get_template_part_hierarchical_fetch('partials/widgets/recent-comments', '', $args); wp_reset_postdata(); } }
/** * Find all comments by a given post ID * * @access public * @param int $commentId * @link http://codex.wordpress.org/Function_Reference/get_comments * @return array */ public function findByParentId($commentId) { $args = array('parent' => $commentId); $comments = get_comments($args); // Convert and return the comments return $this->convertAndReturn($comments); }
/** * Process user deletion requests. * * Note: No longer called here. See the Settings component. */ function bp_core_action_delete_user() { $userID = bp_displayed_user_id(); echo "Buddypress:"; echo $userID; $now = current_time('mysql'); $args = array('date_query' => array('after' => '5 minute ago', 'before' => $now, 'inclusive' => true), 'post_id' => $postID, 'user_id' => $userID, 'count' => true); $userActivityCount = get_comments($args); if (!bp_current_user_can('bp_moderate') || bp_is_my_profile() || !bp_displayed_user_id() || $userActivityCount != 0) { return false; } if (bp_is_current_component('admin') && bp_is_current_action('delete-user') && $userActivityCount == 0) { // Check the nonce. check_admin_referer('delete-user'); $errors = false; $style = "<style> #account-delete-form .submit{ display:none !important;} </style>"; if ($userActivityCount != 0) { $errors = true; return $style; } do_action('bp_core_before_action_delete_user', $errors); if (bp_core_delete_account(bp_displayed_user_id()) || $userActivityCount == 0) { bp_core_add_message(sprintf(__('%s has been deleted from the system.', 'buddypress'), bp_get_displayed_user_fullname())); } else { bp_core_add_message(sprintf(__('There was an error deleting %s from the system. Please try again.', 'buddypress'), bp_get_displayed_user_fullname()), 'error'); $errors = true; } do_action('bp_core_action_delete_user', $errors); if ($errors) { bp_core_redirect(bp_displayed_user_domain()); } else { bp_core_redirect(bp_loggedin_user_domain()); } } }
function show_comments($root_comment, $is_outer) { $children = get_comments(array('parent' => $root_comment->comment_ID)); // 子コメントでかつ最も外側で読んでいる場合は表示しない if ($root_comment->comment_parent != '0' && $is_outer) { return; } if (!is_null($children)) { $children_coutput = '<ul class="mdl-list comments child">'; foreach ($children as $cc) { $children_coutput = $children_coutput . show_comments($cc, false); } $children_coutput = $children_coutput . '</ul>'; } $home_url = home_url(); $author = empty($root_comment->comment_author) ? '匿名' : $root_comment->comment_author; $output = <<<HTML <li class="mdl-list__item mdl-list__item--three-line" id="{$root_comment->comment_ID}"> <span class="mdl-list__item-primary-content"> <i class="material-icons mdl-list__item-avatar">person</i> <span class="author">{$author}</span> <span class="mdl-list__item-text-body">{$root_comment->comment_content}</span> {$children_coutput} </span> <span class="mdl-list__item-secondary-content reply"> <button data-replytocom="{$root_comment->comment_ID}" data-commentauthor="{$author}" class="replytocom mdl-list__item-secondary-action mdl-button mdl-js-button mdl-button--icon" rel='nofollow'> <i class="material-icons">reply</i> </button> </span> </li> HTML; return $output; }
function widget($args, $instance) { if (!isset($args['widget_id'])) { $args['widget_id'] = $this->id; } $output = ''; $title = !empty($instance['title']) ? $instance['title'] : __('Recent Comments'); $title = apply_filters('widget_title', $title, $instance, $this->id_base); $number = !empty($instance['number']) ? absint($instance['number']) : 5; if (!$number) { $number = 5; } $comments = get_comments(apply_filters('widget_comments_args', array('number' => $number, 'status' => 'approve', 'post_status' => 'publish'))); $output .= $args['before_widget']; if ($title) { $output .= $args['before_title'] . $title . $args['after_title']; } $output .= '<ul id="recentcomments">'; if (is_array($comments) && $comments) { $post_ids = array_unique(wp_list_pluck($comments, 'comment_post_ID')); _prime_post_caches($post_ids, strpos(get_option('permalink_structure'), '%category%'), false); foreach ((array) $comments as $comment) { $title = get_the_title($comment->comment_post_ID); $output .= '<li class="recentcomments"><i class="fa fa-comments"> </i> '; $output .= sprintf(_x('%1$s on %2$s', 'widgets'), '<span class="comment-author-link"><strong> ' . get_comment_author_link($comment) . '</strong></span>', '<br><a href="' . esc_url(get_comment_link($comment)) . '">' . $title . '</a>'); $output .= '</li>'; } } $output .= '</ul>'; $output .= $args['after_widget']; echo $output; }
public function run($arguments) { $arguments = Ithemes_Sync_Functions::merge_defaults($arguments, $this->default_arguments); if (!is_callable('get_comments')) { include_once ABSPATH . WPINC . '/wp-includes/comment.php'; } if (!is_callable('get_comments')) { return new WP_Error('missing-function-get_comments', 'Due to an unknown issue, the wp_comments function is not available.'); } $comments = get_comments($arguments['args']); if (is_array($comments)) { $this->response['comments'] = array(); foreach ($comments as $index => $comment) { $this->response['comments'][$comment->comment_ID] = (array) $comment; } if ($arguments['include-parent-details']) { $this->add_parent_details(); } if ($arguments['include-post-details']) { $this->add_post_details(); } if ($arguments['include-user-details']) { $this->add_user_details(); } } else { $this->response = $comments; } return $this->response; }
function widget_lmee_notice($args) { extract($args); echo $before_widget; $lmee_popular_options = get_option('widget_lmee_popular'); $title = '小家伙说的话(NOTICE)'; //设置默认的标题 echo $before_title . $title . $after_title; $page_ID = 515; //用来作为公告栏的页面或者文章id $num = 2; //显示公告的条数 echo '<ul class="notice" style="padding: 1em 1.4em;">'; $announcement = ''; $comments = get_comments("number={$num}&post_id={$page_ID}"); if (!empty($comments)) { foreach ($comments as $comment) { $announcement .= '<li>' . convert_smilies($comment->comment_content) . ' <span style="color:#999;">(' . get_comment_date('y/m/d', $comment->comment_ID) . ')</span></li>'; } } if (empty($announcement)) { $announcement = '<li>欢迎来到 LMEE!</li>'; } echo $announcement; echo '</ul>'; if (is_user_logged_in()) { echo '<p style="text-align:right;"><a href="' . get_page_link($page_ID) . '#respond" rel="nofollow">发表公告</a></p>'; } echo $after_widget; }
function woo_add_order_notes_to_email() { global $woocommerce, $post; $args = array('post_id' => $post->ID, 'approve' => 'approve', 'type' => 'order_note'); $notes = get_comments($args); echo '<h2>' . __('Order Notes', 'woocommerce') . '</h2>'; echo '<ul class="order_notes">'; if ($notes) { foreach ($notes as $note) { $note_classes = get_comment_meta($note->comment_ID, 'is_customer_note', true) ? array('customer-note', 'note') : array('note'); ?> <li rel="<?php echo absint($note->comment_ID); ?> " class="<?php echo implode(' ', $note_classes); ?> "> <div class="note_content"> (<?php printf(__('added %s ago', 'woocommerce'), human_time_diff(strtotime($note->comment_date_gmt), current_time('timestamp', 1))); ?> ) <?php echo wpautop(wptexturize(wp_kses_post($note->comment_content))); ?> </div> </li> <?php } } else { echo '<li>' . __('There are no notes for this order yet.', 'woocommerce') . '</li>'; } echo '</ul>'; }
function mirana_recent_comments($show_comments = 6) { $my_email = get_bloginfo('admin_email'); $i = 1; $comments = get_comments('number=50&status=approve&type=comment'); foreach ($comments as $rc_comment) { if ($rc_comment->comment_author_email != $my_email) { ?> <li class="sidcomment"> <a href="<?php echo get_permalink($rc_comment->comment_post_ID); ?> #comment-<?php echo $rc_comment->comment_ID; ?> " title="查看完整评论"> <?php echo get_avatar($rc_comment->comment_author_email, 28); ?> <?php echo mb_strimwidth(strip_tags(apply_filters('the_content', convert_smilies($rc_comment->comment_content))), 0, 27, "..."); ?> </a> </li> <?php if ($i == $show_comments) { break; } $i++; } } }
function display_comments($story_id) { $CI =& get_instance(); $CI->load->library('comment/comments_parser'); $comments = get_comments($story_id); $CI->comments_parser->arrange($comments); }
private function load_comments() { $comments = get_comments(array('status' => 'approve', 'post_id' => $this->ID)); foreach ($comments as $comment) { $this->comments[] = new WPOO_Comment($comment); } }
function render($args, $instance) { global $gantry, $comments, $comment; ob_start(); $menu_class = $instance['menu_class']; $link_class = $instance['link_class']; if ($menu_class != '') { $menu_class = ' class="' . $menu_class . '"'; } else { $menu_class = ''; } if ($link_class != '') { $link_class = ' class="' . $link_class . '"'; } else { $link_class = ''; } $cache = wp_cache_get('gantry_recentcomments', 'widget'); if (!is_array($cache)) { $cache = array(); } if (isset($cache[$args['widget_id']])) { echo $cache[$args['widget_id']]; return; } $output = ''; if (!($number = (int) $instance['number'])) { $number = 5; } else { if ($number < 1) { $number = 1; } } if (!($word_limit = (int) $instance['word_limit'])) { $word_limit = 8; } else { if ($word_limit < 1) { $word_limit = 1; } } $comments = get_comments(array('number' => $number, 'status' => 'approve')); $output .= '<ul' . $menu_class . '>'; if ($comments) { foreach ((array) $comments as $comment) { $words = explode(' ', strip_tags($comment->comment_content)); $comment_text = implode(' ', array_slice($words, 0, $word_limit)); $avatar = get_avatar($comment->comment_author_email, $size = 32); $avatar = str_replace("class='", "class='rt-image ", $avatar); $output .= '<li class="gantry_recentcomments">'; $output .= $avatar; $output .= '<a href="' . get_comment_link($comment->comment_ID) . '"' . $link_class . '>' . $comment_text . '...</a>'; $output .= '<br />By ' . $comment->comment_author; $output .= '</li>'; } } $output .= '</ul>'; echo $output; $cache[$args['widget_id']] = $output; wp_cache_set('gantry_recentcomments', $cache, 'widget'); echo ob_get_clean(); }
/** * widget function. * * @see WP_Widget * * @param array $args * @param array $instance */ public function widget($args, $instance) { global $comments, $comment; if ($this->get_cached_widget($args)) { return; } ob_start(); $number = !empty($instance['number']) ? absint($instance['number']) : $this->settings['number']['std']; $comments = get_comments(array('number' => $number, 'status' => 'approve', 'post_status' => 'publish', 'post_type' => 'product')); if ($comments) { $this->widget_start($args, $instance); echo '<ul class="product_list_widget">'; foreach ((array) $comments as $comment) { $_product = wc_get_product($comment->comment_post_ID); $rating = intval(get_comment_meta($comment->comment_ID, 'rating', true)); $rating_html = $_product->get_rating_html($rating); echo '<li><a href="' . esc_url(get_comment_link($comment->comment_ID)) . '">'; echo $_product->get_image(); echo $_product->get_title() . '</a>'; echo $rating_html; printf('<span class="reviewer">' . _x('by %1$s', 'by comment author', 'woocommerce') . '</span>', get_comment_author()); echo '</li>'; } echo '</ul>'; $this->widget_end($args); } $content = ob_get_clean(); echo $content; $this->cache_widget($args, $content); }
function p2_get_discussion_links() { $comments = get_comments(array('post_id' => get_the_ID())); $unique_commentors = array(); foreach ($comments as $comment) { if ('1' == $comment->comment_approved) { $unique_commentors[$comment->comment_author_email] = get_avatar($comment, 16) . ' ' . get_comment_author_link($comment->comment_ID); } } $unique_commentors = array_values($unique_commentors); $total_unique_commentors = count($unique_commentors); $content = ''; if (1 == $total_unique_commentors) { $content = sprintf(__('%1$s is discussing.', 'p2'), $unique_commentors[0]); } else { if (2 == $total_unique_commentors) { $content = sprintf(__('%1$s and %2$s are discussing.', 'p2'), $unique_commentors[0], $unique_commentors[1]); } else { if (3 == $total_unique_commentors) { $content = sprintf(__('%1$s, %2$s, and %3$s are discussing.', 'p2'), $unique_commentors[0], $unique_commentors[1], $unique_commentors[2]); } else { if (3 < $total_unique_commentors) { $others = $total_unique_commentors - 3; $content .= sprintf(_n('%1$s, %2$s, %3$s, and %4$d other are discussing.', '%1$s, %2$s, %3$s, and %4$d others are discussing.', $others, 'p2'), $unique_commentors[0], $unique_commentors[1], $unique_commentors[2], $others); } } } } return $content; }
function comments_evolved_get_wordpress_count() { global $post, $comments, $wp_query, $comments_by_type, $id; $get_comments = get_comments('post_id=' . $id); $comments_by_type =& separate_comments($get_comments); return count($comments_by_type['comment']); }
function widget($args, $instance) { if (!isset($args['widget_id'])) { $args['widget_id'] = null; } extract($args, EXTR_SKIP); echo $before_widget; $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base); if ($title) { echo $before_title . $title . $after_title; } $comments = get_comments(apply_filters('widget_comments_args', array('number' => intval($instance['count']), 'status' => 'approve', 'post_status' => 'publish', 'post_type' => 'post'))); if (is_array($comments)) { $output = '<div class="Recent_comments">'; $output .= '<ul>'; foreach ($comments as $comment) { $url = get_permalink($comment->comment_post_ID) . '#comment-' . $comment->comment_ID . '" title="' . $comment->comment_author . ' | ' . get_the_title($comment->comment_post_ID); $date = new DateTime($comment->comment_date); $output .= '<li>'; $output .= '<span class="date_label">' . $date->format(get_option('date_format')) . '</span>'; $output .= '<p><i class="icon-user"></i> <strong>' . strip_tags($comment->comment_author) . '</strong> ' . __('commented on', 'mfn-opts') . ' <a href="' . $url . '">' . get_the_title($comment->comment_post_ID) . '</a></p>'; $output .= '</li>'; } $output .= '</ul>'; $output .= '</div>' . "\n"; } echo $output; echo $after_widget; }
function get_all_comments_list() { global $post; ob_start(); //exit(has_shortcode($post->post_content, 'list_comments')); # The comment functions use the query var 'cpage', so we'll ensure that's set $page = intval(get_query_var('cpage')); if (0 == $page) { $page = 1; set_query_var('cpage', $page); } # We'll do 10 comments per page... # Note that the 'page_comments' option in /wp-admin/options-discussion.php must be checked $comments_per_page = 10; $comments = get_comments(array('status' => 'approve', 'meta_key' => 'notify_user', 'meta_value' => get_current_user_id())); ?> <ol start="<?php echo $comments_per_page * $page - $comments_per_page + 1; ?> "> <?php wp_list_comments(array('style' => 'ol', 'per_page' => $comments_per_page, 'page' => $page, 'reverse_top_level' => false), $comments); ?> </ol> <?php // Now you can either use paginate_comments_links ... paginate_comments_links(); $html = ob_get_contents(); ob_end_clean(); return $html; }