本文整理汇总了PHP中_nx函数的典型用法代码示例。如果您正苦于以下问题:PHP _nx函数的具体用法?PHP _nx怎么用?PHP _nx使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_nx函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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();
}
示例2: get_views
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;
}
示例3: get_views
function get_views()
{
global $wpdb;
$status_links = array();
$post_types = get_post_types(array('public' => true, 'exclude_from_search' => false));
$post_types = "'" . implode("', '", $post_types) . "'";
$states = get_post_stati(array('show_in_admin_all_list' => true));
$states['trash'] = 'trash';
$all_states = "'" . implode("', '", $states) . "'";
$total_posts = $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->posts} WHERE post_status IN ({$all_states}) AND post_type IN ({$post_types})");
$class = empty($_REQUEST['post_status']) ? ' class="current"' : '';
$status_links['all'] = "<a href='admin.php?page=seo_extended_titles'{$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_all_list' => true), 'objects') as $status) {
$status_name = $status->name;
$total = $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->posts} WHERE post_status IN ('{$status_name}') AND post_type IN ({$post_types})");
if ($total == 0) {
continue;
}
if (isset($_REQUEST['post_status']) && $status_name == $_REQUEST['post_status']) {
$class = ' class="current"';
} else {
$class = '';
}
$status_links[$status_name] = "<a href='admin.php?page=seo_extended_titles&post_status={$status_name}'{$class}>" . sprintf(translate_nooped_plural($status->label_count, $total), number_format_i18n($total)) . '</a>';
}
$trashed_posts = $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->posts} WHERE post_status IN ('trash') AND post_type IN ({$post_types})");
$class = isset($_REQUEST['post_status']) && 'trash' == $_REQUEST['post_status'] ? 'class="current"' : '';
$status_links['trash'] = "<a href='admin.php?page=seo_extended_titles&post_status=trash'{$class}>" . sprintf(_nx('Trash <span class="count">(%s)</span>', 'Trash <span class="count">(%s)</span>', $trashed_posts, 'posts'), number_format_i18n($trashed_posts)) . '</a>';
return $status_links;
}
示例4: get_views
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, number_format_i18n($avail_roles[$this_role]));
$role_links[$this_role] = "<a href='" . esc_url(add_query_arg('role', $this_role, $url)) . "'{$class}>{$name}</a>";
}
return $role_links;
}
示例5: 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;
}
示例6: _nx
public static function _nx($single, $plural, $number, $domain = null)
{
if (!$domain) {
$domain = Core::ID;
}
return \_nx($single, $plural, $number, $domain);
}
示例7: mh_cicero_lite_post_meta
function mh_cicero_lite_post_meta()
{
echo '<p class="entry-meta">' . "\n";
echo '<i class="fa fa-clock-o"></i><span class="updated">' . get_the_date() . '</span>' . "\n";
echo '<i class="fa fa-folder-open-o"></i><span class="entry-category">' . get_the_category_list(', ', '') . '</span>' . "\n";
echo '<i class="fa fa-comment-o"></i><span>' . sprintf(_nx('1 Comment', '%1$s Comments', get_comments_number(), 'comments number', 'mh-cicero-lite'), number_format_i18n(get_comments_number())) . '</span>' . "\n";
echo '</p>' . "\n";
}
示例8: mh_elegance_lite_post_meta
function mh_elegance_lite_post_meta()
{
echo '<p class="entry-meta">' . "\n";
echo sprintf(_x('Date: %s', 'post date', 'mh-elegance-lite'), '<span class="updated">' . get_the_date() . '</span><br>') . "\n";
echo sprintf(_x('Author: %s', 'post author', 'mh-elegance-lite'), '<span class="vcard author"><a class="fn" href="' . esc_url(get_author_posts_url(get_the_author_meta('ID'))) . '">' . esc_html(get_the_author()) . '</a></span><br>') . "\n";
echo __('Comments:', 'mh-elegance-lite') . ' <span>' . sprintf(_nx('1 Comment', '%1$s Comments', get_comments_number(), 'comments number', 'mh-elegance-lite'), number_format_i18n(get_comments_number())) . '</span><br>' . "\n";
echo sprintf(__('Categories: %s', 'mh-elegance-lite'), '<span>' . get_the_category_list(', ', '') . '</span>') . "\n";
echo '</p>' . "\n";
}
示例9: the_minimal_posted_on
/**
* Prints HTML with meta information for the current post-date/time and author.
*/
function the_minimal_posted_on()
{
$time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
$time_string = sprintf($time_string, esc_attr(get_the_date('c')), esc_html(get_the_date('F jS, Y')));
$posted_on = sprintf(esc_html_x('%s', 'post date', 'the-minimal'), '<a href="' . esc_url(get_permalink()) . '" rel="bookmark">' . $time_string . '</a>');
$byline = sprintf(esc_html_x('%s', 'post author', 'the-minimal'), '<span class="author vcard"><a class="url fn n" href="' . esc_url(get_author_posts_url(get_the_author_meta('ID'))) . '">' . esc_html(get_the_author()) . '</a></span>');
$comment_count = sprintf(_nx('1 Comment', '%1$s Comments', get_comments_number(), 'comments title', 'the-minimal'), number_format_i18n(get_comments_number()));
$comment = sprintf(esc_html_x('%s', 'post comment', 'the-minimal'), '<a href="' . esc_url(get_permalink()) . '" rel="bookmark">' . $comment_count . '</a>');
echo '<span class="date">' . $posted_on . '</span><span class="name">' . $byline . '</span><span class="comments">' . $comment . '</span>';
// WPCS: XSS OK.
}
示例10: get_views
protected function get_views()
{
global $role;
$total_users = get_user_count();
$super_admins = get_super_admins();
$total_admins = count($super_admins);
$class = $role != 'super' ? ' class="current"' : '';
$role_links = array();
$role_links['all'] = "<a href='" . network_admin_url('users.php') . "'{$class}>" . sprintf(_nx('All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_users, 'users'), number_format_i18n($total_users)) . '</a>';
$class = $role == 'super' ? ' class="current"' : '';
$role_links['super'] = "<a href='" . network_admin_url('users.php?role=super') . "'{$class}>" . sprintf(_n('Super Admin <span class="count">(%s)</span>', 'Super Admins <span class="count">(%s)</span>', $total_admins), number_format_i18n($total_admins)) . '</a>';
return $role_links;
}
示例11: addTranslationFunctions
/**
* Translation functions
*
* @param Twig $twig
*/
public function addTranslationFunctions($twig)
{
$twig->addFunction('_x', new Twig_SimpleFunction('_x', function ($text, $context, $domain = 'default') {
return _x($text, $context, $domain);
}));
$twig->addFunction('_n', new Twig_SimpleFunction('_n', function ($single, $plural, $number, $domain = 'default') {
return _n($single, $plural, $number, $domain);
}));
$twig->addFunction('_nx', new Twig_SimpleFunction('_nx', function ($single, $plural, $number, $context, $domain = 'default') {
return _nx($single, $plural, $number, $context, $domain);
}));
return $twig;
}
示例12: transChoice
public function transChoice($id, $number, array $parameters = [], $domain = null, $locale = null)
{
$domain = $domain !== null ? $domain : 'default';
$hasSingle = array_key_exists('single', $parameters) && $parameters['single'] !== null;
$hasPlural = array_key_exists('plural', $parameters) && $parameters['plural'] !== null;
$hasContext = array_key_exists('context', $parameters) && $parameters['context'] !== null;
$single = $hasSingle ? $parameters['single'] : $id;
$plural = $hasPlural ? $parameters['plural'] : $id;
$context = $hasContext ? $parameters['context'] : null;
if ($context !== null) {
return _nx($single, $plural, $number, $context, $domain);
}
return _n($single, $plural, $number, $domain);
}
示例13: generate_view
/**
* Generates a view link widget
*
* @param string $type The type of filtering (all, scheduled, pending)
* @param int $value Number of results
* @param string $current The current type selected (null for all)
*/
public function generate_view($type, $value, $current)
{
$all_inner_html = sprintf(_nx(ucfirst($type) . ' <span class="count">(%s)</span>', ucfirst($type) . ' <span class="count">(%s)</span>', $value, 'posts'), number_format_i18n($value));
$q_string = $type == 'all' ? '' : '&type=' . $type;
$class = '';
if ($type == 'all' && !$current) {
$class = ' class="current"';
} else {
if ($type == $current) {
$class = ' class="current"';
}
}
return "<a href='admin.php?page=smmp-list{$q_string}'{$class}>" . $all_inner_html . '</a>';
}
示例14: get_views
function get_views()
{
global $post_type_object, $locked_post_status, $avail_post_stati;
$post_type = $post_type_object->name;
if (!empty($locked_post_status)) {
return array();
}
$status_links = array();
$num_posts = wp_count_posts($post_type, 'readable');
$class = '';
$allposts = '';
$current_user_id = get_current_user_id();
if ($this->user_posts_count) {
if (isset($_GET['author']) && $_GET['author'] == $current_user_id) {
$class = ' class="current"';
}
$status_links['mine'] = "<a href='edit.php?post_type={$post_type}&author={$current_user_id}'{$class}>" . sprintf(_nx('Mine <span class="count">(%s)</span>', 'Mine <span class="count">(%s)</span>', $this->user_posts_count, 'posts'), number_format_i18n($this->user_posts_count)) . '</a>';
$allposts = '&all_posts=1';
}
$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($class) && empty($_REQUEST['post_status']) && empty($_REQUEST['show_sticky']) ? ' class="current"' : '';
$status_links['all'] = "<a href='edit.php?post_type={$post_type}{$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 (!in_array($status_name, $avail_post_stati)) {
continue;
}
if (empty($num_posts->{$status_name})) {
continue;
}
if (isset($_REQUEST['post_status']) && $status_name == $_REQUEST['post_status']) {
$class = ' class="current"';
}
$status_links[$status_name] = "<a href='edit.php?post_status={$status_name}&post_type={$post_type}'{$class}>" . sprintf(translate_nooped_plural($status->label_count, $num_posts->{$status_name}), number_format_i18n($num_posts->{$status_name})) . '</a>';
}
if (!empty($this->sticky_posts_count)) {
$class = !empty($_REQUEST['show_sticky']) ? ' class="current"' : '';
$sticky_link = array('sticky' => "<a href='edit.php?post_type={$post_type}&show_sticky=1'{$class}>" . sprintf(_nx('Sticky <span class="count">(%s)</span>', 'Sticky <span class="count">(%s)</span>', $this->sticky_posts_count, 'posts'), number_format_i18n($this->sticky_posts_count)) . '</a>');
// Sticky comes after Publish, or if not listed, after All.
$split = 1 + array_search(isset($status_links['publish']) ? 'publish' : 'all', array_keys($status_links));
$status_links = array_merge(array_slice($status_links, 0, $split), $sticky_link, array_slice($status_links, $split));
}
return $status_links;
}
示例15: widget
function widget($args, $instance)
{
global $post;
/* PRINT THE WIDGET */
extract($args, EXTR_SKIP);
$instance = wp_parse_args((array) $instance, array('title' => ''));
$title = $instance['title'];
if (!is_single()) {
return;
}
echo $before_widget;
if (!empty($title)) {
echo $before_title;
echo apply_filters('widget_title', esc_attr($title), $instance, $this->id_base);
echo $after_title;
}
$y = esc_attr(get_post_time('Y', false, $post->ID));
$m = esc_attr(get_post_time('m', false, $post->ID));
$d = esc_attr(get_post_time('d', false, $post->ID));
$name = get_the_author_meta('display_name', $post->post_author);
$dtime = get_post_time('Y-m-d', false, $post->ID);
$ptime = get_post_time(esc_attr(get_option('date_format')), false, $post->ID, true);
echo '<div class="large-icons">';
echo '<ul>';
edit_post_link('<i class="icon-pencil"></i>' . __('Edit', 'treeson'), '<li>', '</li>');
echo '<li><a href="' . esc_url(get_day_link($y, $m, $d)) . '">';
echo '<time datetime="' . esc_attr($dtime) . '"><i class="icon-calendar"></i>' . esc_html($ptime) . '</time></a></li>';
echo '<li><a href="' . esc_url(get_author_posts_url($post->post_author)) . '" title="' . sprintf(__('Writed by %s', 'treeson'), esc_attr($name)) . '"><i class="icon-user-5"></i>' . esc_html($name) . '</a></li>';
if ($post->comment_status == 'open') {
$nr = get_comments_number($post->ID);
echo '<li>';
echo '<a href="' . esc_url(get_comments_link($post->ID)) . '">';
echo '<i class="icon-comment"></i>';
echo sprintf(_nx('%s Comment', '%s Comments', absint($nr), 'Number of comment(s) from widget "myThemes: Meta Details"', 'treeson'), number_format_i18n(absint($nr)));
echo '</a></li>';
}
if (function_exists('stats_get_csv')) {
$args = array('days' => -1, 'post_id' => $post->ID);
$result = stats_get_csv('postviews', $args);
$views = $result[0]['views'];
echo '<li><i class="icon-eye-2"></i> ' . sprintf(_n('%s view', '%s views', absint($views), 'treeson'), number_format_i18n(absint($views))) . '</li>';
}
echo '</ul>';
echo '</div>';
echo $after_widget;
}