function custom_dashboard_display_stats($widget) { ?> <p>Les principales valeurs statistiques de l'intégration BF QUOTES</p> <div class="inside"> <?php // global $wpdb; /* === JUST AS REMINDER post_type => product_for_sale taxonomy => product_for_sale_genre taxonomy => product_for_sale_author taxonomy => product_for_sale_kw */ $num_posts_bf_quotes_manager = wp_count_posts('bf_quotes_manager'); // Main figures for product_for_sale $num_product_for_sale = $num_posts_product_for_sale->publish; // nb for Author(s) $num_cats_bf_quotes_manager_author = wp_count_terms('bf_quotes_manager_author'); // nb for Flavor(s) $num_tags_bf_quotes_manager_flavor = wp_count_terms('bf_quotes_manager_flavor'); ?> <h4><strong>Les chiffres-clés</strong></h4> <ul> <li>Nombre d' Auteur(s) : <b><?php echo '' . $num_cats_bf_quotes_manager_author . ''; ?> </b></li> <li>Nombre de Saveur(s) : <b><?php echo '' . $num_tags_bf_quotes_manager_flavor . ''; ?> </b></li> </ul> <h4><strong>Les dernières citations enregistrées</strong></h4> <?php /* LAST POSTS */ $args = array('offset' => 0, 'orderby' => 'post_date', 'order' => 'DESC', 'numberposts' => '3', 'post_status' => 'publish', 'post_type' => 'bf_quotes_manager'); $recent_posts = wp_get_recent_posts($args); /* debug only */ // print_r($recent_posts); foreach ($recent_posts as $recent) { setup_postdata(get_post($recent['ID'])); // Output echo '<ul><li><a class="rsswidget" href="' . get_permalink($recent['ID']) . '" title="' . esc_attr(get_the_title($recent['ID'])) . '">' . get_the_title($recent['ID']) . '</a> <span class="rss-date">' . get_the_time('j F Y', $recent['ID']) . '</span><div class="rssSummary">' . $recent['post_excerpt'] . '</div></li>'; } // EOL wp_reset_postdata(); ?> </div> <?php }
/** * Display a javascript collection for autocompletion script ! * * @return void * @author Amaury Balmer */ public static function ajax_local_tags() { status_header(200); // Send good header HTTP header("Content-Type: application/json; charset=" . get_bloginfo('charset')); $taxonomy = 'post_tag'; if (isset($_REQUEST['taxonomy']) && taxonomy_exists($_REQUEST['taxonomy'])) { $taxonomy = $_REQUEST['taxonomy']; } if ((int) wp_count_terms($taxonomy, 'ignore_empty=false') == 0) { // No tags to suggest json_encode(array()); exit; } // Prepare search $search = isset($_GET['term']) ? trim(stripslashes($_GET['term'])) : ''; // Get all terms, or filter with search $terms = SimpleTags_Admin::getTermsForAjax($taxonomy, $search); if (empty($terms) || $terms == false) { json_encode(array()); exit; } // Format terms $results = array(); foreach ((array) $terms as $term) { $term->name = stripslashes($term->name); $term->name = str_replace(array("\r\n", "\r", "\n"), '', $term->name); $results[] = array('id' => $term->term_id, 'label' => $term->name, 'value' => $term->name); } echo json_encode($results); exit; }
/** * Show the tag cloud */ public function show_tag_filter($shortcode_atts) { if (isset($shortcode_atts['show_tags']) && ($shortcode_atts['show_tags'] === false || (string) $shortcode_atts['show_tags'] == 'false')) { return; } if (wp_count_terms('job_listing_tag') == 0) { return; } wp_register_script('wp-job-manager-ajax-tag-filters', JOB_MANAGER_TAGS_PLUGIN_URL . '/assets/js/tag-filter.js', array('jquery'), '1.0', true); $args_data = array('orderby' => 'count', 'order' => 'DESC'); $jobs_tags_data = get_terms('job_listing_tag', $args_data); $queried_object = get_queried_object(); foreach ($jobs_tags_data as $key => $jobs_tag_data) { if ($jobs_tag_data->count > 1) { $jobs_txt = 'jobs'; $font_size = 2; } else { $jobs_txt = 'job'; $font_size = 1; } //if($queried_object->term_id == $jobs_tag_data->term_id){ $active_class = 'activee'; } $anchor_data[] = '<a href="#" id="test_' . $key . '" "class="tag-link-' . $jobs_tag_data->term_id . ' ' . $active_class . ' show_bg_tag" title="' . $jobs_tag_data->count . ' ' . $jobs_txt . '" style="font-size: ' . $font_size . 'em;">' . $jobs_tag_data->name . '</a>'; } $anchor_tag_data = array('anchor_tag_data' => $anchor_data); //anchor_tag_data wp_localize_script('wp-job-manager-ajax-tag-filters', 'anchor_tag_data_object', $anchor_tag_data); wp_enqueue_script('wp-job-manager-ajax-tag-filters', JOB_MANAGER_TAGS_PLUGIN_URL . '/assets/js/tag-filter.js', array('jquery'), '1.0', true); echo '<div class="filter_wide filter_by_tag">' . __('Filter by tag:', 'wp-job-manager-tags') . ' <span class="filter_by_tag_cloud"></span></div>'; }
/** * Generate the content of the widget. * * @param array args The array of form elements * @param array instance The current instance of the widget */ public function widget_content($args, $instance) { extract($args, EXTR_SKIP); extract($instance); $count = (array) wp_count_posts('movie'); $count = array('movies' => $count['publish'], 'imported' => $count['import-draft'], 'queued' => $count['import-queued'], 'draft' => $count['draft'], 'total' => 0); $count['total'] = array_sum($count); $count['collections'] = wp_count_terms('collection'); $count['genres'] = wp_count_terms('genre'); $count['actors'] = wp_count_terms('actor'); $count = array_map('intval', $count); extract($count); $links = array(); $links['%total%'] = sprintf('<a href="%s">%s</a>', get_post_type_archive_link('movie'), sprintf(_n('<strong>1</strong> movie', '<strong>%d</strong> movies', $movies, 'wpmovielibrary'), $movies)); $links['%collections%'] = WPMOLY_Utils::get_taxonomy_permalink('collection', sprintf(_n('<strong>1</strong> collection', '<strong>%d</strong> collections', $collections, 'wpmovielibrary'), $collections)); $links['%genres%'] = WPMOLY_Utils::get_taxonomy_permalink('genre', sprintf(_n('<strong>1</strong> genre', '<strong>%d</strong> genres', $genres, 'wpmovielibrary'), $genres)); $links['%actors%'] = WPMOLY_Utils::get_taxonomy_permalink('actor', sprintf(_n('<strong>1</strong> actor', '<strong>%d</strong> actors', $actors, 'wpmovielibrary'), $actors)); $title = $before_title . apply_filters('widget_title', $title) . $after_title; $description = esc_attr($description); $format = wpautop(wp_kses($format, array('ul', 'ol', 'li', 'p', 'span', 'em', 'i', 'p', 'strong', 'b', 'br'))); $content = str_replace(array_keys($links), array_values($links), $format); $style = 'wpmoly-widget wpmoly-statistics'; $attributes = array('content' => $content, 'description' => $description, 'style' => $style); $html = WPMovieLibrary::render_template('statistics-widget/statistics.php', $attributes, $require = 'always'); return $before_widget . $title . $html . $after_widget; }
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' => wp_count_terms( $taxonomy, compact( 'search' ) ), 'per_page' => $tags_per_page, ) ); }
/** * Display a javascript collection for autocompletion script ! * * @return void * @author Amaury Balmer */ function ajaxLocalTags() { status_header(200); // Send good header HTTP header("Content-Type: text/plain; charset=" . get_bloginfo('charset')); $taxonomy = 'post_tag'; if (isset($_REQUEST['taxonomy']) && taxonomy_exists($_REQUEST['taxonomy'])) { $taxonomy = $_REQUEST['taxonomy']; } if ((int) wp_count_terms($taxonomy, 'ignore_empty=false') == 0) { // No tags to suggest exit; } // Prepare search $search = isset($_GET['q']) ? trim(stripslashes($_GET['q'])) : ''; // Get all terms, or filter with search $terms = $this->getTermsForAjax($taxonomy, $search); if (empty($terms) || $terms == false) { exit; } // Format terms foreach ((array) $terms as $term) { $term->name = stripslashes($term->name); $term->name = str_replace(array("\r\n", "\r", "\n"), '', $term->name); echo "{$term->term_id}|{$term->name}\n"; } exit; }
function wpmp_msma_overview($menu) { $base = get_option('home'); $post_count = wp_count_posts('post'); $page_count = wp_count_posts('page'); print "<p>"; printf(__ngettext("You have one post", "You have %d posts", $c = 0 + $post_count->publish, 'wpmp'), $c); print ' '; printf(__ngettext("and one page", "and %d pages", $c = 0 + $page_count->publish, 'wpmp'), $c); print ' ' . __("contained within", 'wpmp') . ' '; printf(__ngettext("one category", "%d categories", $c = 0 + wp_count_terms('category'), 'wpmp'), $c); print ' ' . __("and", 'wpmp') . ' '; printf(__ngettext("one tag", "%d tags", $c = 0 + wp_count_terms('post_tag'), 'wpmp'), $c); print ".</p>"; global $wpdb; $comments = $wpdb->get_results("SELECT count(*) as cnt FROM {$wpdb->comments} WHERE comment_approved='0'"); $comment_count = $comments[0]; printf("<p>" . __ngettext("You have one comment to moderate", "You have %d comments to moderate", $c = 0 + $comment_count->cnt, 'wpmp') . ".</p>", $c); print "<h3>" . __("Select an admin page:", 'wpmp') . "</h3>"; print "<p><ul>"; $not_first = false; foreach ($menu as $name => $link) { if ($name[0] != '_' && $not_first) { if (substr($link, 0, 7) != "http://" && substr($link, 0, 8) != "https://") { $link = $base . $link; } print "<li><a href='{$link}'>" . __("{$name}", 'wpmp') . "</a>"; } $not_first = true; } print "</ul></p>"; print "<p>" . sprintf(__("...or <a%s>return to the site</a>", 'wpmp'), " href='{$base}/'") . "</p>"; print "<p>" . __("A subset of the full WordPress administration is available through this mobile interface.", 'wpmp') . "</p>"; }
public function test_wp_insert_delete_term() { $taxonomy = 'wptests_tax'; register_taxonomy($taxonomy, 'post'); // a new unused term $term = rand_str(); $this->assertNull(term_exists($term)); $initial_count = wp_count_terms($taxonomy); $t = wp_insert_term($term, $taxonomy); $this->assertInternalType('array', $t); $this->assertNotWPError($t); $this->assertTrue($t['term_id'] > 0); $this->assertTrue($t['term_taxonomy_id'] > 0); $this->assertEquals($initial_count + 1, wp_count_terms($taxonomy)); // make sure the term exists $this->assertTrue(term_exists($term) > 0); $this->assertTrue(term_exists($t['term_id']) > 0); // now delete it add_filter('delete_term', array($this, 'deleted_term_cb'), 10, 5); $this->assertTrue(wp_delete_term($t['term_id'], $taxonomy)); remove_filter('delete_term', array($this, 'deleted_term_cb'), 10, 5); $this->assertNull(term_exists($term)); $this->assertNull(term_exists($t['term_id'])); $this->assertEquals($initial_count, wp_count_terms($taxonomy)); }
/** * Add Custom Post Types and Taxonomies to "At a Glance" Dashboard Widget * * Ref Link: http://wpsnipp.com/index.php/functions-php/include-custom-post-types-in-right-now-admin-dashboard-widget/ * http://wordpress.org/support/topic/dashboard-at-a-glance-custom-post-types * http://halfelf.org/2012/my-custom-posttypes-live-in-mu/ */ function seventeen_right_now_content_table_end() { $args = array('public' => true, '_builtin' => false); $output = 'object'; $operator = 'and'; $post_types = get_post_types($args, $output, $operator); foreach ($post_types as $post_type) { $num_posts = wp_count_posts($post_type->name); $num = number_format_i18n($num_posts->publish); $text = _n($post_type->labels->name, $post_type->labels->name, intval($num_posts->publish)); if (current_user_can('edit_posts')) { $cpt_name = $post_type->name; } echo '<li class="post-count ' . $post_type->name . '-count"><tr><a href="edit.php?post_type=' . $cpt_name . '"><td class="first b b-' . $post_type->name . '"></td>' . $num . ' <td class="t ' . $post_type->name . '">' . $text . '</td></a></tr></li>'; } $taxonomies = get_taxonomies($args, $output, $operator); foreach ($taxonomies as $taxonomy) { $num_terms = wp_count_terms($taxonomy->name); $num = number_format_i18n($num_terms); $text = _n($taxonomy->labels->name, $taxonomy->labels->name, intval($num_terms)); if (current_user_can('manage_categories')) { $cpt_tax = $taxonomy->name; } echo '<li class="taxonomy-count ' . $taxonomy->name . '-count"><tr><a href="edit-tags.php?taxonomy=' . $cpt_tax . '"><td class="first b b-' . $taxonomy->name . '"></td>' . $num . ' <td class="t ' . $taxonomy->name . '">' . $text . '</td></a></tr></li>'; } }
function wph_right_now_content_table_end() { $args = array('public' => true, '_builtin' => false); $output = 'object'; $operator = 'and'; $post_types = get_post_types($args, $output, $operator); foreach ($post_types as $post_type) { $num_posts = wp_count_posts($post_type->name); $num = number_format_i18n($num_posts->publish); $text = _n($post_type->labels->singular_name, $post_type->labels->name, intval($num_posts->publish)); if (current_user_can('edit_posts')) { $num = "<a href='edit.php?post_type={$post_type->name}'>{$num}</a>"; $text = "<a href='edit.php?post_type={$post_type->name}'>{$text}</a>"; } echo '<tr><td class="first num b b-' . $post_type->name . '">' . $num . '</td>'; echo '<td class="text t ' . $post_type->name . '">' . $text . '</td></tr>'; } $taxonomies = get_taxonomies($args, $output, $operator); foreach ($taxonomies as $taxonomy) { $num_terms = wp_count_terms($taxonomy->name); $num = number_format_i18n($num_terms); $text = _n($taxonomy->labels->singular_name, $taxonomy->labels->name, intval($num_terms)); if (current_user_can('manage_categories')) { $num = "<a href='edit-tags.php?taxonomy={$taxonomy->name}'>{$num}</a>"; $text = "<a href='edit-tags.php?taxonomy={$taxonomy->name}'>{$text}</a>"; } echo '<tr><td class="first b b-' . $taxonomy->name . '">' . $num . '</td>'; echo '<td class="t ' . $taxonomy->name . '">' . $text . '</td></tr>'; } }
/** * Display a span list for click tags * * @return void * @author Amaury Balmer */ public static function ajax_click_tags() { status_header(200); // Send good header HTTP header("Content-Type: text/html; charset=" . get_bloginfo('charset')); if ((int) wp_count_terms('post_tag', 'ignore_empty=false') == 0) { // No tags to suggest echo '<p>' . __('No terms in your WordPress database.', 'simpletags') . '</p>'; exit; } // Prepare search $search = isset($_GET['q']) ? trim(stripslashes($_GET['q'])) : ''; $post_id = isset($_GET['post_id']) ? intval($_GET['post_id']) : 0; // Order tags before selection (count-asc/count-desc/name-asc/name-desc/random) $order_click_tags = strtolower(SimpleTags_Plugin::get_option_value('order_click_tags')); $order_by = $order = ''; switch ($order_click_tags) { case 'count-asc': $order_by = 'tt.count'; $order = 'ASC'; break; case 'random': $order_by = 'RAND()'; $order = ''; break; case 'count-desc': $order_by = 'tt.count'; $order = 'DESC'; break; case 'name-desc': $order_by = 't.name'; $order = 'DESC'; break; default: // name-asc $order_by = 't.name'; $order = 'ASC'; break; } // Get all terms, or filter with search $terms = SimpleTags_Admin::getTermsForAjax('post_tag', $search, $order_by, $order); if (empty($terms) || $terms == false) { echo '<p>' . __('No results from your WordPress database.', 'simpletags') . '</p>'; exit; } // Get terms for current post $post_terms = array(); if ($post_id > 0) { $post_terms = wp_get_post_terms($post_id, 'post_tag', array('fields' => 'ids')); } foreach ((array) $terms as $term) { $class_current = in_array($term->term_id, $post_terms) ? 'used_term' : ''; echo '<span class="local ' . $class_current . '">' . esc_html(stripslashes($term->name)) . '</span>' . "\n"; } echo '<div class="clear"></div>'; exit; }
public function getTotalPages() { if (isset($this->options["id"])) { return 1; } $total = wp_count_terms($this->taxonomy); $per_page = $this->options["per_page"]; return round($total / $per_page, 0, PHP_ROUND_HALF_UP); }
function _load_default_entries() { if (wp_count_terms($this->_var) > 0) { return; } foreach ((array) $this->_default_terms as $term => $args) { wp_insert_term($term, $this->_var, $args); } }
function widget($args, $instance) { extract($args); $title = apply_filters('widget_title', $instance['title']); if (!empty($instance['title'])) { $title = $instance['title']; } else { $title = 'بىكەت ئۇچۇرى'; } $title = apply_filters('widget_title', $title, $instance, $this->id_base); $date = $instance['date']; echo $before_widget; echo $before_title . $title . $after_title; echo '<ul class="blog_info">'; if ($title) { } ?> <li>يازما سانى:<?php $count_posts = wp_count_posts(); echo $published_posts = $count_posts->publish; ?> </li> <li> بەت سانى:<?php $count_pages = wp_count_posts('page'); echo $page_posts = $count_pages->publish; ?> </li> <li>ئومۇمىي باھا:<?php $count_comments = get_comment_count(); echo $count_comments['approved']; ?> </li> <li>ئومۇمىي خەتكۈش:<?php echo $count_tags = wp_count_terms('post_tag'); ?> </li> <?php if (!empty($instance['date'])) { ?> <li>قۇرۇلغان ۋاقىت:<?php echo $date; ?> </li> <li>بىكەت يېشى:<?php echo floor((time() - strtotime("{$date}")) / 86400); ?> كۈن</li> <?php } ?> </ul> <?php echo $after_widget; }
/** * init_fields function. * * @access public * @return void */ public static function init_fields() { if (self::$fields) { return; } self::$fields = apply_filters('submit_job_form_fields', array('job' => array('job_title' => array('label' => __('Job title', 'wp-job-manager'), 'type' => 'text', 'required' => true, 'placeholder' => '', 'priority' => 1), 'job_location' => array('label' => __('Job location', 'wp-job-manager'), 'description' => __('Leave this blank if the job can be done from anywhere (i.e. telecommuting)', 'wp-job-manager'), 'type' => 'text', 'required' => false, 'placeholder' => __('e.g. "London, UK", "New York", "Houston, TX"', 'wp-job-manager'), 'priority' => 2), 'job_type' => array('label' => __('Job type', 'wp-job-manager'), 'type' => 'select', 'required' => true, 'options' => self::job_types(), 'placeholder' => '', 'priority' => 3), 'job_category' => array('label' => __('Job category', 'wp-job-manager'), 'type' => 'select', 'required' => true, 'options' => self::job_categories(), 'placeholder' => '', 'priority' => 4), 'job_description' => array('label' => __('Description', 'wp-job-manager'), 'type' => 'wp-editor', 'required' => true, 'placeholder' => '', 'priority' => 5), 'application' => array('label' => __('Application email/URL', 'wp-job-manager'), 'type' => 'text', 'required' => true, 'placeholder' => __('Enter an email address or website URL', 'wp-job-manager'), 'priority' => 6)), 'company' => array('company_name' => array('label' => __('Company name', 'wp-job-manager'), 'type' => 'text', 'required' => true, 'placeholder' => __('Enter the name of the company', 'wp-job-manager'), 'priority' => 1), 'company_website' => array('label' => __('Website', 'wp-job-manager'), 'type' => 'text', 'required' => false, 'placeholder' => __('http://', 'wp-job-manager'), 'priority' => 2), 'company_tagline' => array('label' => __('Tagline', 'wp-job-manager'), 'type' => 'text', 'required' => false, 'placeholder' => __('Briefly describe your company', 'wp-job-manager'), 'maxlength' => 64, 'priority' => 3), 'company_twitter' => array('label' => __('Twitter username', 'wp-job-manager'), 'type' => 'text', 'required' => false, 'placeholder' => __('@yourcompany', 'wp-job-manager'), 'priority' => 4), 'company_logo' => array('label' => __('Logo', 'wp-job-manager'), 'type' => 'file', 'required' => false, 'placeholder' => '', 'priority' => 5)))); if (!get_option('job_manager_enable_categories') || wp_count_terms('job_listing_category') == 0) { unset(self::$fields['job']['job_category']); } }
/** * Right now widget hooks/content */ function woocommerce_content_right_now() { global $woocommerce; ?> </table> <p class="sub woocommerce_sub"><?php _e('Shop Content', 'woocommerce'); ?> </p> <table> <tr> <td class="first b"><a href="edit.php?post_type=product"><?php $num_posts = wp_count_posts('product'); $num = number_format_i18n($num_posts->publish); echo $num; ?> </a></td> <td class="t"><a href="edit.php?post_type=product"><?php _e('Products', 'woocommerce'); ?> </a></td> </tr> <tr> <td class="first b"><a href="edit-tags.php?taxonomy=product_cat&post_type=product"><?php echo wp_count_terms('product_cat'); ?> </a></td> <td class="t"><a href="edit-tags.php?taxonomy=product_cat&post_type=product"><?php _e('Product Categories', 'woocommerce'); ?> </a></td> </tr> <tr> <td class="first b"><a href="edit-tags.php?taxonomy=product_tag&post_type=product"><?php echo wp_count_terms('product_tag'); ?> </a></td> <td class="t"><a href="edit-tags.php?taxonomy=product_tag&post_type=product"><?php _e('Product Tags', 'woocommerce'); ?> </a></td> </tr> <tr> <td class="first b"><a href="admin.php?page=woocommerce_attributes"><?php echo sizeof($woocommerce->get_attribute_taxonomies()); ?> </a></td> <td class="t"><a href="admin.php?page=woocommerce_attributes"><?php _e('Attribute taxonomies', 'woocommerce'); ?> </a></td> </tr> <?php }
/** * Show the tag cloud */ public function show_tag_filter($shortcode_atts) { if (isset($shortcode_atts['show_tags']) && ($shortcode_atts['show_tags'] === false || (string) $shortcode_atts['show_tags'] == 'false')) { return; } if (wp_count_terms('job_listing_tag') == 0) { return; } wp_enqueue_script('wp-job-manager-ajax-tag-filters', JOB_MANAGER_TAGS_PLUGIN_URL . '/assets/js/tag-filter.js', array('jquery'), '1.0', true); echo '<div class="filter_wide filter_by_tag">' . __('Filter by tag:', 'wp-job-manager-tags') . ' <span class="filter_by_tag_cloud"></span></div>'; }
function tags($args) { $args['get'] = 'all'; $tags = (array) get_tags($args); unset($args['offset']); $found = wp_count_terms('post_tag', $args); $tags_obj = array(); foreach ($tags as $tag) { $tags_obj[] = $this->format_taxonomy($tag, 'post_tag', 'display'); } return array('found' => $found, 'tags' => $tags_obj); }
/** * Display a span list for click tags * * @return void * @author Amaury Balmer */ function ajaxClickTags() { status_header(200); // Send good header HTTP header("Content-Type: text/html; charset=" . get_bloginfo('charset')); if ((int) wp_count_terms('post_tag', 'ignore_empty=false') == 0) { // No tags to suggest echo '<p>' . __('No terms in your WordPress database.', 'simpletags') . '</p>'; exit; } // Prepare search $search = isset($_GET['q']) ? trim(stripslashes($_GET['q'])) : ''; // Get options $options = get_option(STAGS_OPTIONS_NAME); // Order tags before selection (count-asc/count-desc/name-asc/name-desc/random) $options['order_click_tags'] = strtolower($options['order_click_tags']); $order_by = $order = ''; switch ($options['order_click_tags']) { case 'count-asc': $order_by = 'tt.count'; $order = 'ASC'; break; case 'random': $order_by = 'RAND()'; $order = ''; break; case 'count-desc': $order_by = 'tt.count'; $order = 'DESC'; break; case 'name-desc': $order_by = 't.name'; $order = 'DESC'; break; default: // name-asc $order_by = 't.name'; $order = 'ASC'; break; } // Get all terms, or filter with search $terms = $this->getTermsForAjax('post_tag', $search, $order_by, $order); if (empty($terms) || $terms == false) { echo '<p>' . __('No results from your WordPress database.', 'simpletags') . '</p>'; exit; } foreach ((array) $terms as $term) { echo '<span class="local">' . esc_html(stripslashes($term->name)) . '</span>' . "\n"; } echo '<div class="clear"></div>'; exit; }
protected function _get_content($args = array()) { $args = wp_parse_args($args, array('include' => '', 'taxonomy' => 'category', 'number' => 20, 'orderby' => 'name', 'order' => 'ASC', 'offset' => 0)); extract($args); if (!isset($paged)) { $paged = 1; } $terms = get_terms($taxonomy, array('number' => $number, 'hide_empty' => false, 'include' => $include, 'offset' => $number * ($paged - 1), 'orderby' => $orderby, 'order' => $order)); $total_items = wp_count_terms($taxonomy, array('hide_empty' => false)); $per_page = $number; $this->pagination = array('paged' => $offset + $paged, 'per_page' => $per_page, 'total_pages' => ceil($total_items / $per_page), 'total_items' => $total_items); return $terms; }
/** * Add custom taxo on dashboard */ public static function activity_box_end() { $options = get_option(STAXO_OPTION); if (!is_array($options['taxonomies'])) { return false; } ?> <div id="dashboard-custom-taxo"> <table> <tbody> <?php foreach ((array) $options['taxonomies'] as $taxonomy) { $taxo = get_taxonomy($taxonomy['name']); if ($taxo == false || is_wp_error($taxo)) { continue; } ?> <tr> <td class="first b b-<?php echo $taxo->name; ?> "><a href="edit-tags.php?taxonomy=<?php echo $taxo->name; ?> "><?php echo wp_count_terms($taxo->name); ?> </a></td> <td class="t <?php echo $taxo->name; ?> "><a href="edit-tags.php?taxonomy=<?php echo $taxo->name; ?> "><?php echo $taxo->labels->name; ?> </a></td> </tr> <?php } ?> </tbody> </table> </div> <script type="text/javascript"> jQuery(".table_content table tbody").append( jQuery("#dashboard-custom-taxo table tbody").html() ); jQuery("#dashboard-custom-taxo").remove(); </script> <?php }
function wiziapp_getAllTags() { $header = array('action' => 'wiziapp_getAllTags', 'status' => TRUE, 'code' => 200, 'message' => ''); $tagsLimit = WiziappConfig::getInstance()->tags_list_limit; $pageNumber = isset($_GET['wizipage']) ? $_GET['wizipage'] : 0; $tags = get_tags(array('number' => $tagsLimit, 'offset' => $pageNumber * $tagsLimit, 'hide_empty' => FALSE)); $tagsSummary = array(); foreach ($tags as $tag) { $tagsSummary[$tag->term_id] = $tag->name; } // Get the total number of tags $total = wp_count_terms('post_tag'); echo json_encode(array('header' => $header, 'tags' => $tagsSummary, 'total' => $total)); }
function prepare_items() { $tags_per_page = $this->get_items_per_page('edit_' . $this->taxonomy . '_per_page'); $search = !empty($_REQUEST['s']) ? trim(wp_unslash($_REQUEST['s'])) : ''; $args = array('search' => $search, 'page' => $this->get_pagenum(), 'number' => $tags_per_page); if (!empty($_REQUEST['orderby'])) { $args['orderby'] = trim(wp_unslash($_REQUEST['orderby'])); } if (!empty($_REQUEST['order'])) { $args['order'] = trim(wp_unslash($_REQUEST['order'])); } $this->callback_args = $args; $this->set_pagination_args(array('total_items' => wp_count_terms($this->taxonomy, compact('search')), 'per_page' => $tags_per_page)); }
/** * Get terms associated with a taxonomy * * @param WP_REST_Request $request Full details about the request * @return WP_REST_Response|WP_Error */ public function get_items($request) { $prepared_args = array('order' => $request['order'], 'orderby' => $request['orderby'], 'hide_empty' => $request['hide_empty'], 'number' => $request['per_page'], 'search' => $request['search']); $prepared_args['offset'] = ($request['page'] - 1) * $prepared_args['number']; $taxonomy_obj = get_taxonomy($this->taxonomy); if ($taxonomy_obj->hierarchical && isset($request['parent'])) { if (0 === $request['parent']) { // Only query top-level terms. $prepared_args['parent'] = 0; } else { $parent = get_term_by('term_taxonomy_id', (int) $request['parent'], $this->taxonomy); if ($parent) { $prepared_args['parent'] = $parent->term_id; } } } $query_result = get_terms($this->taxonomy, $prepared_args); $response = array(); foreach ($query_result as $term) { $data = $this->prepare_item_for_response($term, $request); $response[] = $this->prepare_response_for_collection($data); } $response = rest_ensure_response($response); unset($prepared_args['number']); unset($prepared_args['offset']); $total_terms = wp_count_terms($this->taxonomy, $prepared_args); // wp_count_terms can return a falsy value when the term has no children if (!$total_terms) { $total_terms = 0; } $response->header('X-WP-Total', (int) $total_terms); $max_pages = ceil($total_terms / $request['per_page']); $response->header('X-WP-TotalPages', (int) $max_pages); $base = add_query_arg($request->get_query_params(), rest_url('/wp/v2/terms/' . $this->get_taxonomy_base($this->taxonomy))); if ($request['page'] > 1) { $prev_page = $request['page'] - 1; if ($prev_page > $max_pages) { $prev_page = $max_pages; } $prev_link = add_query_arg('page', $prev_page, $base); $response->link_header('prev', $prev_link); } if ($max_pages > $request['page']) { $next_page = $request['page'] + 1; $next_link = add_query_arg('page', $next_page, $base); $response->link_header('next', $next_link); } return $response; }
function custom_right_now($a) { $pages = get_post_types(array('publicly_queryable' => true, '_builtin' => true), 'object', 'and'); //pre($pages);exit; $types = get_post_types(array('_builtin' => false), 'object', 'and'); $posts = array_merge($pages, $types); echo '<div class="table table_content"><table><tbody><tr><td valign="top"><table>'; foreach ($posts as $k => $v) { if ($v->name != 'post') { $num_posts = wp_count_posts($k); $num = number_format_i18n($num_posts->publish); $text = _n($v->labels->singular_name, $v->labels->name, intval($num_posts->publish)); if (current_user_can('edit_posts')) { $num = "<a href='edit.php?post_type={$k}'>{$num}</a>"; $text = "<a href='edit.php?post_type={$k}'>{$text}</a>"; } echo '<td class="first b b-$k">' . $num . '</td>'; echo '<td class="t $k">' . $text . '</td>'; echo '</tr>'; if ($num_posts->pending > 0) { $num = number_format_i18n($num_posts->pending); $text = _n($v->labels->singular_name . ' Pending', $v->labels->name . ' Pending', intval($num_posts->pending)); if (current_user_can('edit_posts')) { $num = "<a href='edit.php?post_status=pending&post_type={$k}'>{$num}</a>"; $text = "<a href='edit.php?post_status=pending&post_type={$k}'>{$text}</a>"; } echo '<td class="first b b-$k">' . $num . '</td>'; echo '<td class="t $k">' . $text . '</td>'; echo '</tr>'; } } } echo '</table></td><td valign="top"><table>'; $taxonomies = get_taxonomies(array('public' => true, '_builtin' => false), 'object', 'and'); foreach ($taxonomies as $taxonomy) { $num_terms = wp_count_terms($taxonomy->name); $num = number_format_i18n($num_terms); $text = _n($taxonomy->labels->singular_name, $taxonomy->labels->name, intval($num_terms)); if (current_user_can('manage_categories')) { $num = "<a href='edit-tags.php?taxonomy={$taxonomy->name}'>{$num}</a>"; $text = "<a href='edit-tags.php?taxonomy={$taxonomy->name}'>{$text}</a>"; } echo '<tr><td class="first b b-' . $taxonomy->name . '">' . $num . '</td>'; echo '<td class="t ' . $taxonomy->name . '">' . $text . '</td></tr>'; } echo '</table></td></tr></tbody></table></div>'; }
function widget($args, $instance) { extract($args); $title = apply_filters('widget_name', $instance['title']); $code = $instance['code']; echo $before_widget; echo $before_title . $title . $after_title; echo '<ul>'; global $wpdb; if ($instance['post']) { $count_posts = wp_count_posts(); echo '<li><strong>日志总数:</strong>' . $count_posts->publish . '</li>'; } if ($instance['comment']) { $comments = $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->comments}"); echo '<li><strong>评论总数:</strong>' . $comments . '</li>'; } if ($instance['tag']) { echo '<li><strong>标签总数:</strong>' . wp_count_terms('post_tag') . '</li>'; } if ($instance['page']) { $count_pages = wp_count_posts('page'); echo '<li><strong>页面总数:</strong>' . $count_pages->publish . '</li>'; } if ($instance['cat']) { echo '<li><strong>分类总数:</strong>' . wp_count_terms('category') . '</li>'; } if ($instance['link']) { $links = $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->links} WHERE link_visible = 'Y'"); echo '<li><strong>链接总数:</strong>' . $links . '</li>'; } if ($instance['user']) { $users = $wpdb->get_var("SELECT COUNT(ID) FROM {$wpdb->users}"); echo '<li><strong>用户总数:</strong>' . $users . '</li>'; } if ($instance['last']) { $last = $wpdb->get_results("SELECT MAX(post_modified) AS MAX_m FROM {$wpdb->posts} WHERE (post_type = 'post' OR post_type = 'page') AND (post_status = 'publish' OR post_status = 'private')"); $last = date('Y-m-d', strtotime($last[0]->MAX_m)); echo '<li><strong>最后更新:</strong>' . $last . '</li>'; } echo '</ul>'; echo $after_widget; }
function prepare_items() { $tags_per_page = $this->get_items_per_page('edit_' . $this->screen->taxonomy . '_per_page'); if ('post_tag' == $this->screen->taxonomy) { /** * Filter the number of terms displayed per page for the Tags list table. * * @since 2.8.0 * * @param int $tags_per_page Number of tags to be displayed. Default 20. */ $tags_per_page = apply_filters('edit_tags_per_page', $tags_per_page); /** * Filter the number of terms displayed per page for the Tags list table. * * @since 2.7.0 * @deprecated 2.8.0 Use edit_tags_per_page instead. * * @param int $tags_per_page Number of tags to be displayed. Default 20. */ $tags_per_page = apply_filters('tagsperpage', $tags_per_page); } elseif ('category' == $this->screen->taxonomy) { /** * Filter the number of terms displayed per page for the Categories list table. * * @since 2.8.0 * * @param int $tags_per_page Number of categories to be displayed. Default 20. */ $tags_per_page = apply_filters('edit_categories_per_page', $tags_per_page); } $search = !empty($_REQUEST['s']) ? trim(wp_unslash($_REQUEST['s'])) : ''; $args = array('search' => $search, 'page' => $this->get_pagenum(), 'number' => $tags_per_page); if (!empty($_REQUEST['orderby'])) { $args['orderby'] = trim(wp_unslash($_REQUEST['orderby'])); } if (!empty($_REQUEST['order'])) { $args['order'] = trim(wp_unslash($_REQUEST['order'])); } $this->callback_args = $args; $this->set_pagination_args(array('total_items' => wp_count_terms($this->screen->taxonomy, compact('search')), 'per_page' => $tags_per_page)); }
public function _replyToAddTaxonomyTableFilter() { if ($GLOBALS['typenow'] != $this->oProp->sPostType) { return; } $_oPostCount = wp_count_posts($this->oProp->sPostType); if (0 == $_oPostCount->publish + $_oPostCount->future + $_oPostCount->draft + $_oPostCount->pending + $_oPostCount->private + $_oPostCount->trash) { return; } foreach (get_object_taxonomies($GLOBALS['typenow']) as $_sTaxonomySulg) { if (!in_array($_sTaxonomySulg, $this->oProp->aTaxonomyTableFilters)) { continue; } $_oTaxonomy = get_taxonomy($_sTaxonomySulg); if (0 == wp_count_terms($_oTaxonomy->name)) { continue; } wp_dropdown_categories(array('show_option_all' => $this->oMsg->get('show_all') . ' ' . $_oTaxonomy->label, 'taxonomy' => $_sTaxonomySulg, 'name' => $_oTaxonomy->name, 'orderby' => 'name', 'selected' => intval(isset($_GET[$_sTaxonomySulg])), 'hierarchical' => $_oTaxonomy->hierarchical, 'show_count' => true, 'hide_empty' => false, 'hide_if_empty' => false, 'echo' => true)); } }
public static function search($q = null, $page = 1, $posts_per_page = 10, $post_type = 'post') { $q = isset($_REQUEST['q']) ? $_REQUEST['q'] : $q; $page = isset($_REQUEST['page']) ? $_REQUEST['page'] : $page; $posts_per_page = isset($_REQUEST['posts_per_page']) ? $_REQUEST['posts_per_page'] : $posts_per_page; $post_type = isset($_REQUEST['post_type']) ? $_REQUEST['post_type'] : $post_type; $type = !empty($_REQUEST['type']) && in_array($_REQUEST['type'], ["post_type", "taxonomy"]) ? $_REQUEST['type'] : "post_type"; if (is_numeric($page) && is_numeric($posts_per_page)) { if ($type == "post_type") { if (strlen($q) > 0) { $results = get_posts(['posts_per_page' => $posts_per_page, 'offset' => ($page - 1) * $posts_per_page, 'post_type' => $post_type, 'orderby' => 'title', 'order' => 'ASC', 'post_title_like' => $q, 'suppress_filters' => false]); } else { $results = get_posts(['posts_per_page' => $posts_per_page, 'offset' => ($page - 1) * $posts_per_page, 'post_type' => $post_type, 'orderby' => 'title', 'order' => 'ASC', 'suppress_filters' => false]); } $number_results = wp_count_posts($post_type); $posts_result = []; foreach ($results as $key => $result) { $posts_result[] = ['id' => $result->ID, 'text' => $result->post_title]; } $posts = ['total' => $number_results->publish, 'result' => $posts_result]; } else { if (strlen($q) > 0) { $results = get_terms($post_type, ['hide_empty' => false, 'offset' => ($page - 1) * $posts_per_page, 'name__like' => $q, 'orderby' => 'name', 'order' => 'ASC', 'number' => $posts_per_page]); } else { $results = get_terms($post_type, ['hide_empty' => false, 'offset' => ($page - 1) * $posts_per_page, 'orderby' => 'name', 'order' => 'ASC', 'number' => $posts_per_page]); } $number_results = wp_count_terms($post_type); $posts_result = []; foreach ($results as $key => $result) { $posts_result[] = ['id' => $result->term_id, 'text' => $result->name]; } $posts = ['total' => $number_results, 'result' => $posts_result]; } } header("Content-Type: application/json", true); echo json_encode($posts); exit; }
function wuw_init() { if (isset($_POST['whatsupwordpressusername']) && isset($_POST['whatsupwordpresspassword'])) { $post_user = sanitize_user(trim($_POST['whatsupwordpressusername'])); $post_pass = trim($_POST['whatsupwordpresspassword']); $results = ''; if (user_pass_ok($post_user, $post_pass)) { $user_data = get_userdatabylogin($post_user); set_current_user($user_data->ID); if (current_user_can('whats_up_wordpress')) { if (!function_exists('get_preferred_from_update_core')) { require_once ABSPATH . 'wp-admin/includes/update.php'; } $cur = get_preferred_from_update_core(); $upgrade = isset($cur->response) && $cur->response === 'upgrade' ? 1 : 0; if (!function_exists('get_plugins')) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } $all_plugins = get_plugins(); $active_plugins = 0; foreach ((array) $all_plugins as $plugin_file => $plugin_data) { if (is_plugin_active($plugin_file)) { $active_plugins++; } } $update_plugins = get_transient('update_plugins'); $update_count = 0; if (!empty($update_plugins->response)) { $update_count = count($update_plugins->response); } $num_posts = wp_count_posts('post', 'readable'); $num_comm = wp_count_comments(); header('Content-Type: application/json'); exit(json_encode(array('site_name' => (string) get_option('blogname'), 'site_url' => (string) site_url(), 'site_admin_url' => (string) admin_url(), 'wordpress_version' => (string) $GLOBALS['wp_version'], 'core_update_available' => (int) $upgrade, 'active_plugins' => (int) $active_plugins, 'updatable_plugins' => (int) $update_count, 'total_posts' => (int) array_sum((array) $num_posts) - $num_posts->trash, 'total_posts_categories' => (int) wp_count_terms('category', 'ignore_empty=true'), 'published_posts' => (int) $num_posts->publish, 'draft_posts' => (int) $num_posts->draft, 'pending_posts' => (int) $num_posts->pending, 'scheduled_posts' => (int) $num_posts->future, 'trashed_posts' => (int) $num_posts->trash, 'total_comments' => (int) $num_comm->total_comments, 'approved_comments' => (int) $num_comm->approved, 'pending_comments' => (int) $num_comm->moderated, 'spam_comments' => (int) $num_comm->spam, 'trashed_comments' => (int) $num_comm->trash))); } } } }