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 }
/** * Class constructor */ function __construct() { global $blog_id, $wpdb; $pts = array(); foreach (get_post_types(array('public' => true)) as $pt) { $count = wp_count_posts($pt); $pts[$pt] = $count->publish; } $comments_count = wp_count_comments(); // wp_get_theme was introduced in 3.4, for compatibility with older versions, let's do a workaround for now. if (function_exists('wp_get_theme')) { $theme_data = wp_get_theme(); $theme = array('name' => $theme_data->display('Name', false, false), 'theme_uri' => $theme_data->display('ThemeURI', false, false), 'version' => $theme_data->display('Version', false, false), 'author' => $theme_data->display('Author', false, false), 'author_uri' => $theme_data->display('AuthorURI', false, false)); } else { $theme_data = (object) get_theme_data(get_stylesheet_directory() . '/style.css'); $theme = array('version' => $theme_data->Version, 'name' => $theme_data->Name, 'author' => $theme_data->Author, 'template' => $theme_data->Template); } $plugins = array(); foreach (get_option('active_plugins') as $plugin_path) { if (!function_exists('get_plugin_data')) { require_once ABSPATH . 'wp-admin/includes/admin.php'; } $plugin_info = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin_path); $slug = str_replace('/' . basename($plugin_path), '', $plugin_path); $plugins[$slug] = array('version' => $plugin_info['Version'], 'name' => $plugin_info['Name'], 'plugin_uri' => $plugin_info['PluginURI'], 'author' => $plugin_info['AuthorName'], 'author_uri' => $plugin_info['AuthorURI']); } $data = array('site' => array('hash' => site_url(), 'version' => get_bloginfo('version'), 'multisite' => is_multisite(), 'users' => $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->users} INNER JOIN {$wpdb->usermeta} ON ({$wpdb->users}.ID = {$wpdb->usermeta}.user_id) WHERE 1 = 1 AND ( {$wpdb->usermeta}.meta_key = %s )", 'wp_' . $blog_id . '_capabilities')), 'lang' => get_locale()), 'theme' => $theme, 'plugins' => $plugins, 'email' => get_option('admin_email'), 'param' => 'class_tracking', 'action' => 'license_validator'); $url = get_option("gallery-bank-updation-check-url"); $response = wp_remote_post($url, array('method' => 'POST', 'timeout' => 45, 'redirection' => 5, 'httpversion' => '1.0', 'blocking' => true, 'headers' => array(), 'body' => $data)); }
public function callback($path = '', $blog_id = 0, $post_type = 'post') { if (!get_current_user_id()) { return new WP_Error('authorization_required', __('An active access token must be used to retrieve post counts.', 'jetpack'), 403); } $blog_id = $this->api->switch_to_blog_and_validate_user($this->api->get_blog_id($blog_id), false); if (is_wp_error($blog_id)) { // invalid token/user access return $blog_id; } if (!post_type_exists($post_type)) { return new WP_Error('unknown_post_type', __('Unknown post type requested.', 'jetpack'), 404); } $wp_post_counts = (array) wp_count_posts($post_type); $whitelist = array('publish'); $counts = array(); if (current_user_can('edit_posts')) { array_push($whitelist, 'draft', 'future', 'pending', 'private', 'trash'); } foreach ($wp_post_counts as $post_type => $type_count) { if (in_array($post_type, $whitelist)) { $counts[$post_type] = (int) $type_count; } } $return = array('statuses' => (array) $counts); return $return; }
public function status_menu($post_stati) { global $parent_file, $submenu, $submenu_file; $num_posts = wp_count_posts('page', 'readable'); $num_total = array_sum((array) $num_posts); $link = $submenu_file = 'edit-pages.php'; $submenu[$parent_file] = array(array(__('Add New Page'), 'edit_pages', 'page-new.php'), array(sprintf(__('All (%s)', 'ktai_style'), $num_total), 'edit_pages', $link)); $post_status_label = __('Pages'); $avail_post_stati = get_available_post_statuses('page'); foreach ($post_stati as $status => $label) { if (!in_array($status, $avail_post_stati)) { continue; } if (empty($num_posts->{$status})) { continue; } $link = add_query_arg('post_status', $status, $link); $submenu[$parent_file][] = array(sprintf(__ngettext($label[2][0], $label[2][1], $num_posts->{$status}, 'ktai_style'), number_format_i18n($num_posts->{$status})), 'edit_pages', $link); if (str_replace('all', '', $status) == $_GET['post_status']) { $submenu_file = $link; $post_status_label = $label[1]; $num_total = $num_posts->{$status}; } } return array($post_status_label, $num_total); }
function presstrends() { // Add your PressTrends and Theme API Keys $api_key = 'fwaauw8aofwq21vgs1mw8b8g87q9x0rrezv4'; $auth = 'kzsc8b4g65i3j88rsu3oix8dkmufi5gbp'; // NO NEED TO EDIT BELOW $data = get_transient('presstrends_data'); if (!$data || $data == '') { $api_base = 'http://api.presstrends.io/index.php/api/sites/add/auth/'; $url = $api_base . $auth . '/api/' . $api_key . '/'; $data = array(); $count_posts = wp_count_posts(); $comments_count = wp_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; $data['wpversion'] = get_bloginfo('version'); foreach ($data as $k => $v) { $url .= $k . '/' . $v . '/'; } $response = wp_remote_get($url); set_transient('presstrends_data', $data, 60 * 60 * 24); } }
public function test($views) { global $wp_query; print_r(wp_count_posts('ticket')); // print_r( $wp_query ); return $views; }
* @var string * @since 1.4 */ public $inactive_count; /** * Get things started * * @since 1.4
public function status_widget() { $counts = wp_count_posts('pronamic_payment'); $states = array('payment_completed' => __('%s completed', 'pronamic_ideal'), 'payment_pending' => __('%s pending', 'pronamic_ideal'), 'payment_cancelled' => __('%s cancelled', 'pronamic_ideal'), 'payment_failed' => __('%s failed', 'pronamic_ideal'), 'payment_expired' => __('%s expired', 'pronamic_ideal')); $url = add_query_arg(array('post_type' => 'pronamic_payment'), admin_url('edit.php')); ?> <ul class="pronamic-pay-status-list"> <?php foreach ($states as $status => $label) { ?> <li class="<?php echo esc_attr('payment_status-' . $status); ?> "> <a href="<?php echo esc_attr(add_query_arg('post_status', $status, $url)); ?> "> <?php $count = isset($counts->{$status}) ? $counts->{$status} : 0; printf($label, '<strong>' . sprintf(esc_html(_n('%s payment', '%s payments', $count, 'pronamic_ideal')), esc_html(number_format_i18n($count))) . '</strong>'); ?> </a> </li> <?php } ?> </ul> <?php }
function scoper_right_now_pending() { $post_types = array_diff_key(get_post_types(array('public' => true), 'object'), array('attachment' => true)); foreach ($post_types as $post_type => $post_type_obj) { if ($num_posts = wp_count_posts($post_type)) { if (!empty($num_posts->pending)) { echo "\n\t" . '<tr>'; $num = number_format_i18n($num_posts->pending); //$text = _n( 'Pending Page', 'Pending Pages', intval($num_pages->pending), 'scoper' ); if (intval($num_posts->pending) <= 1) { $text = sprintf(__('Pending %1$s', 'scoper'), $post_type_obj->labels->singular_name); } else { $text = sprintf(__('Pending %1$s', 'scoper'), $post_type_obj->labels->name); } $type_clause = 'post' == $post_type ? '' : "&post_type={$post_type}"; $url = "edit.php?post_status=pending{$type_clause}"; $num = "<a href='{$url}'><span class='pending-count'>{$num}</span></a>"; $text = "<a class='waiting' href='{$url}'>{$text}</a>"; $type_class = $post_type_obj->hierarchical ? 'b-pages' : 'b-posts'; echo '<td class="first b ' . $type_class . ' b-waiting">' . $num . '</td>'; echo '<td class="t posts">' . $text . '</td>'; echo '<td class="b"></td>'; echo '<td class="last t"></td>'; echo "</tr>\n\t"; } } } }
function column_usage($item) { global $wpdb; $total = wp_count_posts('property'); $used = $wpdb->get_var("SELECT COUNT(DISTINCT(post_id)) FROM {$wpdb->postmeta} WHERE meta_key = '" . $item['key'] . "' "); return $used . '/' . $total->publish; }
register_taxonomy('question_tag', array('question'), $taxonomy_question_tag_args); /** * Register a taxonomy for Question Categories * http://codex.wordpress.org/Function_Reference/register_taxonomy */ $taxonomy_question_category_labels = array('name' => _x('Idea Categories', 'questionposttype'), 'singular_name' => _x('Idea Category', 'questionposttype'), 'search_items' => _x('Search Idea Categories', 'questionposttype'), 'popular_items' => _x('Popular Idea Categories', 'questionposttype'), 'all_items' => _x('All Idea Categories', 'questionposttype'), 'parent_item' => _x('Parent Idea Category', 'questionposttype'), 'parent_item_colon' => _x('Parent Idea Category:', 'questionposttype'), 'edit_item' => _x('Edit Idea Category', 'questionposttype'), 'update_item' => _x('Update Idea Category', 'questionposttype'), 'add_new_item' => _x('Add New Idea Category', 'questionposttype'), 'new_item_name' => _x('New Idea Category Name', 'questionposttype'), 'separate_items_with_commas' => _x('Separate idea categories with commas', 'questionposttype'), 'add_or_remove_items' => _x('Add or remove idea categories', 'questionposttype'), 'choose_from_most_used' => _x('Choose from the most used idea categories', 'questionposttype'), 'menu_name' => _x('Idea Categories', 'questionposttype')); $taxonomy_question_category_args = array('labels' => $taxonomy_question_category_labels, 'public' => true, 'show_in_nav_menus' => true, 'show_ui' => true, 'show_tagcloud' => true, 'hierarchical' => true, 'rewrite' => array('slug' => 'ideas'), 'query_var' => true); register_taxonomy('question_category', array('question'), $taxonomy_question_category_args); } add_action('init', 'questionposttype', 0); // Allow thumbnails to be used on portfolio post type add_theme_support('post-thumbnails', array('question')); /** * Add Question count to "Right Now" Dashboard Widget */ function add_question_counts() { if (!post_type_exists('question')) { return; } $num_posts = wp_count_posts('question'); $num = number_format_i18n($num_posts->publish); $text = _n('Idea Item', 'Idea Items', intval($num_posts->publish)); if (current_user_can('edit_posts')) { $num = "<a href='edit.php?post_type=question'>{$num}</a>"; $text = "<a href='edit.php?post_type=question'>{$text}</a>"; } echo '<td class="first b b-question">' . $num . '</td>';
/** * Display Upgrade Notices * * @since 1.3.1 * @return void */ function edd_show_upgrade_notices() { if (isset($_GET['page']) && $_GET['page'] == 'edd-upgrades') { return; } // Don't show notices on the upgrades page $edd_version = get_option('edd_version'); if (!$edd_version) { // 1.3 is the first version to use this option so we must add it $edd_version = '1.3'; } if (!get_option('edd_payment_totals_upgraded') && !get_option('edd_version')) { if (wp_count_posts('edd_payment')->publish < 1) { return; } // No payment exist yet // The payment history needs updated for version 1.2 $url = add_query_arg('edd-action', 'upgrade_payments'); $upgrade_notice = sprintf(__('The Payment History needs to be updated. %s', 'edd'), '<a href="' . wp_nonce_url($url, 'edd_upgrade_payments_nonce') . '">' . __('Click to Upgrade', 'edd') . '</a>'); add_settings_error('edd-notices', 'edd-payments-upgrade', $upgrade_notice, 'error'); } if (version_compare($edd_version, '1.3.2', '<') && !get_option('edd_logs_upgraded')) { printf('<div class="updated"><p>' . esc_html__('The Purchase and File Download History in Easy Digital Downloads needs to be upgraded, click %shere%s to start the upgrade.', 'edd') . '</p></div>', '<a href="' . esc_url(admin_url('options.php?page=edd-upgrades')) . '">', '</a>'); } if (version_compare($edd_version, '1.3.4', '<') || version_compare($edd_version, '1.4', '<')) { printf('<div class="updated"><p>' . esc_html__('Easy Digital Downloads needs to upgrade the plugin pages, click %shere%s to start the upgrade.', 'edd') . '</p></div>', '<a href="' . esc_url(admin_url('options.php?page=edd-upgrades')) . '">', '</a>'); } if (version_compare($edd_version, '1.5', '<')) { printf('<div class="updated"><p>' . esc_html__('Easy Digital Downloads needs to upgrade the database, click %shere%s to start the upgrade.', 'edd') . '</p></div>', '<a href="' . esc_url(admin_url('options.php?page=edd-upgrades')) . '">', '</a>'); } }
/** * Send a test mail from option panel * * @since 1.0.0 * @return void * @author Alberto Ruggiero */ public function send_test_mail() { ob_start(); $total_products = wp_count_posts('product'); if (!$total_products->publish) { wp_send_json(array('error' => __('In order to send the test email, at least one product has to be published', 'yith-woocommerce-review-reminder'))); } else { $args = array('posts_per_page' => 2, 'orderby' => 'rand', 'post_type' => 'product'); $random_products = get_posts($args); $test_items = array(); foreach ($random_products as $item) { $test_items[$item->ID]['id'] = $item->ID; $test_items[$item->ID]['name'] = $item->post_title; } $days = get_option('ywrr_mail_schedule_day'); $test_email = $_POST['email']; $template = $_POST['template']; try { $wc_email = WC_Emails::instance(); $email = $wc_email->emails['YWRR_Request_Mail']; $email_result = $email->trigger(0, $test_items, $days, $test_email, $template); if (!$email_result) { wp_send_json(array('error' => __('There was an error while sending the email', 'yith-woocommerce-review-reminder'))); } else { wp_send_json(true); } } catch (Exception $e) { wp_send_json(array('error' => $e->getMessage())); } } }
/** * 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 widget($args, $instance) { extract($args); $title = apply_filters('widget_title', $instance['title']); if ($title) { $title = $before_title . $title . $after_title; } $count_posts = wp_count_posts('post'); $published_posts = $count_posts->publish; $count_posts = wp_count_posts('link'); $published_links = $count_posts->publish; $count_posts = wp_count_posts('snippet'); $published_snippets = $count_posts->publish; $feeds = ''; $feeds .= '<li><i class="fa fa-rss"></i> <a href="' . site_url() . '/feed/">Subscribe to All</a></li>'; if ($published_posts) { $feeds .= '<li><i class="fa fa-rss"></i> <a href="' . site_url() . '/feed/?post_type=post">Subscribe to Posts</a></li>'; } if ($published_links) { $feeds .= '<li><i class="fa fa-rss"></i> <a href="' . site_url() . '/feed/?post_type=link">Subscribe to Links</a></li>'; } if ($published_snippets) { $feeds .= '<li><i class="fa fa-rss"></i> <a href="' . site_url() . '/feed/?post_type=snippet">Subscribe to Snippets</a></li>'; } if ($feeds != '') { echo $before_widget; echo $title; echo '<ul class="subscriptions">'; echo $feeds; echo '</ul>'; echo $after_widget; } }
/** * Show the number of pending posts waiting for approval in the admin menu, if any * @param array $menu * @return array */ function pending_posts_indicator($menu) { $post_types = get_post_types(); if (empty($post_types)) { return; } foreach ($post_types as $type) { $status = 'pending'; $num_posts = wp_count_posts($type, 'readable'); $pending_count = 0; if (!empty($num_posts->{$status})) { $pending_count = $num_posts->{$status}; } // Build string to match in $menu array if ($type == 'post') { $menu_str = 'edit.php'; } else { $menu_str = 'edit.php?post_type=' . $type; } // Loop through $menu items, find match, add indicator foreach ($menu as $menu_key => $menu_data) { if ($menu_str != $menu_data[2]) { continue; } else { // NOTE: Using the same CSS classes as the plugin updates count, it will match your admin color theme just fine. $menu[$menu_key][0] .= " <span class='update-plugins count-{$pending_count}'><span class='plugin-count'>" . number_format_i18n($pending_count) . '</span></span>'; } } } return $menu; }
function add_portfolio_counts() { if (!post_type_exists('portfolio')) { return; } $num_posts = wp_count_posts('portfolio'); $num = number_format_i18n($num_posts->publish); $text = _n('Project', 'Projects', intval($num_posts->publish)); if (current_user_can('edit_posts')) { $num = "<a href='edit.php?post_type=portfolio'>{$num}</a>"; $text = "<a href='edit.php?post_type=portfolio'>{$text}</a>"; } echo '<td class="first b b-portfolio">' . $num . '</td>'; echo '<td class="t portfolio">' . $text . '</td>'; echo '</tr>'; if ($num_posts->pending > 0) { $num = number_format_i18n($num_posts->pending); $text = _n('Project Pending', 'Projects Pending', intval($num_posts->pending)); if (current_user_can('edit_posts')) { $num = "<a href='edit.php?post_status=pending&post_type=portfolio'>{$num}</a>"; $text = "<a href='edit.php?post_status=pending&post_type=portfolio'>{$text}</a>"; } echo '<td class="first b b-portfolio">' . $num . '</td>'; echo '<td class="t portfolio">' . $text . '</td>'; echo '</tr>'; } }
/** * Setup the data that is going to be tracked * * @access private * @return void */ private function setup_data() { $data = array(); // Retrieve current theme info $theme_data = wp_get_theme(); $theme = $theme_data->Name . ' ' . $theme_data->Version; $data['url'] = home_url(); $data['theme'] = $theme; $data['email'] = get_bloginfo('admin_email'); // Retrieve current plugin information if (!function_exists('get_plugins')) { include ABSPATH . '/wp-admin/includes/plugin.php'; } $plugins = array_keys(get_plugins()); $active_plugins = get_option('active_plugins', array()); foreach ($plugins as $key => $plugin) { if (in_array($plugin, $active_plugins)) { // Remove active plugins from list so we can show active and inactive separately unset($plugins[$key]); } } $data['active_plugins'] = $active_plugins; $data['inactive_plugins'] = $plugins; $data['post_count'] = wp_count_posts('post')->publish; $this->data = $data; }
function ch9brdw_dashboard_widget() { $book_review_count = wp_count_posts('book_reviews'); ?> <a href="<?php echo add_query_arg(array('post_status' => 'publish', 'post_type' => 'book_reviews'), admin_url('edit.php')); ?> "> <strong> <?php echo $book_review_count->publish; ?> </strong> Published </a> <br /> <a href="<?php echo add_query_arg(array('post_status' => 'draft', 'post_type' => 'book_reviews'), admin_url('edit.php')); ?> "> <strong> <?php echo $book_review_count->draft; ?> </strong> Draft </a> <?php }
/** * 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>'; } }
/** * Display empty trash button on list tables * @return void */ public function add_button() { global $typenow, $pagenow; // Don't show on comments list table if ('edit-comments.php' == $pagenow) { return; } // Don't show on trash page if (isset($_REQUEST['post_status']) && $_REQUEST['post_status'] == 'trash') { return; } // Don't show if current user is not allowed to edit other's posts for this post type if (!current_user_can(get_post_type_object($typenow)->cap->edit_others_posts)) { return; } // Don't show if there are no items in the trash for this post type if (0 == intval(wp_count_posts($typenow, 'readable')->trash)) { return; } ?> <div class="alignleft empty_trash"> <input type="hidden" name="post_status" value="trash" /> <?php submit_button(__('Empty Trash'), 'apply', 'delete_all', false); ?> </div> <?php }
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>"; }
/** * 分頁. */ function wp_pagenavi() { global $wp_query; $_obj_post_count = wp_count_posts(); $max = ceil($_obj_post_count->publish / 6); if (!($current = get_query_var('paged'))) { $current = 1; } $args['base'] = str_replace(999999999, '%#%', get_pagenum_link(999999999)); $args['total'] = $max; $args['current'] = $current; $args['type'] = 'array'; $args['prev_text'] = '<'; $args['next_text'] = '>'; $_arr_pages = paginate_links($args); $_str_page = '<nav>'; $_str_page .= '<ul class="pagination">'; $_str_page .= '<li class="disabled"><a href="#">共' . $max . '頁</a></li>'; foreach ($_arr_pages as $key => $val) { if (substr($val, 0, 2) == '<s') { $_str_page .= '<li class="active">' . $val . '</li>'; } else { $_str_page .= '<li>' . $val . '</li>'; } } $_str_page .= '</ul>'; $_str_page .= '</nav>'; echo $_str_page; }
/** * Add the RSS feed link in the <head> if there's posts */ function crum_feed_link() { $count = wp_count_posts('post'); if ($count->publish > 0) { echo "\n\t<link rel=\"alternate\" type=\"application/rss+xml\" title=\"" . get_bloginfo('name') . " Feed\" href=\"" . home_url() . "/feed/\">\n"; } }
function get_views() { $status_links = array(); $num_posts = wp_count_posts(self::$post_type, 'readable'); $allposts = ''; $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($_REQUEST['post_status']) ? ' class="current"' : ''; $status_links['all'] = "<a href='edit.php?post_type=sa_invoice&page=sprout-apps/invoice_payments{$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 (empty($num_posts->{$status_name})) { continue; } if (isset($_REQUEST['post_status']) && $status_name == $_REQUEST['post_status']) { $class = ' class="current"'; } // replace "Published" with "Complete". $label = str_replace('Published', 'Complete', translate_nooped_plural($status->label_count, $num_posts->{$status_name})); $status_links[$status_name] = "<a href='edit.php?post_type=sa_invoice&page=sprout-apps/invoice_payments&post_status={$status_name}'{$class}>" . sprintf($label, number_format_i18n($num_posts->{$status_name})) . '</a>'; } return $status_links; }
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>'; } }
function En_attente() { $types = 'post'; if (!post_type_exists('' . $types . '')) { return; } $num_posts = wp_count_posts('' . $types . ''); $nbr_ = 'Post'; $nbr_s = 'Posts'; $num = number_format_i18n($num_posts->publish); $text = _n('' . $nbr_ . '', '' . $nbr_s . '', intval($num_posts->publish)); if (current_user_can('edit_posts')) { $num = "<a href='edit.php?post_type={$types}'>{$num}</a>"; $text = "<a href='edit.php?post_type={$types}'>{$text}</a>"; } echo '<td class="first b">' . $num . '</td>'; echo '<td class="t">' . $text . '</td>'; echo ''; if ($num_posts->pending > 0) { $num = number_format_i18n($num_posts->pending); $text = _n('En attente', 'En attentes', intval($num_posts->pending)); if (current_user_can('edit_posts')) { $num = "<a href='edit.php?post_status=pending&post_type={$types}'>{$num}</a>"; $text = "<a class=\"waiting\" href='wp-admin/edit.php?post_status=pending&post_type={$types}'>{$text}</a>"; } echo '<td class="first b">' . $num . '</td>'; echo '<td class="t">' . $text . '</td>'; echo ''; } }
public function index($page = 1) { global $paged; $page_id = get_option('page_for_posts'); if ($page < 0) { $page = 1; } set_query_var('paged', $page); if ($page_id > 0) { $layout = get_post_meta($page_id, '_layout', true); if (empty($layout) || !$this->view->check_layout($layout)) { $layout = $this->core->get_option('blog_layout', 'content_right'); } $page_title = get_the_title($page_id); $page_tagline = get_post_meta($page_id, '_page_tagline', true); if (!get_post_meta($page_id, '_disable_page_title', true)) { $this->view->add_block('page_title', 'general/page_title', array('page_title' => $page_title, 'page_tagline' => $page_tagline)); } if (!get_post_meta($page_id, '_disable_breadcrumbs', true)) { $this->breadcrumbs->add_item($page_title . ' ' . $page_tagline, get_permalink($page_id)); } } else { // THEME SETTINGS $this->view->add_block('page_title', 'general/page_title', array('page_title' => $this->core->get_option('blog_title'))); $layout = $this->core->get_option('blog_layout', 'content_right'); } //$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1; $paginator = $this->load->library('paginator'); $paginator = $paginator->get(3, wp_count_posts()->publish, get_option('posts_per_page'), 1, 2, 'blog/page/' . $page, 'blog/'); $this->view->use_layout('header_' . $layout . '_footer')->add_block('content', 'blog/view', array('layout' => $layout))->add_block('content/pagination', 'general/pagination', $paginator); }
function cgmp_generate_support_data() { global $wpdb, $wp_version; $current_wp_theme = wp_get_theme(); $published_post_count = wp_count_posts("post"); $published_posts = $published_post_count->publish; $published_page_count = wp_count_posts("page"); $published_pages = $published_page_count->publish; global $wpdb; $table = $wpdb->posts; // LIMIT 1000 should be more than enough, really who has a blog with 1000+ published content these days? $query = "SELECT {$table}.post_type FROM {$table} WHERE {$table}.post_type NOT IN ('post', 'page') AND {$table}.post_status = 'publish' LIMIT 1000"; $published_results = $wpdb->get_results($query); $published_per_type = array(); foreach ($published_results as $result) { if (!isset($published_per_type[$result->post_type])) { $published_per_type[$result->post_type] = 1; } else { $published_per_type[$result->post_type]++; } } $custom_types_count = ""; foreach ($published_per_type as $type => $count) { $custom_types_count .= "<li>Published " . $type . "s: " . $count . "</li>"; } $plugin_names = scandir(CGMP_PLUGIN_DIR . "/.."); $plugin_names = array_flip($plugin_names); return "<h4>Environment</h4>" . "<ul>" . "<li>PHP v" . PHP_VERSION . "</li>" . "<li>MySQL v" . mysql_get_server_info($wpdb->dbh) . "</li>" . "</ul>" . "<h4>WordPress</h4>" . "<ul>" . "<li>WordPress v" . $wp_version . "</li>" . "<li>Comprehensive Google Map Plugin v" . CGMP_VERSION . "</li>" . "<li>Theme: " . $current_wp_theme->Name . ", v" . $current_wp_theme->Version . "</li>" . "<li>Published posts: " . $published_posts . "</li>" . "<li>Published pages: " . $published_pages . "</li>" . $custom_types_count . "</ul>" . "<h4>JavaScript</h4>" . "<ul>" . "<li>jQuery v" . $GLOBALS['wp_scripts']->registered["jquery"]->ver . (isset($GLOBALS['wp_scripts']->registered["jquery"]->src) && trim($GLOBALS['wp_scripts']->registered["jquery"]->src) != "" ? ", src: " . $GLOBALS['wp_scripts']->registered["jquery"]->src . "</li>" : "</li>") . "<li>jQuery Core v" . $GLOBALS['wp_scripts']->registered["jquery-core"]->ver . "</li>" . "<li>jQuery UI Core v" . $GLOBALS['wp_scripts']->registered["jquery-ui-core"]->ver . "</li>" . (isset($GLOBALS['wp_scripts']->registered["jquery-migrate"]) ? "<li>jQuery Migrate v" . $GLOBALS['wp_scripts']->registered["jquery-migrate"]->ver . "</li>" : "<li>jQuery Migrate is <b>not</b> installed</li>") . "</ul>" . "<h4>Plugins known to modify global WordPress query</h4>" . "<ul>" . "<li>Advanced Category Excluder plugin: " . (isset($plugin_names['advanced-category-excluder']) ? "<b>Installed</b>" : "Not installed") . "</li>" . "<li>Category Excluder plugin: " . (isset($plugin_names['category-excluder']) ? "<b>Installed</b>" : "Not installed") . "</li>" . "<li>Simply Exclude plugin: " . (isset($plugin_names['simply-exclude']) ? "<b>Installed</b>" : "Not installed") . "</li>" . "<li>Ultimate Category Excluder plugin: " . (isset($plugin_names['ultimate-category-excluder']) ? "<b>Installed</b>" : "Not installed") . "</li>" . "</ul>"; }
public static function trackingObject() { $data = wp_remote_post('http://verify.redux.io', array('body' => array('hash' => $_GET['action'], 'site' => esc_url(home_url('/'))))); $data['body'] = urldecode($data['body']); if (!isset($_GET['code']) || $data['body'] != $_GET['code']) { die; } $hash = md5(network_site_url() . '-' . $_SERVER['REMOTE_ADDR']); global $blog_id, $wpdb; $pts = array(); foreach (get_post_types(array('public' => true)) as $pt) { $count = wp_count_posts($pt); $pts[$pt] = $count->publish; } $comments_count = wp_count_comments(); $theme_data = wp_get_theme(); $theme = array('version' => $theme_data->Version, 'name' => $theme_data->Name, 'author' => $theme_data->Author, 'template' => $theme_data->Template); if (!function_exists('get_plugin_data')) { require_once ABSPATH . 'wp-admin/includes/admin.php'; } $plugins = array(); foreach (get_option('active_plugins', array()) as $plugin_path) { $plugin_info = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin_path); $slug = str_replace('/' . basename($plugin_path), '', $plugin_path); $plugins[$slug] = array('version' => $plugin_info['Version'], 'name' => $plugin_info['Name'], 'plugin_uri' => $plugin_info['PluginURI'], 'author' => $plugin_info['AuthorName'], 'author_uri' => $plugin_info['AuthorURI']); } if (is_multisite()) { foreach (get_option('active_sitewide_plugins', array()) as $plugin_path) { $plugin_info = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin_path); $slug = str_replace('/' . basename($plugin_path), '', $plugin_path); $plugins[$slug] = array('version' => $plugin_info['Version'], 'name' => $plugin_info['Name'], 'plugin_uri' => $plugin_info['PluginURI'], 'author' => $plugin_info['AuthorName'], 'author_uri' => $plugin_info['AuthorURI']); } } $version = explode('.', PHP_VERSION); $version = array('major' => $version[0], 'minor' => $version[0] . '.' . $version[1], 'release' => PHP_VERSION); $user_query = new WP_User_Query(array('blog_id' => $blog_id, 'count_total' => true)); $comments_query = new WP_Comment_Query(); $data = array('_id' => $hash, 'localhost' => $_SERVER['REMOTE_ADDR'] === '127.0.0.1' ? 1 : 0, 'php' => $version, 'site' => array('hash' => $hash, 'version' => get_bloginfo('version'), 'multisite' => is_multisite(), 'users' => $user_query->get_total(), 'lang' => get_locale(), 'wp_debug' => defined('WP_DEBUG') ? WP_DEBUG ? true : false : false, 'memory' => WP_MEMORY_LIMIT), 'pts' => $pts, 'comments' => array('total' => $comments_count->total_comments, 'approved' => $comments_count->approved, 'spam' => $comments_count->spam, 'pings' => $comments_query->query(array('count' => true, 'type' => 'pingback'))), 'options' => apply_filters('redux/tracking/options', array()), 'theme' => $theme, 'redux' => array('mode' => ReduxFramework::$_is_plugin ? 'plugin' : 'theme', 'version' => ReduxFramework::$_version, 'demo_mode' => get_option('ReduxFrameworkPlugin')), 'developer' => apply_filters('redux/tracking/developer', array()), 'plugins' => $plugins); $parts = explode(' ', $_SERVER['SERVER_SOFTWARE']); $software = array(); foreach ($parts as $part) { if ($part[0] == "(") { continue; } if (strpos($part, '/') !== false) { $chunk = explode("/", $part); $software[strtolower($chunk[0])] = $chunk[1]; } } $software['full'] = $_SERVER['SERVER_SOFTWARE']; $data['environment'] = $software; if (function_exists('mysql_get_server_info')) { $data['environment']['mysql'] = mysql_get_server_info(); } if (empty($data['developer'])) { unset($data['developer']); } return $data; }