function prepare_items()
 {
     global $taxonomy;
     $tags_per_page = $this->get_items_per_page('edit_' . $taxonomy . '_per_page');
     if ('post_tag' == $taxonomy) {
         $tags_per_page = apply_filters('edit_tags_per_page', $tags_per_page);
         $tags_per_page = apply_filters('tagsperpage', $tags_per_page);
         // Old filter
     } elseif ('category' == $taxonomy) {
         $tags_per_page = apply_filters('edit_categories_per_page', $tags_per_page);
         // Old filter
     }
     $search = !empty($_REQUEST['s']) ? trim(stripslashes($_REQUEST['s'])) : '';
     $args = array('search' => $search, 'page' => $this->get_pagenum(), 'number' => $tags_per_page);
     if (!empty($_REQUEST['orderby'])) {
         $args['orderby'] = trim(stripslashes($_REQUEST['orderby']));
     }
     if (!empty($_REQUEST['order'])) {
         $args['order'] = trim(stripslashes($_REQUEST['order']));
     }
     $this->callback_args = $args;
     $this->set_pagination_args(array('total_items' => nxt_count_terms($taxonomy, compact('search')), 'per_page' => $tags_per_page));
 }
예제 #2
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');
}
예제 #3
0
/**
 * Displays a metabox for a taxonomy menu item.
 *
 * @since 3.0.0
 *
 * @param string $object Not used.
 * @param string $taxonomy The taxonomy object.
 */
