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>'; } }
/** * Create the Dashboard Widget and content of the Popular pages * * @since 1.3 * * @param bool $daily Switch for Daily or Overall popular posts * @param int $page Which page of the lists are we on? * @param int $limit Maximum number of posts per page * @param bool $widget Is this a WordPress widget? * @return Formatted list of popular posts */ function tptn_pop_display($daily = FALSE, $page = 0, $limit = FALSE, $widget = FALSE) { global $wpdb, $tptn_settings; $table_name = $wpdb->base_prefix . "top_ten"; if ($daily) { $table_name .= "_daily"; } // If we're viewing daily posts, set this to true if (!$limit) { $limit = $tptn_settings['limit']; } $results = get_tptn_pop_posts(array('posts_only' => 1, 'strict_limit' => 1, 'is_widget' => 1, 'daily' => $daily, 'limit' => $limit)); $output = '<div id="tptn_popular_posts' . ($daily ? "_daily" : "") . '">'; if ($results) { $output .= '<ul>'; foreach ($results as $result) { $output .= '<li><a href="' . get_permalink($result['postnumber']) . '">' . get_the_title($result['postnumber']) . '</a>'; $output .= ' (' . number_format_i18n($result['sumCount']) . ')'; $output .= '</li>'; } $output .= '</ul>'; } $output .= '<p style="text-align:center">'; if ($daily) { $output .= '<a href="' . admin_url('admin.php?page=tptn_popular_posts&orderby=daily_count&order=desc') . '">' . __("View all daily popular posts", 'tptn') . '</a>'; } else { $output .= '<a href="' . admin_url('admin.php?page=tptn_popular_posts&orderby=total_count&order=desc') . '">' . __("View all popular posts", 'tptn') . '</a>'; } $output .= '</p>'; $output .= '<p style="text-align:center;border-top: #000 1px solid">'; $output .= sprintf(__('Popular posts by <a href="%s" target="_blank">Top 10 plugin</a>', 'tptn'), esc_url('https://webberzone.com/plugins/top-10/')); $output .= '</p>'; $output .= '</div>'; return apply_filters('tptn_pop_display', $output); }
public static function pagination($args = array()) { $args = wp_parse_args($args, array('current' => 1, 'total_pages' => 1)); $current = $args['current']; $total_pages = $args['total_pages']; $records_link = add_query_arg(array('page' => WP_Stream_Admin::RECORDS_PAGE_SLUG), self_admin_url(WP_Stream_Admin::ADMIN_PARENT_PAGE)); $html_view_all = sprintf('<a class="%s" title="%s" href="%s">%s</a>', 'view-all', esc_attr__('View all records', 'stream'), esc_url($records_link), esc_html__('View All', 'stream')); $page_links = array(); $disable_first = ''; $disable_last = ''; if (1 === $current) { $disable_first = ' disabled'; } if ($current === $total_pages) { $disable_last = ' disabled'; } $page_links[] = sprintf('<a class="%s" title="%s" href="%s" data-page="1">%s</a>', 'first-page' . $disable_first, esc_attr__('Go to the first page', 'stream'), esc_url(remove_query_arg('paged', $records_link)), '«'); $page_links[] = sprintf('<a class="%s" title="%s" href="%s" data-page="%s">%s</a>', 'prev-page' . $disable_first, esc_attr__('Go to the previous page', 'stream'), esc_url(add_query_arg('paged', max(1, $current - 1), $records_link)), max(1, $current - 1), '‹'); $html_total_pages = sprintf('<span class="total-pages">%s</span>', number_format_i18n($total_pages)); $page_links[] = '<span class="paging-input">' . sprintf(_x('%1$s of %2$s', 'paging', 'stream'), number_format_i18n($current), $html_total_pages) . '</span>'; $page_links[] = sprintf('<a class="%s" title="%s" href="%s" data-page="%s">%s</a>', 'next-page' . $disable_last, esc_attr__('Go to the next page', 'stream'), esc_url(add_query_arg('paged', min($total_pages, $current + 1), $records_link)), min($total_pages, $current + 1), '›'); $page_links[] = sprintf('<a class="%s" title="%s" href="%s" data-page="%s">%s</a>', 'last-page' . $disable_last, esc_attr__('Go to the last page', 'stream'), esc_url(add_query_arg('paged', $total_pages, $records_link)), $total_pages, '»'); $html_pagination_links = ' <div class="tablenav"> <div class="tablenav-pages"> <span class="pagination-links">' . join("\n", $page_links) . '</span> </div> <div class="clear"></div> </div>'; echo '<div>' . $html_view_all . $html_pagination_links . '</div>'; // xss ok }
public function custom_columns($column, $post_id) { global $post; switch ($column) { case 'pronamic_payment_form_gateway': $config_id = get_post_meta($post_id, '_pronamic_payment_form_config_id', true); if (!empty($config_id)) { echo get_the_title($config_id); } else { echo '—'; } break; case 'pronamic_payment_form_payments': global $wpdb; $query = $wpdb->prepare("\n\t\t\t\t\tSELECT\n\t\t\t\t\t\tCOUNT( post.ID ) AS value\n\t\t\t\t\tFROM\n\t\t\t\t\t\t{$wpdb->posts} AS post\n\t\t\t\t\t\t\tLEFT JOIN\n\t\t\t\t\t\t{$wpdb->postmeta} AS meta_amount\n\t\t\t\t\t\t\t\tON post.ID = meta_amount.post_id AND meta_amount.meta_key = '_pronamic_payment_amount'\n\t\t\t\t\t\t\tLEFT JOIN\n\t\t\t\t\t\t{$wpdb->postmeta} AS meta_source\n\t\t\t\t\t\t\t\tON post.ID = meta_source.post_id AND meta_source.meta_key = '_pronamic_payment_source'\n\t\t\t\t\t\t\tLEFT JOIN\n\t\t\t\t\t\t{$wpdb->postmeta} AS meta_source_id\n\t\t\t\t\t\t\t\tON post.ID = meta_source_id.post_id AND meta_source_id.meta_key = '_pronamic_payment_source_id'\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tpost.post_type = 'pronamic_payment'\n\t\t\t\t\t\t\tAND\n\t\t\t\t\t\tpost.post_status = 'payment_completed'\n\t\t\t\t\t\t\tAND\n\t\t\t\t\t\tmeta_source.meta_value = 'payment_form'\n\t\t\t\t\t\t\tAND\n\t\t\t\t\t\tmeta_source_id.meta_value = %s\n\t\t\t\t\tGROUP BY\n\t\t\t\t\t\tpost.ID\n\t\t\t\t\t;", $post_id); $value = $wpdb->get_var($query); echo esc_html(number_format_i18n($value)); break; case 'pronamic_payment_form_earnings': global $wpdb; $query = $wpdb->prepare("\n\t\t\t\t\tSELECT\n\t\t\t\t\t\tSUM( meta_amount.meta_value ) AS value\n\t\t\t\t\tFROM\n\t\t\t\t\t\t{$wpdb->posts} AS post\n\t\t\t\t\t\t\tLEFT JOIN\n\t\t\t\t\t\t{$wpdb->postmeta} AS meta_amount\n\t\t\t\t\t\t\t\tON post.ID = meta_amount.post_id AND meta_amount.meta_key = '_pronamic_payment_amount'\n\t\t\t\t\t\t\tLEFT JOIN\n\t\t\t\t\t\t{$wpdb->postmeta} AS meta_source\n\t\t\t\t\t\t\t\tON post.ID = meta_source.post_id AND meta_source.meta_key = '_pronamic_payment_source'\n\t\t\t\t\t\t\tLEFT JOIN\n\t\t\t\t\t\t{$wpdb->postmeta} AS meta_source_id\n\t\t\t\t\t\t\t\tON post.ID = meta_source_id.post_id AND meta_source_id.meta_key = '_pronamic_payment_source_id'\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tpost.post_type = 'pronamic_payment'\n\t\t\t\t\t\t\tAND\n\t\t\t\t\t\tpost.post_status = 'payment_completed'\n\t\t\t\t\t\t\tAND\n\t\t\t\t\t\tmeta_source.meta_value = 'payment_form'\n\t\t\t\t\t\t\tAND\n\t\t\t\t\t\tmeta_source_id.meta_value = %s\n\t\t\t\t\tGROUP BY\n\t\t\t\t\t\tpost.ID\n\t\t\t\t\t;", $post_id); $value = $wpdb->get_var($query); echo '€', ' ', esc_html(number_format_i18n($value, 2)); break; case 'pronamic_payment_form_shortcode': printf('<input onclick="this.setSelectionRange( 0, this.value.length )" type="text" class="pronamic-pay-shortcode-input" readonly="" value="%s" />', esc_attr($this->get_shortcode($post_id))); break; } }
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 }
/** * Stop the timer * * @param int $precision number of digits after the decimal point * @return int $timetotal total timed * * Notes: Measured in seconds / Function borrowed from Wordpress.org */ function timer_stop($precision = 4, $name = 'default') { global $timestart; $timetotal = microtime(TRUE) - $timestart[$name]; $r = function_exists('number_format_i18n') ? number_format_i18n($timetotal, $precision) : number_format($timetotal, $precision); return $r; }
protected function get_views() { global $wpdb, $post_mime_types, $avail_post_mime_types; $type_links = array(); $_num_posts = (array) wp_count_attachments(); $_total_posts = array_sum($_num_posts) - $_num_posts['trash']; $total_orphans = $wpdb->get_var("SELECT COUNT( * ) FROM {$wpdb->posts} WHERE post_type = 'attachment' AND post_status != 'trash' AND post_parent < 1"); $matches = wp_match_mime_types(array_keys($post_mime_types), array_keys($_num_posts)); foreach ($matches as $type => $reals) { foreach ($reals as $real) { $num_posts[$type] = isset($num_posts[$type]) ? $num_posts[$type] + $_num_posts[$real] : $_num_posts[$real]; } } $selected = empty($_GET['attachment-filter']) ? ' selected="selected"' : ''; $type_links['all'] = "<option value=''{$selected}>" . sprintf(_nx('All (%s)', 'All (%s)', $_total_posts, 'uploaded files'), number_format_i18n($_total_posts)) . '</option>'; foreach ($post_mime_types as $mime_type => $label) { if (!wp_match_mime_types($mime_type, $avail_post_mime_types)) { continue; } $selected = ''; if (!empty($_GET['attachment-filter']) && strpos($_GET['attachment-filter'], 'post_mime_type:') === 0 && wp_match_mime_types($mime_type, str_replace('post_mime_type:', '', $_GET['attachment-filter']))) { $selected = ' selected="selected"'; } if (!empty($num_posts[$mime_type])) { $type_links[$mime_type] = '<option value="post_mime_type:' . esc_attr($mime_type) . '"' . $selected . '>' . sprintf(translate_nooped_plural($label[2], $num_posts[$mime_type]), number_format_i18n($num_posts[$mime_type])) . '</option>'; } } $type_links['detached'] = '<option value="detached"' . ($this->detached ? ' selected="selected"' : '') . '>' . sprintf(_nx('Unattached (%s)', 'Unattached (%s)', $total_orphans, 'detached files'), number_format_i18n($total_orphans)) . '</option>'; $type_links['uncategorized'] = '<option value="uncategorized"' . ($this->uncategorized ? ' selected="selected"' : '') . '>' . __('All Uncategorized', 'eml') . '</option>'; if (!empty($_num_posts['trash'])) { $type_links['trash'] = '<option value="trash"' . (isset($_GET['attachment-filter']) && $_GET['attachment-filter'] == 'trash' ? ' selected="selected"' : '') . '>' . sprintf(_nx('Trash (%s)', 'Trash (%s)', $_num_posts['trash'], 'uploaded files'), number_format_i18n($_num_posts['trash'])) . '</option>'; } return $type_links; }
function customize_registering($wp_customize) { global $xili_language; // in_nav_menu $locations = get_registered_nav_menus(); $menus = wp_get_nav_menus(); $menu_locations = get_nav_menu_locations(); $num_locations = count(array_keys($locations)); if ($num_locations >= 1 && count($menu_locations) >= 1) { $wp_customize->add_section('xili_options_section', array('title' => __('Multilingual Options ©xili', 'xili-language'), 'priority' => 300, 'description' => sprintf(_n('Your theme supports %s menu. Customize style.', 'Your theme supports %s menus. Customize style.', $num_locations, 'xili-language'), number_format_i18n($num_locations)) . "\n\n" . __('You can edit your menu content on the Menus screen in the Appearance section.'))); $location_slugs = array_keys($locations); if (0 == $xili_language->has_languages_list_menu($location_slugs[0])) { // only test one menu during transition $wp_customize->add_setting('xili_language_settings[in_nav_menu]', array('default' => '', 'transport' => 'refresh', 'type' => 'option', 'capability' => $this->capability)); $wp_customize->add_control('in_nav_menu', array('settings' => 'xili_language_settings[in_nav_menu]', 'label' => __('Append the languages', 'xili-language'), 'section' => 'xili_options_section', 'type' => 'radio', 'choices' => array('disable' => __('No languages menu-items', 'xili-language'), 'enable' => __('Show languages menu-items', 'xili-language')))); $wp_customize->add_setting('xili_language_settings[nav_menu_separator]', array('default' => '|', 'transport' => 'refresh', 'type' => 'option', 'capability' => $this->capability)); $wp_customize->add_control('nav_menu_separator', array('settings' => 'xili_language_settings[nav_menu_separator]', 'label' => __('Separator before language list (Character or Entity Number or Entity Name)', 'xili-language'), 'section' => 'xili_options_section', 'type' => 'text')); } if (!current_theme_supports('custom_xili_flag')) { $wp_customize->add_setting($this->settings_name . '[no_flags]', array('default' => '', 'transport' => 'refresh', 'type' => 'option', 'capability' => $this->capability)); $wp_customize->add_control('no_flags', array('settings' => $this->settings_name . '[no_flags]', 'label' => __('Hide the flags', 'xili-language'), 'section' => 'xili_options_section', 'type' => 'checkbox')); } } else { $wp_customize->add_section('xili_options_section', array('title' => __('Multilingual Options ©xili', 'xili-language'), 'priority' => 300, 'description' => __('None nav menus location seems active', 'xili-language'))); } $wp_customize->add_setting($this->settings_name . '[linked_posts]', array('default' => '', 'transport' => 'refresh', 'type' => 'option', 'capability' => $this->capability)); $wp_customize->add_control('linked_posts', array('settings' => $this->settings_name . '[linked_posts]', 'label' => __('Show linked posts', 'xili-language'), 'section' => 'xili_options_section', 'type' => 'checkbox')); }
/** * * RETINA DASHBOARD * */ function wr2x_admin_menu_dashboard() { $refresh = isset($_GET['refresh']) ? $_GET['refresh'] : 0; $clearlogs = isset($_GET['clearlogs']) ? $_GET['clearlogs'] : 0; $ignore = isset($_GET['ignore']) ? $_GET['ignore'] : false; if ($ignore) { if (!wr2x_is_pro()) { echo "<div class='error' style='margin-top: 20px;'><p>"; _e("Ignore is a Pro feature.", 'wp-retina-2x'); echo "</p></div>"; } else { wr2x_add_ignore($ignore); } } if ($refresh) { wr2x_calculate_issues(); } if ($clearlogs) { if (file_exists(plugin_dir_path(__FILE__) . '/wp-retina-2x.log')) { unlink(plugin_dir_path(__FILE__) . '/wp-retina-2x.log'); } } $flagged = count(wr2x_get_issues()); $warning_title = __("Retina images", 'wp-retina-2x'); $menu_label = sprintf(__('Retina %s'), "<span class='update-plugins count-{$flagged}' title='{$warning_title}'><span class='update-count'>" . number_format_i18n($flagged) . "</span></span>"); add_media_page('Retina', $menu_label, 'manage_options', 'wp-retina-2x', 'wpr2x_wp_retina_2x'); }
/** * Pagination * * Echoes the pagination for the theme. * * @return string * @access private * @since 1.0 */ function digitalstore_pagination($range = 4, $return = false, $_wp_query = null) { global $paged, $wp_query, $wp_rewrite; $wpq = $_wp_query ? $_wp_query : $wp_query; $max_page = $wpq->max_num_pages; $paged = $paged ? $paged : 1; $wp_query->query_vars['paged'] > 1 ? $current = $wp_query->query_vars['paged'] : ($current = 1); $out = '<p class="digitalstore-pagination">'; $pages_text = sprintf(__('Page %d of %d', 'edd-digitalstore'), number_format_i18n($paged), number_format_i18n($max_page)); $out .= '<span class="pages">' . $pages_text . '</span>'; $pagination = array('base' => esc_url(add_query_arg('paged', '%#%')), 'format' => '', 'total' => $wp_query->max_num_pages, 'current' => $current, 'end_size' => $range, 'prev_text' => __('«', 'edd-digitalstore'), 'next_text' => __('»', 'edd-digitalstore'), 'type' => 'plain'); if ($wp_rewrite->using_permalinks()) { $base_url = get_pagenum_link(1); if (is_search()) { $base_url = preg_replace('/\\?.*/', '', $base_url); } $pagination['base'] = user_trailingslashit(trailingslashit(esc_url(remove_query_arg(array('s'), $base_url))) . 'page/%#%/', 'paged'); } if (!empty($wp_query->query_vars['s'])) { $pagination['add_args'] = array('s' => get_query_var('s')); } $out .= paginate_links($pagination); $out .= '</p>'; if ($return) { return $out; } else { echo $out; } }
public function menu_item() { global $wpdb, $blog_id, $eshopoptions, $post; $eshopsize = 0; $eshopqty = 0; $thetotal = 0; $eshoptotal = 0; if (isset($_SESSION['eshopcart' . $blog_id])) { $eshopcartarray = $_SESSION['eshopcart' . $blog_id]; $currsymbol = $eshopoptions['currency_symbol']; } if (isset($_SESSION['eshopcart' . $blog_id])) { $eshopsize = sizeof($_SESSION['eshopcart' . $blog_id]); foreach ($_SESSION['eshopcart' . $blog_id] as $eshopdo => $eshopwop) { $eshopqty += $eshopwop['qty']; } } if (isset($_SESSION['final_price' . $blog_id]) && isset($_SESSION['eshopcart' . $blog_id])) { //should be working but there seems to be an eShop bug in storing the final_price value (doesn't multiply with quantity) //$thetotal=$_SESSION['final_price'.$blog_id]; $eshopcart = $_SESSION['eshopcart' . $blog_id]; $thetotal = 0; foreach ($eshopcart as $eshopcart_item) { $thetotal += $eshopcart_item['qty'] * $eshopcart_item['price']; } $eshoptotal = sprintf(__('%1$s%2$s', 'eshop'), $currsymbol, number_format_i18n($thetotal, __('2', 'eshop'))); } $menu_item = array('cart_url' => get_permalink($eshopoptions['cart']), 'shop_page_url' => get_home_url(), 'cart_contents_count' => $eshopqty, 'cart_total' => $eshoptotal); return $menu_item; }
/** * Returns a set of image attachment links based on size. * * @since 1.0.0 * @access public * @return string */ function hoot_get_image_size_links() { /* If not viewing an image attachment page, return. */ if (!wp_attachment_is_image(get_the_ID())) { return; } /* Set up an empty array for the links. */ $links = array(); /* Get the intermediate image sizes and add the full size to the array. */ $sizes = get_intermediate_image_sizes(); $sizes[] = 'full'; /* Loop through each of the image sizes. */ foreach ($sizes as $size) { /* Get the image source, width, height, and whether it's intermediate. */ $image = wp_get_attachment_image_src(get_the_ID(), $size); /* Add the link to the array if there's an image and if $is_intermediate (4th array value) is true or full size. */ if (!empty($image) && (true === $image[3] || 'full' == $size)) { /* Translators: Media dimensions - 1 is width and 2 is height. */ $label = sprintf(__('%1$s × %2$s', 'chromatic'), number_format_i18n(absint($image[1])), number_format_i18n(absint($image[2]))); $links[] = sprintf('<a class="image-size-link">%s</a>', $label); } } /* Join the links in a string and return. */ return join(' <span class="sep">/</span> ', $links); }
function wp_star_rating($args = array()) { $defaults = array('rating' => 0, 'type' => 'rating', 'number' => 0); $r = wp_parse_args($args, $defaults); // Non-english decimal places when the $rating is coming from a string $rating = str_replace(',', '.', $r['rating']); // Convert Percentage to star rating, 0..5 in .5 increments if ('percent' == $r['type']) { $rating = round($rating / 10, 0) / 2; } // Calculate the number of each type of star needed $full_stars = floor($rating); $half_stars = ceil($rating - $full_stars); $empty_stars = 5 - $full_stars - $half_stars; if ($r['number']) { /* translators: 1: The rating, 2: The number of ratings */ $format = _n('%1$s rating based on %2$s rating', '%1$s rating based on %2$s ratings', $r['number']); $title = sprintf($format, number_format_i18n($rating, 1), number_format_i18n($r['number'])); } else { /* translators: 1: The rating */ $title = sprintf(__('%s rating'), number_format_i18n($rating, 1)); } echo '<div class="star-rating" title="' . esc_attr($title) . '">'; echo '<span class="screen-reader-text">' . $title . '</span>'; echo str_repeat('<div class="star star-full"></div>', $full_stars); echo str_repeat('<div class="star star-half"></div>', $half_stars); echo str_repeat('<div class="star star-empty"></div>', $empty_stars); echo '</div>'; }
function showhide_shortcode($atts, $content = null) { // Variables $post_id = get_the_id(); $word_count = number_format_i18n(sizeof(explode(' ', strip_tags($content)))); // Extract ShortCode Attributes $attributes = shortcode_atts(array('type' => 'pressrelease', 'more_text' => __('Show Press Release (%s More Words)', 'wp-showhide'), 'less_text' => __('Hide Press Release (%s Less Words)', 'wp-showhide'), 'hidden' => 'yes'), $atts); // More/Less Text $more_text = sprintf($attributes['more_text'], $word_count); $less_text = sprintf($attributes['less_text'], $word_count); // Determine Whether To Show Or Hide Press Release $hidden_class = 'sh-hide'; $hidden_css = 'display: none;'; $hidden_aria_expanded = 'false'; if ($attributes['hidden'] === 'no') { $hidden_class = 'sh-show'; $hidden_css = 'display: block;'; $hidden_aria_expanded = 'true'; $tmp_text = $more_text; $more_text = $less_text; $less_text = $tmp_text; } // Format HTML Output $output = '<div id="' . $attributes['type'] . '-link-' . $post_id . '" class="sh-link ' . $attributes['type'] . '-link ' . $hidden_class . '"><a href="#" onclick="showhide_toggle(\'' . esc_js($attributes['type']) . '\', ' . $post_id . ', \'' . esc_js($more_text) . '\', \'' . esc_js($less_text) . '\'); return false;" aria-expanded="' . $hidden_aria_expanded . '"><span id="' . $attributes['type'] . '-toggle-' . $post_id . '">' . $more_text . '</span></a></div>'; $output .= '<div id="' . $attributes['type'] . '-content-' . $post_id . '" class="sh-content ' . $attributes['type'] . '-content ' . $hidden_class . '" style="' . $hidden_css . '">' . do_shortcode($content) . '</div>'; return $output; }
function get_views() { global $wpdb, $post_mime_types, $avail_post_mime_types; $type_links = array(); $_num_posts = (array) wp_count_attachments(); $_total_posts = array_sum($_num_posts) - $_num_posts['trash']; if (!isset($total_orphans)) { $total_orphans = $wpdb->get_var("SELECT COUNT( * ) FROM {$wpdb->posts} WHERE post_type = 'attachment' AND post_status != 'trash' AND post_parent < 1"); } $matches = wp_match_mime_types(array_keys($post_mime_types), array_keys($_num_posts)); foreach ($matches as $type => $reals) { foreach ($reals as $real) { $num_posts[$type] = isset($num_posts[$type]) ? $num_posts[$type] + $_num_posts[$real] : $_num_posts[$real]; } } $class = empty($_GET['post_mime_type']) && !isset($_GET['status']) ? ' class="current"' : ''; $type_links['all'] = "<a href='upload.php'{$class}>" . sprintf(_nx('All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $_total_posts, 'uploaded files'), number_format_i18n($_total_posts)) . '</a>'; foreach ($post_mime_types as $mime_type => $label) { $class = ''; if (!wp_match_mime_types($mime_type, $avail_post_mime_types)) { continue; } if (!empty($_GET['post_mime_type']) && wp_match_mime_types($mime_type, $_GET['post_mime_type'])) { $class = ' class="current"'; } if (!empty($num_posts[$mime_type])) { $type_links[$mime_type] = "<a href='upload.php?post_mime_type={$mime_type}'{$class}>" . sprintf(translate_nooped_plural($label[2], $num_posts[$mime_type]), number_format_i18n($num_posts[$mime_type])) . '</a>'; } } if (!empty($_num_posts['trash'])) { $type_links['trash'] = '<a href="upload.php?status=trash"' . (isset($_GET['status']) && $_GET['status'] == 'trash' ? ' class="current"' : '') . '>' . sprintf(_nx('Trash <span class="count">(%s)</span>', 'Trash <span class="count">(%s)</span>', $_num_posts['trash'], 'uploaded files'), number_format_i18n($_num_posts['trash'])) . '</a>'; } return array(); }
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 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 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 ''; } }
function get_views() { global $wp_roles, $role; if ($this->is_site_users) { $url = 'site-users.php?id=' . $this->site_id; switch_to_blog($this->site_id); $users_of_blog = count_users(); restore_current_blog(); } else { $url = 'users.php'; $users_of_blog = count_users(); } $total_users = $users_of_blog['total_users']; $avail_roles =& $users_of_blog['avail_roles']; unset($users_of_blog); $current_role = false; $class = empty($role) ? ' class="current"' : ''; $role_links = array(); $role_links['all'] = "<a href='{$url}'{$class}>" . sprintf(_nx('All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_users, 'users'), number_format_i18n($total_users)) . '</a>'; foreach ($wp_roles->get_names() as $this_role => $name) { if (!isset($avail_roles[$this_role])) { continue; } $class = ''; if ($this_role == $role) { $current_role = $role; $class = ' class="current"'; } $name = translate_user_role($name); /* translators: User role name with count */ $name = sprintf(__('%1$s <span class="count">(%2$s)</span>'), $name, $avail_roles[$this_role]); $role_links[$this_role] = "<a href='" . add_query_arg('role', $this_role, $url) . "'{$class}>{$name}</a>"; } return $role_links; }
function sfw_comment_form_extra_fields() { global $post, $sfw_options; $pwd = get_post_meta($post->ID, 'sfw_pwd', true); // If the reader is logged in don't require password for comments.php if (!is_user_logged_in()) { echo '<!-- ' . number_format_i18n(get_option('sfw_spam_hits')); _e(' Spam Comments Blocked so far by ', 'spam-free-wordpress'); echo 'Spam Free Wordpress'; _e(' version ', 'spam-free-wordpress'); echo SFW_VERSION; _e(' located at ', 'spam-free-wordpress'); echo "https://www.toddlahman.com/shop/simple-comments/ -->\n"; if ($sfw_options['legacy_pwd'] == 'on') { // Reader must enter this password manually on the comment form echo "<p><input type='text' value='" . $pwd . "' onclick='this.select()' size='20' />\n\t\t<b>* Copy This Password *</b></p>"; echo "<p><input type='text' name='passthis' id='passthis' value='' size='20' />\n\t\t<b>* Type Or Paste Password Here *</b></p>"; } } if ($sfw_options['spam_stats'] == 'on') { echo '<p>' . number_format_i18n(get_option('sfw_spam_hits')); _e(' Spam Comments Blocked so far by ', 'spam-free-wordpress'); echo '<a href="https://www.toddlahman.com/shop/simple-comments/" title="Spam Free Wordpress" target="_blank">Spam Free Wordpress</a></p>' . "\n"; } }
/** * 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>'; } }
/** * 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 do_paging() { if ($this->total_users_for_query > $this->users_per_page) { // have to page the results $args = array(); if (!empty($this->search_term)) { $args['s'] = urlencode($this->search_term); } if (!empty($this->role)) { $args['role'] = urlencode($this->role); } if (!empty($this->sub_id)) { $args['sub_op'] = urlencode($this->sub_id); $args['doactionsub'] = 'Filter'; } if (!empty($this->level_id)) { $args['level_op'] = urlencode($this->level_id); $args['doactionlevel'] = 'Filter'; } $this->paging_text = paginate_links(array('total' => ceil($this->total_users_for_query / $this->users_per_page), 'current' => $this->page, 'base' => 'admin.php?page=membershipmembers&%_%', 'format' => 'userspage=%#%', 'add_args' => $args)); if ($this->paging_text) { $this->paging_text = sprintf('<span class="displaying-num">' . __('Displaying %s–%s of %s', 'membership') . '</span>%s', number_format_i18n(($this->page - 1) * $this->users_per_page + 1), number_format_i18n(min($this->page * $this->users_per_page, $this->total_users_for_query)), number_format_i18n($this->total_users_for_query), $this->paging_text); } } }
function ajax_response() { check_ajax_referer('ajax-custom-list-nonce', '_ajax_custom_list_nonce'); $this->prepare_items(); extract($this->_args); extract($this->_pagination_args, EXTR_SKIP); ob_start(); if (!empty($_REQUEST['no_placeholder'])) { $this->display_rows(); } else { $this->display_rows_or_placeholder(); } $rows = ob_get_clean(); ob_start(); $this->print_column_headers(); $headers = ob_get_clean(); ob_start(); $this->pagination('top'); $pagination_top = ob_get_clean(); ob_start(); $this->pagination('bottom'); $pagination_bottom = ob_get_clean(); $response = array('rows' => $rows); $response['pagination']['top'] = $pagination_top; $response['pagination']['bottom'] = $pagination_bottom; $response['column_headers'] = $headers; if (isset($total_items)) { $response['total_items_i18n'] = sprintf(_n('1 item', '%s items', $total_items), number_format_i18n($total_items)); } if (isset($total_pages)) { $response['total_pages'] = $total_pages; $response['total_pages_i18n'] = number_format_i18n($total_pages); } die(wp_json_encode($response)); }
function get_pager_links($page_url = '', $args = array()) { global $wpdb; // page url if ($page_url) { $this->page_url = $page_url; } // total $this->row_count = $wpdb->get_var("SELECT FOUND_ROWS() AS row_count"); // page count $this->page_count = ceil($this->row_count / $this->page_limit); // text $paging_text = ''; // when greater if ($this->row_count > $this->page_limit) { // have to page the results // text $paging_text = paginate_links(array('total' => $this->page_count, 'current' => $this->page_current, 'base' => $this->page_url . (!preg_match('/\\?/', $this->page_url) ? '?' : '&') . '%_%', 'format' => $this->page_no . '=%#%', 'add_args' => $args)); // format if ($paging_text) { $paging_text = sprintf('<span class="displaying-num">' . __('Displaying %d-%d of %d records ', 'mgm') . '</span> %s', number_format_i18n(($this->page_current - 1) * $this->page_limit + 1), number_format_i18n(min($this->page_current * $this->page_limit, $this->row_count)), number_format_i18n($this->row_count), $paging_text); } } // return return str_replace('page-numbers', '', $paging_text); }
/** * Load and show optin stats. * * @return void */ public function showOptinStats() { ?> <div class="op-bsw-grey-panel-content op-bsw-grey-panel-no-sidebar cf" style="display: block;"> <label><?php _e('Total Optins from OptimizePress', 'optimizepress'); ?> </label> <h2 style="color: #004a80; text-align: center;"><?php printf('%s', number_format_i18n(op_optin_stats_get_local_total_count())); ?> </h2> <p class="op-micro-copy"><?php printf(__('<small>(since %s)</small>', 'optimizepress'), date_i18n(get_option('date_format'), strtotime(OptimizePress_Optin_Stats::SINCE_DATE))); ?> </p> <?php if (op_optin_stats_get_local_data()) { ?> <hr /> <label><?php _e('Optins per month', 'optimizepress'); ?> </label> <div id="optin_stats_chart" style="height: 300px; width: 437px;"></div> <div class="clear"></div> <?php } ?> </div> <?php }
/** * Returns an array of search suggestions from the unofficial completion API located * at the endpoint specified in this class. &q=query * * Parses the output into an array of associative arrays with keys of term, volume and * current. "current" is a boolean that determines whether the result in question is the searched * for term. * * @return array|WP_Error WP_Error if something goes wrong. Otherwise, an array as described above. */ public static function get_suggestions($search_term) { $search_term = trim($search_term); if (empty($search_term)) { return new WP_Error('empty_term', __('Please provide a search term.', 'scribeseo')); } $response = wp_remote_get(add_query_arg(array('q' => urlencode($search_term)), self::ENDPOINT)); if (is_wp_error($response)) { return $response; } $result = array(); // turn on user error handing $user_errors = libxml_use_internal_errors(true); $complete_suggestions = simplexml_load_string(wp_remote_retrieve_body($response)); // get any errors $xml_errors = libxml_get_errors(); // restore error handling setting libxml_use_internal_errors($user_errors); if (!empty($xml_errors)) { return new WP_Error('xml_error', __('The XML from the Google Completion API could not be loaded appropriately.', 'scribeseo')); } $complete_suggestions_po = json_decode(json_encode($complete_suggestions)); if (!is_object($complete_suggestions_po) || !isset($complete_suggestions_po->CompleteSuggestion)) { return new WP_Error('xml_error', __('The XML from the Google Completion API could not be loaded appropriately.', 'scribeseo')); } foreach ($complete_suggestions_po->CompleteSuggestion as $suggestion) { $term = $suggestion->suggestion->{'@attributes'}->data; $volume = intval($suggestion->num_queries->{'@attributes'}->int); $volume_nice = number_format_i18n($volume); $current = $term == $search_term; $result[] = compact('term', 'volume', 'volume_nice', 'current'); } return $result; }
function vwplk_get_like_button($post_id) { $likes_count = intval(get_post_meta($post_id, 'vw_post_likes', true)); $output = '<i class="icon-entypo-heart"></i>'; $output .= '<span class="vw-post-likes-count">' . number_format_i18n($likes_count) . '</span>'; return $output; }
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"; } } } }
/** * Start the element output. * @param string $output Passed by reference. Used to append additional content. * @param object $object The data object. * @param int $depth Depth of the item. * @param array $args An array of additional arguments. * @param int $current_object_id ID of the current item. */ function start_el(&$output, $category, $depth = 0, $args = array(), $id = 0) { extract($args); $cat_name = esc_attr($category->name); $cat_name = apply_filters('list_cats', $cat_name, $category); $link = '<a href="' . esc_url(get_term_link($category)) . '" '; if ($use_desc_for_title == 0 || empty($category->description)) { $link .= 'title="' . esc_attr(sprintf(__('View all posts filed under %s', ZF_WORDPRESS_CATEGORY_ACCORDION_LANG), $cat_name)) . '"'; } else { $link .= 'title="' . esc_attr(strip_tags(apply_filters('category_description', $category->description, $category))) . '"'; } $link .= ' class="item-link"'; $link .= '>'; $link .= $cat_name; if ($show_count) { $link .= ' <span class="count">(' . number_format_i18n($category->count) . ')</span>'; } $link .= '</a>'; $output .= "\t<li"; $class = 'cat-item cat-item-' . $category->term_id . ' level-' . $depth; if ($has_children) { $class .= ' has-sub'; } if (!empty($current_category)) { $_current_category = get_term($current_category, $category->taxonomy); if ($category->term_id == $current_category) { $class .= ' current-cat'; } elseif ($category->term_id == $_current_category->parent) { $class .= ' current-cat-parent'; } } $output .= ' class="' . $class . '"'; $output .= ">{$link}\n"; }