当前位置: 首页>>代码示例>>PHP>>正文


PHP number_format_i18n函数代码示例

本文整理汇总了PHP中number_format_i18n函数的典型用法代码示例。如果您正苦于以下问题:PHP number_format_i18n函数的具体用法?PHP number_format_i18n怎么用?PHP number_format_i18n使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了number_format_i18n函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: add_portfolio_counts

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>';
    }
}
开发者ID:ConceptHaus,项目名称:huasca,代码行数:27,代码来源:portfolio.php

示例2: tptn_pop_display

/**
 *  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);
}
开发者ID:axovel,项目名称:tattoo,代码行数:46,代码来源:admin-dashboard.php

示例3: pagination

    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)), '&laquo;');
        $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), '&lsaquo;');
        $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), '&rsaquo;');
        $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, '&raquo;');
        $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
    }
开发者ID:johnleesw,项目名称:mustardseedwp,代码行数:32,代码来源:class-wp-stream-dashboard-widget.php

示例4: custom_columns

 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 '€', '&nbsp;', 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;
     }
 }
开发者ID:Charitable,项目名称:wp-pronamic-ideal,代码行数:29,代码来源:FormPostType.php

示例5: status_widget

    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 
    }
开发者ID:Charitable,项目名称:wp-pronamic-ideal,代码行数:34,代码来源:Dashboard.php

示例6: timer_stop

/**
 * 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;
}
开发者ID:hotarucms,项目名称:hotarucms,代码行数:15,代码来源:funcs.times.php

示例7: get_views

 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;
 }
开发者ID:vanlong200880,项目名称:uni,代码行数:34,代码来源:class-eml-media-list-table.php

示例8: customize_registering

 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'));
 }
开发者ID:ergov2015,项目名称:rideflag.dev,代码行数:28,代码来源:theme-multilingual-classes.php

示例9: wr2x_admin_menu_dashboard

/**
 *
 * 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');
}
开发者ID:shuramita,项目名称:dhsd,代码行数:32,代码来源:wr2x_retina-dashboard.php

示例10: digitalstore_pagination

/**
 * 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' => __('&laquo;', 'edd-digitalstore'), 'next_text' => __('&raquo;', '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;
    }
}
开发者ID:SelaInc,项目名称:Digital-Store,代码行数:38,代码来源:pagination.php

示例11: menu_item

 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;
 }
开发者ID:mselango,项目名称:driz-project,代码行数:30,代码来源:wpmenucart-eshop.php

示例12: hoot_get_image_size_links

/**
 * 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 &#215; %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);
}
开发者ID:acafourek,项目名称:maidstone,代码行数:32,代码来源:template-media.php

示例13: wp_star_rating

 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>';
 }
开发者ID:GvarimAZA,项目名称:website,代码行数:29,代码来源:recommended-plugins.php

示例14: showhide_shortcode

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;
}
开发者ID:raminabsari,项目名称:phonicsschool,代码行数:27,代码来源:wp-showhide.php

示例15: get_views

 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();
 }
开发者ID:sangikumar,项目名称:IP,代码行数:34,代码来源:class-frontend-uploader-wp-posts-list-table.php


注:本文中的number_format_i18n函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。