function nxt_nav_menu_item_taxonomy_meta_box($object, $taxonomy)
{
    global $nav_menu_selected_id;
    $taxonomy_name = $taxonomy['args']->name;
    // paginate browsing for large numbers of objects
    $per_page = 50;
    $pagenum = isset($_REQUEST[$taxonomy_name . '-tab']) && isset($_REQUEST['paged']) ? absint($_REQUEST['paged']) : 1;
    $offset = 0 < $pagenum ? $per_page * ($pagenum - 1) : 0;
    $args = array('child_of' => 0, 'exclude' => '', 'hide_empty' => false, 'hierarchical' => 1, 'include' => '', 'include_last_update_time' => false, 'number' => $per_page, 'offset' => $offset, 'order' => 'ASC', 'orderby' => 'name', 'pad_counts' => false);
    $terms = get_terms($taxonomy_name, $args);
    if (!$terms || is_nxt_error($terms)) {
        echo '<p>' . __('No items.') . '</p>';
        return;
    }
    $num_pages = ceil(nxt_count_terms($taxonomy_name, array_merge($args, array('number' => '', 'offset' => ''))) / $per_page);
    $page_links = paginate_links(array('base' => add_query_arg(array($taxonomy_name . '-tab' => 'all', 'paged' => '%#%', 'item-type' => 'taxonomy', 'item-object' => $taxonomy_name)), 'format' => '', 'prev_text' => __('&laquo;'), 'next_text' => __('&raquo;'), 'total' => $num_pages, 'current' => $pagenum));
    $db_fields = false;
    if (is_taxonomy_hierarchical($taxonomy_name)) {
        $db_fields = array('parent' => 'parent', 'id' => 'term_id');
    }
    $walker = new Walker_Nav_Menu_Checklist($db_fields);
    $current_tab = 'most-used';
    if (isset($_REQUEST[$taxonomy_name . '-tab']) && in_array($_REQUEST[$taxonomy_name . '-tab'], array('all', 'most-used', 'search'))) {
        $current_tab = $_REQUEST[$taxonomy_name . '-tab'];
    }
    if (!empty($_REQUEST['quick-search-taxonomy-' . $taxonomy_name])) {
        $current_tab = 'search';
    }
    $removed_args = array('action', 'customlink-tab', 'edit-menu-item', 'menu-item', 'page-tab', '_nxtnonce');
    ?>
	<div id="taxonomy-<?php 
    echo $taxonomy_name;
    ?>
" class="taxonomydiv">
		<ul id="taxonomy-<?php 
    echo $taxonomy_name;
    ?>
-tabs" class="taxonomy-tabs add-menu-item-tabs">
			<li <?php 
    echo 'most-used' == $current_tab ? ' class="tabs"' : '';
    ?>
><a class="nav-tab-link" href="<?php 
    if ($nav_menu_selected_id) {
        echo esc_url(add_query_arg($taxonomy_name . '-tab', 'most-used', remove_query_arg($removed_args)));
    }
    ?>
#tabs-panel-<?php 
    echo $taxonomy_name;
    ?>
-pop"><?php 
    _e('Most Used');
    ?>
</a></li>
			<li <?php 
    echo 'all' == $current_tab ? ' class="tabs"' : '';
    ?>
><a class="nav-tab-link" href="<?php 
    if ($nav_menu_selected_id) {
        echo esc_url(add_query_arg($taxonomy_name . '-tab', 'all', remove_query_arg($removed_args)));
    }
    ?>
#tabs-panel-<?php 
    echo $taxonomy_name;
    ?>
-all"><?php 
    _e('View All');
    ?>
</a></li>
			<li <?php 
    echo 'search' == $current_tab ? ' class="tabs"' : '';
    ?>
><a class="nav-tab-link" href="<?php 
    if ($nav_menu_selected_id) {
        echo esc_url(add_query_arg($taxonomy_name . '-tab', 'search', remove_query_arg($removed_args)));
    }
    ?>
#tabs-panel-search-taxonomy-<?php 
    echo $taxonomy_name;
    ?>
"><?php 
    _e('Search');
    ?>
</a></li>
		</ul>

		<div id="tabs-panel-<?php 
    echo $taxonomy_name;
    ?>
-pop" class="tabs-panel <?php 
    echo 'most-used' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive';
    ?>
">
			<ul id="<?php 
    echo $taxonomy_name;
    ?>
checklist-pop" class="categorychecklist form-no-clear" >
				<?php 
    $popular_terms = get_terms($taxonomy_name, array('orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false));
    $args['walker'] = $walker;
    echo walk_nav_menu_tree(array_map('nxt_setup_nav_menu_item', $popular_terms), 0, (object) $args);
    ?>
			</ul>
		</div><!-- /.tabs-panel -->

		<div id="tabs-panel-<?php 
    echo $taxonomy_name;
    ?>
-all" class="tabs-panel tabs-panel-view-all <?php 
    echo 'all' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive';
    ?>
">
			<?php 
    if (!empty($page_links)) {
        ?>
				<div class="add-menu-item-pagelinks">
					<?php 
        echo $page_links;
        ?>
				</div>
			<?php 
    }
    ?>
			<ul id="<?php 
    echo $taxonomy_name;
    ?>
checklist" class="list:<?php 
    echo $taxonomy_name;
    ?>
 categorychecklist form-no-clear">
				<?php 
    $args['walker'] = $walker;
    echo walk_nav_menu_tree(array_map('nxt_setup_nav_menu_item', $terms), 0, (object) $args);
    ?>
			</ul>
			<?php 
    if (!empty($page_links)) {
        ?>
				<div class="add-menu-item-pagelinks">
					<?php 
        echo $page_links;
        ?>
				</div>
			<?php 
    }
    ?>
		</div><!-- /.tabs-panel -->

		<div class="tabs-panel <?php 
    echo 'search' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive';
    ?>
" id="tabs-panel-search-taxonomy-<?php 
    echo $taxonomy_name;
    ?>
">
			<?php 
    if (isset($_REQUEST['quick-search-taxonomy-' . $taxonomy_name])) {
        $searched = esc_attr($_REQUEST['quick-search-taxonomy-' . $taxonomy_name]);
        $search_results = get_terms($taxonomy_name, array('name__like' => $searched, 'fields' => 'all', 'orderby' => 'count', 'order' => 'DESC', 'hierarchical' => false));
    } else {
        $searched = '';
        $search_results = array();
    }
    ?>
			<p class="quick-search-wrap">
				<input type="text" class="quick-search input-with-default-title" title="<?php 
    esc_attr_e('Search');
    ?>
" value="<?php 
    echo $searched;
    ?>
" name="quick-search-taxonomy-<?php 
    echo $taxonomy_name;
    ?>
" />
				<img class="waiting" src="<?php 
    echo esc_url(admin_url('images/nxtspin_light.gif'));
    ?>
" alt="" />
				<?php 
    submit_button(__('Search'), 'quick-search-submit button-secondary hide-if-js', 'submit', false, array('id' => 'submit-quick-search-taxonomy-' . $taxonomy_name));
    ?>
			</p>

			<ul id="<?php 
    echo $taxonomy_name;
    ?>
-search-checklist" class="list:<?php 
    echo $taxonomy_name;
    ?>
 categorychecklist form-no-clear">
			<?php 
    if (!empty($search_results) && !is_nxt_error($search_results)) {
        ?>
				<?php 
        $args['walker'] = $walker;
        echo walk_nav_menu_tree(array_map('nxt_setup_nav_menu_item', $search_results), 0, (object) $args);
        ?>
			<?php 
    } elseif (is_nxt_error($search_results)) {
        ?>
				<li><?php 
        echo $search_results->get_error_message();
        ?>
</li>
			<?php 
    } elseif (!empty($searched)) {
        ?>
				<li><?php 
        _e('No results found.');
        ?>
</li>
			<?php 
    }
    ?>
			</ul>
		</div><!-- /.tabs-panel -->

		<p class="button-controls">
			<span class="list-controls">
				<a href="<?php 
    echo esc_url(add_query_arg(array($taxonomy_name . '-tab' => 'all', 'selectall' => 1), remove_query_arg($removed_args)));
    ?>
#taxonomy-<?php 
    echo $taxonomy_name;
    ?>
" class="select-all"><?php 
    _e('Select All');
    ?>
</a>
			</span>

			<span class="add-to-menu">
				<img class="waiting" src="<?php 
    echo esc_url(admin_url('images/nxtspin_light.gif'));
    ?>
" alt="" />
				<input type="submit"<?php 
    disabled($nav_menu_selected_id, 0);
    ?>
 class="button-secondary submit-add-to-menu" value="<?php 
    esc_attr_e('Add to Menu');
    ?>
" name="add-taxonomy-menu-item" id="submit-taxonomy-<?php 
    echo $taxonomy_name;
    ?>
" />
			</span>
		</p>

	</div><!-- /.taxonomydiv -->
	<?php 
}