/** * Add edit comments link with awaiting moderation count bubble */ function bp_admin_bar_comments_menu($nxt_admin_bar) { global $nxt_admin_bar; if (!current_user_can('edit_posts')) { return; } $awaiting_mod = nxt_count_comments(); $awaiting_mod = $awaiting_mod->moderated; $awaiting_mod = $awaiting_mod ? "<span id='ab-awaiting-mod' class='pending-count'>" . number_format_i18n($awaiting_mod) . "</span>" : ''; $nxt_admin_bar->add_menu(array('parent' => 'dashboard', 'id' => 'comments', 'title' => sprintf(__('Comments %s'), $awaiting_mod), 'href' => admin_url('edit-comments.php'))); }
/** * Add edit comments link with awaiting moderation count bubble. * * @since 3.1.0 */ function nxt_admin_bar_comments_menu($nxt_admin_bar) { if (!current_user_can('edit_posts')) { return; } $awaiting_mod = nxt_count_comments(); $awaiting_mod = $awaiting_mod->moderated; $awaiting_title = esc_attr(sprintf(_n('%s comment awaiting moderation', '%s comments awaiting moderation', $awaiting_mod), number_format_i18n($awaiting_mod))); $icon = '<span class="ab-icon"></span>'; $title = '<span id="ab-awaiting-mod" class="ab-label awaiting-mod pending-count count-' . $awaiting_mod . '">' . number_format_i18n($awaiting_mod) . '</span>'; $nxt_admin_bar->add_menu(array('id' => 'comments', 'title' => $icon . $title, 'href' => admin_url('edit-comments.php'), 'meta' => array('title' => $awaiting_title))); }
/** * Sends back current comment total and new page links if they need to be updated. * * Contrary to normal success AJAX response ("1"), die with time() on success. * * @since 2.7 * * @param int $comment_id * @return die */ function _nxt_ajax_delete_comment_response($comment_id, $delta = -1) { $total = (int) @$_POST['_total']; $per_page = (int) @$_POST['_per_page']; $page = (int) @$_POST['_page']; $url = esc_url_raw(@$_POST['_url']); // JS didn't send us everything we need to know. Just die with success message if (!$total || !$per_page || !$page || !$url) { die((string) time()); } $total += $delta; if ($total < 0) { $total = 0; } // Only do the expensive stuff on a page-break, and about 1 other time per page if (0 == $total % $per_page || 1 == mt_rand(1, $per_page)) { $post_id = 0; $status = 'total_comments'; // What type of comment count are we looking for? $parsed = parse_url($url); if (isset($parsed['query'])) { parse_str($parsed['query'], $query_vars); if (!empty($query_vars['comment_status'])) { $status = $query_vars['comment_status']; } if (!empty($query_vars['p'])) { $post_id = (int) $query_vars['p']; } } $comment_count = nxt_count_comments($post_id); if (isset($comment_count->{$status})) { // We're looking for a known type of comment count $total = $comment_count->{$status}; } // else use the decremented value from above } $time = time(); // The time since the last comment count $x = new nxt_Ajax_Response(array('what' => 'comment', 'id' => $comment_id, 'supplemental' => array('total_items_i18n' => sprintf(_n('1 item', '%s items', $total), number_format_i18n($total)), 'total_pages' => ceil($total / $per_page), 'total_pages_i18n' => number_format_i18n(ceil($total / $per_page)), 'total' => $total, 'time' => $time))); $x->send(); }
/** * Retrieve comment count. * * @since 2.5.0 * * @param array $args Method parameters. * @return array */ function nxt_getCommentCount($args) { $this->escape($args); $blog_id = (int) $args[0]; $username = $args[1]; $password = $args[2]; $post_id = (int) $args[3]; if (!($user = $this->login($username, $password))) { return $this->error; } if (!current_user_can('edit_posts')) { return new IXR_Error(403, __('You are not allowed access to details about comments.')); } do_action('xmlrpc_call', 'nxt.getCommentCount'); $count = nxt_count_comments($post_id); return array('approved' => $count->approved, 'awaiting_moderation' => $count->moderated, 'spam' => $count->spam, 'total_comments' => $count->total_comments); }
function get_views() { global $post_id, $comment_status; $status_links = array(); $num_comments = $post_id ? nxt_count_comments($post_id) : nxt_count_comments(); //, number_format_i18n($num_comments->moderated) ), "<span class='comment-count'>" . number_format_i18n($num_comments->moderated) . "</span>"), //, number_format_i18n($num_comments->spam) ), "<span class='spam-comment-count'>" . number_format_i18n($num_comments->spam) . "</span>") $stati = array('all' => _nx_noop('All', 'All', 'comments'), 'moderated' => _n_noop('Pending <span class="count">(<span class="pending-count">%s</span>)</span>', 'Pending <span class="count">(<span class="pending-count">%s</span>)</span>'), 'approved' => _n_noop('Approved', 'Approved'), 'spam' => _n_noop('Spam <span class="count">(<span class="spam-count">%s</span>)</span>', 'Spam <span class="count">(<span class="spam-count">%s</span>)</span>'), 'trash' => _n_noop('Trash <span class="count">(<span class="trash-count">%s</span>)</span>', 'Trash <span class="count">(<span class="trash-count">%s</span>)</span>')); if (!EMPTY_TRASH_DAYS) { unset($stati['trash']); } $link = 'edit-comments.php'; if (!empty($comment_type) && 'all' != $comment_type) { $link = add_query_arg('comment_type', $comment_type, $link); } foreach ($stati as $status => $label) { $class = $status == $comment_status ? ' class="current"' : ''; if (!isset($num_comments->{$status})) { $num_comments->{$status} = 10; } $link = add_query_arg('comment_status', $status, $link); if ($post_id) { $link = add_query_arg('p', absint($post_id), $link); } /* // I toyed with this, but decided against it. Leaving it in here in case anyone thinks it is a good idea. ~ Mark if ( !empty( $_REQUEST['s'] ) ) $link = add_query_arg( 's', esc_attr( stripslashes( $_REQUEST['s'] ) ), $link ); */ $status_links[$status] = "<a href='{$link}'{$class}>" . sprintf(translate_nooped_plural($label, $num_comments->{$status}), number_format_i18n($num_comments->{$status})) . '</a>'; } $status_links = apply_filters('comment_status_links', $status_links); return $status_links; }
function nxt_dashboard_right_now() { global $nxt_registered_sidebars; $num_posts = nxt_count_posts('post'); $num_pages = nxt_count_posts('page'); $num_cats = nxt_count_terms('category'); $num_tags = nxt_count_terms('post_tag'); $num_comm = nxt_count_comments(); echo "\n\t" . '<div class="table table_content">'; echo "\n\t" . '<p class="sub">' . __('Content') . '</p>' . "\n\t" . '<table>'; echo "\n\t" . '<tr class="first">'; // Posts $num = number_format_i18n($num_posts->publish); $text = _n('Post', 'Posts', intval($num_posts->publish)); if (current_user_can('edit_posts')) { $num = "<a href='edit.php'>{$num}</a>"; $text = "<a href='edit.php'>{$text}</a>"; } echo '<td class="first b b-posts">' . $num . '</td>'; echo '<td class="t posts">' . $text . '</td>'; echo '</tr><tr>'; /* TODO: Show status breakdown on hover if ( $can_edit_pages && !empty($num_pages->publish) ) { // how many pages is not exposed in feeds. Don't show if !current_user_can $post_type_texts[] = '<a href="edit-pages.php">'.sprintf( _n( '%s page', '%s pages', $num_pages->publish ), number_format_i18n( $num_pages->publish ) ).'</a>'; } if ( $can_edit_posts && !empty($num_posts->draft) ) { $post_type_texts[] = '<a href="edit.php?post_status=draft">'.sprintf( _n( '%s draft', '%s drafts', $num_posts->draft ), number_format_i18n( $num_posts->draft ) ).'</a>'; } if ( $can_edit_posts && !empty($num_posts->future) ) { $post_type_texts[] = '<a href="edit.php?post_status=future">'.sprintf( _n( '%s scheduled post', '%s scheduled posts', $num_posts->future ), number_format_i18n( $num_posts->future ) ).'</a>'; } if ( current_user_can('publish_posts') && !empty($num_posts->pending) ) { $pending_text = sprintf( _n( 'There is <a href="%1$s">%2$s post</a> pending your review.', 'There are <a href="%1$s">%2$s posts</a> pending your review.', $num_posts->pending ), 'edit.php?post_status=pending', number_format_i18n( $num_posts->pending ) ); } else { $pending_text = ''; } */ // Pages $num = number_format_i18n($num_pages->publish); $text = _n('Page', 'Pages', $num_pages->publish); if (current_user_can('edit_pages')) { $num = "<a href='edit.php?post_type=page'>{$num}</a>"; $text = "<a href='edit.php?post_type=page'>{$text}</a>"; } echo '<td class="first b b_pages">' . $num . '</td>'; echo '<td class="t pages">' . $text . '</td>'; echo '</tr><tr>'; // Categories $num = number_format_i18n($num_cats); $text = _n('Category', 'Categories', $num_cats); if (current_user_can('manage_categories')) { $num = "<a href='edit-tags.php?taxonomy=category'>{$num}</a>"; $text = "<a href='edit-tags.php?taxonomy=category'>{$text}</a>"; } echo '<td class="first b b-cats">' . $num . '</td>'; echo '<td class="t cats">' . $text . '</td>'; echo '</tr><tr>'; // Tags $num = number_format_i18n($num_tags); $text = _n('Tag', 'Tags', $num_tags); if (current_user_can('manage_categories')) { $num = "<a href='edit-tags.php'>{$num}</a>"; $text = "<a href='edit-tags.php'>{$text}</a>"; } echo '<td class="first b b-tags">' . $num . '</td>'; echo '<td class="t tags">' . $text . '</td>'; echo "</tr>"; do_action('right_now_content_table_end'); echo "\n\t</table>\n\t</div>"; echo "\n\t" . '<div class="table table_discussion">'; echo "\n\t" . '<p class="sub">' . __('Discussion') . '</p>' . "\n\t" . '<table>'; echo "\n\t" . '<tr class="first">'; // Total Comments $num = '<span class="total-count">' . number_format_i18n($num_comm->total_comments) . '</span>'; $text = _n('Comment', 'Comments', $num_comm->total_comments); if (current_user_can('moderate_comments')) { $num = '<a href="edit-comments.php">' . $num . '</a>'; $text = '<a href="edit-comments.php">' . $text . '</a>'; } echo '<td class="b b-comments">' . $num . '</td>'; echo '<td class="last t comments">' . $text . '</td>'; echo '</tr><tr>'; // Approved Comments $num = '<span class="approved-count">' . number_format_i18n($num_comm->approved) . '</span>'; $text = _nx('Approved', 'Approved', $num_comm->approved, 'Right Now'); if (current_user_can('moderate_comments')) { $num = "<a href='edit-comments.php?comment_status=approved'>{$num}</a>"; $text = "<a class='approved' href='edit-comments.php?comment_status=approved'>{$text}</a>"; } echo '<td class="b b_approved">' . $num . '</td>'; echo '<td class="last t">' . $text . '</td>'; echo "</tr>\n\t<tr>"; // Pending Comments $num = '<span class="pending-count">' . number_format_i18n($num_comm->moderated) . '</span>'; $text = _n('Pending', 'Pending', $num_comm->moderated); if (current_user_can('moderate_comments')) { $num = "<a href='edit-comments.php?comment_status=moderated'>{$num}</a>"; $text = "<a class='waiting' href='edit-comments.php?comment_status=moderated'>{$text}</a>"; } echo '<td class="b b-waiting">' . $num . '</td>'; echo '<td class="last t">' . $text . '</td>'; echo "</tr>\n\t<tr>"; // Spam Comments $num = number_format_i18n($num_comm->spam); $text = _nx('Spam', 'Spam', $num_comm->spam, 'comment'); if (current_user_can('moderate_comments')) { $num = "<a href='edit-comments.php?comment_status=spam'><span class='spam-count'>{$num}</span></a>"; $text = "<a class='spam' href='edit-comments.php?comment_status=spam'>{$text}</a>"; } echo '<td class="b b-spam">' . $num . '</td>'; echo '<td class="last t">' . $text . '</td>'; echo "</tr>"; do_action('right_now_table_end'); do_action('right_now_discussion_table_end'); echo "\n\t</table>\n\t</div>"; echo "\n\t" . '<div class="versions">'; $ct = current_theme_info(); echo "\n\t<p>"; if (empty($ct->stylesheet_dir)) { if (!is_multisite() || is_super_admin()) { echo '<span class="error-message">' . __('ERROR: The themes directory is either empty or doesn’t exist. Please check your installation.') . '</span>'; } } elseif (!empty($nxt_registered_sidebars)) { $sidebars_widgets = nxt_get_sidebars_widgets(); $num_widgets = 0; foreach ((array) $sidebars_widgets as $k => $v) { if ('nxt_inactive_widgets' == $k || 'orphaned_widgets' == substr($k, 0, 16)) { continue; } if (is_array($v)) { $num_widgets = $num_widgets + count($v); } } $num = number_format_i18n($num_widgets); $switch_themes = $ct->title; if (current_user_can('switch_themes')) { $switch_themes = '<a href="themes.php">' . $switch_themes . '</a>'; } if (current_user_can('edit_theme_options')) { printf(_n('Theme <span class="b">%1$s</span> with <span class="b"><a href="widgets.php">%2$s Widget</a></span>', 'Theme <span class="b">%1$s</span> with <span class="b"><a href="widgets.php">%2$s Widgets</a></span>', $num_widgets), $switch_themes, $num); } else { printf(_n('Theme <span class="b">%1$s</span> with <span class="b">%2$s Widget</span>', 'Theme <span class="b">%1$s</span> with <span class="b">%2$s Widgets</span>', $num_widgets), $switch_themes, $num); } } else { if (current_user_can('switch_themes')) { printf(__('Theme <span class="b"><a href="themes.php">%1$s</a></span>'), $ct->title); } else { printf(__('Theme <span class="b">%1$s</span>'), $ct->title); } } echo '</p>'; // Check if search engines are blocked. if (!is_network_admin() && !is_user_admin() && current_user_can('manage_options') && '1' != get_option('blog_public')) { $title = apply_filters('privacy_on_link_title', __('Your site is asking search engines not to index its content')); $content = apply_filters('privacy_on_link_text', __('Search Engines Blocked')); echo "<p><a href='options-privacy.php' title='{$title}'>{$content}</a></p>"; } update_right_now_message(); echo "\n\t" . '<br class="clear" /></div>'; do_action('rightnow_end'); do_action('activity_box_end'); }
/* translators: add new links */ $submenu['link-manager.php'][10] = array(_x('Add New', 'link'), 'manage_links', 'link-add.php'); $submenu['link-manager.php'][15] = array(__('Link Categories'), 'manage_categories', 'edit-tags.php?taxonomy=link_category'); $menu[20] = array(__('Pages'), 'edit_pages', 'edit.php?post_type=page', '', 'menu-top menu-icon-page', 'menu-pages', 'div'); $submenu['edit.php?post_type=page'][5] = array(__('All Pages'), 'edit_pages', 'edit.php?post_type=page'); /* translators: add new page */ $submenu['edit.php?post_type=page'][10] = array(_x('Add New', 'page'), 'edit_pages', 'post-new.php?post_type=page'); $i = 15; foreach (get_taxonomies(array(), 'objects') as $tax) { if (!$tax->show_ui || !in_array('page', (array) $tax->object_type, true)) { continue; } $submenu['edit.php?post_type=page'][$i++] = array(esc_attr($tax->labels->menu_name), $tax->cap->manage_terms, 'edit-tags.php?taxonomy=' . $tax->name . '&post_type=page'); } unset($tax); $awaiting_mod = nxt_count_comments(); $awaiting_mod = $awaiting_mod->moderated; $menu[25] = array(sprintf(__('Comments %s'), "<span class='awaiting-mod count-{$awaiting_mod}'><span class='pending-count'>" . number_format_i18n($awaiting_mod) . "</span></span>"), 'edit_posts', 'edit-comments.php', '', 'menu-top menu-icon-comments', 'menu-comments', 'div'); unset($awaiting_mod); $submenu['edit-comments.php'][0] = array(__('All Comments'), 'edit_posts', 'edit-comments.php'); $_nxt_last_object_menu = 25; // The index of the last top-level menu in the object menu group foreach ((array) get_post_types(array('show_ui' => true, '_builtin' => false, 'show_in_menu' => true)) as $ptype) { $ptype_obj = get_post_type_object($ptype); // Check if it should be a submenu. if ($ptype_obj->show_in_menu !== true) { continue; } $ptype_menu_position = is_int($ptype_obj->menu_position) ? $ptype_obj->menu_position : ++$_nxt_last_object_menu; // If we're to use $_nxt_last_object_menu, increment it first. $ptype_for_id = sanitize_html_class($ptype);
function woo_presstrends() { if (!defined('WOO_PRESSTRENDS_THEMEKEY')) { return; } // Add your PressTrends API Keys $api_key = 'ypvilflyjb7yyht8as1u2k0no3rxbgl2p4a9'; $auth = WOO_PRESSTRENDS_THEMEKEY; // Check if we have cached data. $data = get_transient('woo_presstrends_data'); if (!$data || $data == '') { // Don't edit below $api_base = 'http://api.presstrends.io/index.php/api/sites/add/auth/'; // Run setup $url = $api_base . $auth . '/api/' . $api_key . '/'; $data = array(); $count_posts = nxt_count_posts(); $comments_count = nxt_count_comments(); $theme_data = get_theme_data(get_template_directory() . '/style.css'); $plugin_count = count(get_option('active_plugins')); $data['url'] = stripslashes(str_replace(array('http://', '/', ':'), '', site_url())); $data['posts'] = $count_posts->publish; $data['comments'] = $comments_count->total_comments; $data['theme_version'] = $theme_data['Version']; $data['theme_name'] = str_replace(' ', '', get_bloginfo('name')); $data['plugins'] = $plugin_count; foreach ($data as $k => $v) { $url .= $k . '/' . $v . '/'; } // Perform the remote request. $response = nxt_remote_get($url); if (is_nxt_error($response) || nxt_remote_retrieve_response_code($response) != 200) { // Silence is golden. } else { set_transient('woo_presstrends_data', $data, 60 * 60 * 24); } } }
function woo_presstrends() { if (!defined('WOO_PRESSTRENDS_THEMEKEY')) { return; } // Add your PressTrends API Keys $api_key = 'ypvilflyjb7yyht8as1u2k0no3rxbgl2p4a9'; $auth = WOO_PRESSTRENDS_THEMEKEY; // Check if we have cached data. $data = get_transient('woo_presstrends_data'); if (!$data || $data == '') { global $nxtdb; // Don't edit below $api_base = 'http://api.presstrends.io/index.php/api/sites/add/auth/'; // Run setup $url = $api_base . $auth . '/api/' . $api_key . '/'; $data = array(); $count_posts = nxt_count_posts(); $count_pages = nxt_count_posts('page'); $comments_count = nxt_count_comments(); $theme_data = get_theme_data(get_template_directory() . '/style.css'); $plugin_count = count(get_option('active_plugins')); $data['url'] = stripslashes(str_replace(array('http://', '/', ':'), '', site_url())); $data['posts'] = $count_posts->publish; $data['comments'] = $comments_count->total_comments; $data['theme_version'] = $theme_data['Version']; $data['theme_name'] = $theme_data['Name']; $data['site_name'] = str_replace(' ', '', get_bloginfo('name')); $data['plugins'] = $plugin_count; $all_plugins = get_plugins(); $plugin_name = ''; foreach ($all_plugins as $plugin_file => $plugin_data) { $plugin_name .= $plugin_data['Name']; $plugin_name .= '&'; } $posts_with_comments = $nxtdb->get_var("SELECT COUNT(*) FROM {$nxtdb->prefix}posts WHERE post_type='post' AND comment_count > 0"); $comments_to_posts = number_format($posts_with_comments / $count_posts->publish * 100, 0, '.', ''); $pingback_result = $nxtdb->get_var('SELECT COUNT(comment_ID) FROM ' . $nxtdb->comments . ' WHERE comment_type = "pingback"'); $data['posts'] = $count_posts->publish; $data['pages'] = $count_pages->publish; $data['comments'] = $comments_count->total_comments; $data['approved'] = $comments_count->approved; $data['spam'] = $comments_count->spam; $data['pingbacks'] = $pingback_result; $data['post_conversion'] = $comments_to_posts; $data['plugin'] = urlencode($plugin_name); $data['nxtversion'] = get_bloginfo('version'); foreach ($data as $k => $v) { $url .= $k . '/' . $v . '/'; } // Perform the remote request. $response = nxt_remote_get($url); if (is_nxt_error($response) || nxt_remote_retrieve_response_code($response) != 200) { // Silence is golden. } else { set_transient('woo_presstrends_data', $data, 60 * 60 * 24); } } }