예제 #1
0
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&#8217;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');
}
 function get_views()
 {
     global $post_type_object, $locked_post_status, $avail_post_stati;
     $post_type = $post_type_object->name;
     if (!empty($locked_post_status)) {
         return array();
     }
     $status_links = array();
     $num_posts = nxt_count_posts($post_type, 'readable');
     $class = '';
     $allposts = '';
     $current_user_id = get_current_user_id();
     if ($this->user_posts_count) {
         if (isset($_GET['author']) && $_GET['author'] == $current_user_id) {
             $class = ' class="current"';
         }
         $status_links['mine'] = "<a href='edit.php?post_type={$post_type}&author={$current_user_id}'{$class}>" . sprintf(_nx('Mine <span class="count">(%s)</span>', 'Mine <span class="count">(%s)</span>', $this->user_posts_count, 'posts'), number_format_i18n($this->user_posts_count)) . '</a>';
         $allposts = '&all_posts=1';
     }
     $total_posts = array_sum((array) $num_posts);
     // Subtract post types that are not included in the admin all list.
     foreach (get_post_stati(array('show_in_admin_all_list' => false)) as $state) {
         $total_posts -= $num_posts->{$state};
     }
     $class = empty($class) && empty($_REQUEST['post_status']) && empty($_REQUEST['show_sticky']) ? ' class="current"' : '';
     $status_links['all'] = "<a href='edit.php?post_type={$post_type}{$allposts}'{$class}>" . sprintf(_nx('All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_posts, 'posts'), number_format_i18n($total_posts)) . '</a>';
     foreach (get_post_stati(array('show_in_admin_status_list' => true), 'objects') as $status) {
         $class = '';
         $status_name = $status->name;
         if (!in_array($status_name, $avail_post_stati)) {
             continue;
         }
         if (empty($num_posts->{$status_name})) {
             continue;
         }
         if (isset($_REQUEST['post_status']) && $status_name == $_REQUEST['post_status']) {
             $class = ' class="current"';
         }
         $status_links[$status_name] = "<a href='edit.php?post_status={$status_name}&amp;post_type={$post_type}'{$class}>" . sprintf(translate_nooped_plural($status->label_count, $num_posts->{$status_name}), number_format_i18n($num_posts->{$status_name})) . '</a>';
     }
     if (!empty($this->sticky_posts_count)) {
         $class = !empty($_REQUEST['show_sticky']) ? ' class="current"' : '';
         $sticky_link = array('sticky' => "<a href='edit.php?post_type={$post_type}&amp;show_sticky=1'{$class}>" . sprintf(_nx('Sticky <span class="count">(%s)</span>', 'Sticky <span class="count">(%s)</span>', $this->sticky_posts_count, 'posts'), number_format_i18n($this->sticky_posts_count)) . '</a>');
         // Sticky comes after Publish, or if not listed, after All.
         $split = 1 + array_search(isset($status_links['publish']) ? 'publish' : 'all', array_keys($status_links));
         $status_links = array_merge(array_slice($status_links, 0, $split), $sticky_link, array_slice($status_links, $split));
     }
     return $status_links;
 }
예제 #3
0
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);
        }
    }
}
예제 #4
0
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);
        }
    }
}
예제 #5
0
파일: post.php 프로젝트: nxtclass/NXTClass
/**
 * Get all the possible statuses for a post_type
 *
 * @since 2.5.0
 *
 * @param string $type The post_type you want the statuses for
 * @return array As array of all the statuses for the supplied post type
 */
function get_available_post_statuses($type = 'post')
{
    $stati = nxt_count_posts($type);
    return array_keys(get_object_vars($stati));
}