/**
 * @link https://core.trac.wordpress.org/ticket/29849
 */
function mb_natural_time($from, $to = '', $limit = 1)
{
    if (empty($to)) {
        $to = current_time('timestamp');
    }
    $diff = absint($to - $from);
    if ($diff < 1) {
        return apply_filters('mb_natural_time', _x('now', 'time ago', 'message-board'), $from, $to, $limit, $diff);
    }
    $result = array();
    $l10n = array(array(YEAR_IN_SECONDS, _nx_noop('%s year', '%s years', 'time ago', 'message-board')), array(30 * DAY_IN_SECONDS, _nx_noop('%s month', '%s months', 'time ago', 'message-board')), array(WEEK_IN_SECONDS, _nx_noop('%s week', '%s weeks', 'time ago', 'message-board')), array(DAY_IN_SECONDS, _nx_noop('%s day', '%s days', 'time ago', 'message-board')), array(HOUR_IN_SECONDS, _nx_noop('%s hour', '%s hours', 'time ago', 'message-board')), array(MINUTE_IN_SECONDS, _nx_noop('%s minute', '%s minutes', 'time ago', 'message-board')), array(1, _nx_noop('%s second', '%s seconds', 'time ago', 'message-board')));
    foreach ($l10n as $key => $pair) {
        $count = (int) ($diff / $pair[0]);
        if ($count > 0) {
            $result[] = sprintf(translate_nooped_plural($l10n[$key][1], $count), $count);
            $diff -= $count * $pair[0];
        }
        if ($limit && count($result) >= $limit) {
            break;
        }
    }
    $label = $to > $from ? _x('%s ago', 'time ago', 'message-board') : _x('%s from now', 'time from now', 'message-board');
    $result = implode(_x(', ', 'natural time separator', 'message-board'), $result);
    $result = sprintf($label, $result);
    return apply_filters('mb_natural_time', $result, $from, $to, $limit, $diff);
}
/**
 * Calculate the time difference - a replacement for `human_time_diff()` until it is improved.
 *
 * Based on BuddyPress function `bp_core_time_since()`, which in turn is based on functions created by
 * Dunstan Orchard - http://1976design.com
 *
 * This function will return an text representation of the time elapsed since a
 * given date, giving the two largest units e.g.:
 *
 *  - 2 hours and 50 minutes
 *  - 4 days
 *  - 4 weeks and 6 days
 *
 * @since 1.7.0
 *
 * @param $older_date int Unix timestamp of date you want to calculate the time since for`
 * @param $newer_date int Optional. Unix timestamp of date to compare older date to. Default false (current time)`
 *
 * @return str The time difference
 */
function dbz_human_time_diff($older_date, $newer_date = false, $timeunits = 1)
{
    //* If no newer date is given, assume now
    $newer_date = $newer_date ? $newer_date : time();
    $timeunits = $timeunits >= 2 ? 2 : 1;
    //* Difference in seconds
    $since = absint($newer_date - $older_date);
    if (!$since) {
        return '0 ' . _x('seconds', 'time difference', 'genesis');
    }
    //* Hold units of time in seconds, and their pluralised strings (not translated yet)
    $units = array(array(31536000, _nx_noop('%s year', '%s years', 'time difference', 'genesis')), array(2592000, _nx_noop('%s month', '%s months', 'time difference', 'genesis')), array(604800, _nx_noop('%s week', '%s weeks', 'time difference', 'genesis')), array(86400, _nx_noop('%s day', '%s days', 'time difference', 'genesis')), array(3600, _nx_noop('%s hour', '%s hours', 'time difference', 'genesis')), array(60, _nx_noop('%s minute', '%s minutes', 'time difference', 'genesis')), array(1, _nx_noop('%s second', '%s seconds', 'time difference', 'genesis')));
    //* Step one: the first unit
    for ($i = 0, $j = count($units); $i < $j; $i++) {
        $seconds = $units[$i][0];
        //* Finding the biggest chunk (if the chunk fits, break)
        if (($count = floor($since / $seconds)) != 0) {
            break;
        }
    }
    //* Translate unit string, and add to the output
    $output = sprintf(translate_nooped_plural($units[$i][1], $count, 'genesis'), $count);
    //* Note the next unit
    $ii = $i + 1;
    //* Step two: the second unit
    if ($ii < $j && $timeunits > 1) {
        $seconds2 = $units[$ii][0];
        //* Check if this second unit has a value > 0
        if (($count2 = floor(($since - $seconds * $count) / $seconds2)) !== 0) {
            //* Add translated separator string, and translated unit string
            $output .= sprintf(' %s ' . translate_nooped_plural($units[$ii][1], $count2, 'genesis'), _x('and', 'separator in time difference', 'genesis'), $count2);
        }
    }
    return $output;
}
 /**
  * @ticket 35961
  */
 function test_nx_noop()
 {
     $text_domain = 'text-domain';
     $nooped_plural = _nx_noop('%s post', '%s posts', 'my-context', $text_domain);
     $this->assertNotEmpty($nooped_plural['domain']);
     $this->assertNotEmpty($nooped_plural['context']);
     $this->assertEquals('%s posts', translate_nooped_plural($nooped_plural, 0, $text_domain));
     $this->assertEquals('%s post', translate_nooped_plural($nooped_plural, 1, $text_domain));
     $this->assertEquals('%s posts', translate_nooped_plural($nooped_plural, 2, $text_domain));
 }
function call_some_i18n_methods()
{
    __('Hello World', 'test-domain');
    _e('Hello World', 'test-domain');
    _n('Single', 'Plural', 1, 'test-domain');
    _n_noop('Single Noop', 'Plural Noop', 1, 'test-domain');
    _x('Hello World', 'Testing', 'test-domain');
    _ex('Hello World', 'Testing', 'test-domain');
    _nx('Hello World', 'Testing', 'test-domain');
    _nx_noop('Hello World Noop', 'Testing', 'test-domain');
    esc_attr__('Attribute', 'test-domain');
    esc_html__('HTML', 'test-domain');
    esc_attr_e('Attribute', 'test-domain');
    esc_html_e('HTML', 'test-domain');
    esc_attr_x('Attribute', 'Testing', 'test-domain');
    esc_html_x('HTML', 'Testing', 'test-domain');
    translate_nooped_plural('Plural Noop', 2, 'test-domain');
}
Exemple #5
0
 /**
  * Sets the current subscription payment plan status
  *
  * @author Jonathan Davis
  * @since 1.2
  *
  * @return void
  **/
 public function recurrences()
 {
     if (empty($this->option->recurring)) {
         return;
     }
     // if free subscription, don't process as subscription
     if (0 == $this->option->promoprice) {
         return;
     }
     extract($this->option->recurring);
     $term_labels = array('trial' => array('d' => _nx_noop("%s for the first day.", "%s for the first %s days.", "Trial term label: '\$10 for the first day.' or '\$5 for the first 10 days.'"), 'w' => _nx_noop("%s for the first week.", "%s for the first %s weeks.", "Trial term label: '\$10 for the first week.' or '\$5 for the first 10 weeks.'"), 'm' => _nx_noop("%s for the first month.", "%s for the first %s months.", "Trial term label: '\$10 for the first month.' or '\$5 for the first 10 months.'"), 'y' => _nx_noop("%s for the first year.", "%s for the first %s years.", "Trial term label: '\$10 for the first year.' or '\$5 for the first 10 years.'")), 'freetrial' => array('d' => _nx_noop("Free for the first day.", "Free for the first %s days.", "Free trial label."), 'w' => _nx_noop("Free for the first week.", "Free for the first %s weeks.", "Free trial label."), 'm' => _nx_noop("Free for the first month.", "Free for the first %s months.", "Free trial label."), 'y' => _nx_noop("Free for the first year.", "Free for the first %s years.", "Free trial label.")), 'aftertrial' => array('d' => _nx_noop("%s per day after the trial period.", "%s every %s days after the trial period.", "Subscription term label: '\$10 per day after the trial period.' or '\$5 every 10 days after the trial period.'"), 'w' => _nx_noop("%s per week after the trial period.", "%s every %s weeks after the trial period.", "Subscription term label: '\$10 per week after the trial period.' or '\$5 every 10 weeks after the trial period.'"), 'm' => _nx_noop("%s per month after the trial period.", "%s every %s months after the trial period.", "Subscription term label: '\$10 per month after the trial period.' or '\$5 every 10 months after the trial period.'"), 'y' => _nx_noop("%s per year after the trial period.", "%s every %s years after the trial period.", "Subscription term label: '\$10 per year after the trial period.' or '\$5 every 10 years after the trial period.'")), 'period' => array('d' => _nx_noop("%s per day.", "%s every %s days.", "Subscription term label: '\$10 per day.' or '\$5 every 10 days.'"), 'w' => _nx_noop("%s per week.", "%s every %s weeks.", "Subscription term label: '\$10 per week.' or '\$5 every 10 weeks.'"), 'm' => _nx_noop("%s per month.", "%s every %s months.", "Subscription term label: '\$10 per month.' or '\$5 every 10 months.'"), 'y' => _nx_noop("%s per year.", "%s every %s years.", "Subscription term label: '\$10 per year.' or '\$5 every 10 years.'")));
     $rebill_labels = array(0 => __('Subscription rebilled unlimited times.', 'Shopp'), 1 => _n_noop('Subscription rebilled once.', 'Subscription rebilled %s times.'));
     // Build Trial Label
     if (Shopp::str_true($trial)) {
         // pick untranlated label
         $trial_label = $trialprice > 0 ? $term_labels['trial'][$trialperiod] : $term_labels['freetrial'][$trialperiod];
         // pick singular or plural translation
         $trial_label = translate_nooped_plural($trial_label, $trialint, 'Shopp');
         // string replacements
         if ($trialprice > 0) {
             $trial_label = sprintf($trial_label, money($trialprice), $trialint);
         } else {
             $trial_label = sprintf($trial_label, $trialint);
         }
         $this->data[_x('Trial Period', 'Item trial period label', 'Shopp')] = $trial_label;
     }
     // pick untranslated label
     $normal = Shopp::str_true($trial) ? 'aftertrial' : 'period';
     $subscription_label = $term_labels[$normal][$period];
     // pick singular or plural translation
     $subscription_label = translate_nooped_plural($subscription_label, $interval);
     $subscription_label = sprintf($subscription_label, money($this->subprice), $interval);
     // pick rebilling label and translate if plurals
     $rebill_label = sprintf(translate_nooped_plural($rebill_labels[1], $cycles, 'Shopp'), $cycles);
     if (!$cycles) {
         $rebill_label = $rebill_labels[0];
     }
     $this->data[_x('Subscription', 'Subscription terms label', 'Shopp')] = array($subscription_label, $rebill_label);
     $this->recurring = true;
 }
Exemple #6
0
		}

		echo '<div id="moderated" class="updated"><p>' . implode( "<br/>\n", $messages ) . '</p></div>';
	}
}
?>

<form id="comments-form" action="" method="get">
<ul class="subsubsub">
<?php
$status_links = array();
$num_comments = ( $post_id ) ? wp_count_comments( $post_id ) : wp_count_comments();
//, number_format_i18n($num_comments->moderated) ), "<span class='comment-count'>" . number_format_i18n($num_comments->moderated) . "</span>"),
//, number_format_i18n($num_comments->spam) ), "<span class='spam-comment-count'>" . number_format_i18n($num_comments->spam) . "</span>")
$stati = array(
		'all' => _nx_noop('All', 'All', 'comments'), // singular not used
		'moderated' => _n_noop('Pending <span class="count">(<span class="pending-count">%s</span>)</span>', 'Pending <span class="count">(<span class="pending-count">%s</span>)</span>'),
		'approved' => _n_noop('Approved', 'Approved'), // singular not used
		'spam' => _n_noop('Spam <span class="count">(<span class="spam-count">%s</span>)</span>', 'Spam <span class="count">(<span class="spam-count">%s</span>)</span>'),
		'trash' => _n_noop('Trash <span class="count">(<span class="trash-count">%s</span>)</span>', 'Trash <span class="count">(<span class="trash-count">%s</span>)</span>')
	);

if ( !EMPTY_TRASH_DAYS )
	unset($stati['trash']);

$link = 'edit-comments.php';
if ( !empty($comment_type) && 'all' != $comment_type )
	$link = add_query_arg( 'comment_type', $comment_type, $link );

foreach ( $stati as $status => $label ) {
	$class = ( $status == $comment_status ) ? ' class="current"' : '';
 /**
  * Register the post statuses used by bbPress
  *
  * We do some manipulation of the 'trash' status so trashed topics and
  * replies can be viewed from within the theme.
  *
  * @since bbPress (r2727)
  * @uses register_post_status() To register post statuses
  * @uses $wp_post_statuses To modify trash and private statuses
  * @uses current_user_can() To check if the current user is capable &
  *                           modify $wp_post_statuses accordingly
  */
 public static function register_post_statuses()
 {
     // Closed
     register_post_status(bbp_get_closed_status_id(), apply_filters('bbp_register_closed_post_status', array('label' => _x('Closed', 'post', 'bbpress'), 'label_count' => _nx_noop('Closed <span class="count">(%s)</span>', 'Closed <span class="count">(%s)</span>', 'post', 'bbpress'), 'public' => true, 'show_in_admin_all' => true)));
     // Spam
     register_post_status(bbp_get_spam_status_id(), apply_filters('bbp_register_spam_post_status', array('label' => _x('Spam', 'post', 'bbpress'), 'label_count' => _nx_noop('Spam <span class="count">(%s)</span>', 'Spam <span class="count">(%s)</span>', 'post', 'bbpress'), 'protected' => true, 'exclude_from_search' => true, 'show_in_admin_status_list' => true, 'show_in_admin_all_list' => false)));
     // Orphan
     register_post_status(bbp_get_orphan_status_id(), apply_filters('bbp_register_orphan_post_status', array('label' => _x('Orphan', 'post', 'bbpress'), 'label_count' => _nx_noop('Orphan <span class="count">(%s)</span>', 'Orphans <span class="count">(%s)</span>', 'post', 'bbpress'), 'protected' => true, 'exclude_from_search' => true, 'show_in_admin_status_list' => true, 'show_in_admin_all_list' => false)));
     // Hidden
     register_post_status(bbp_get_hidden_status_id(), apply_filters('bbp_register_hidden_post_status', array('label' => _x('Hidden', 'post', 'bbpress'), 'label_count' => _nx_noop('Hidden <span class="count">(%s)</span>', 'Hidden <span class="count">(%s)</span>', 'post', 'bbpress'), 'private' => true, 'exclude_from_search' => true, 'show_in_admin_status_list' => true, 'show_in_admin_all_list' => true)));
     /**
      * Trash fix
      *
      * We need to remove the internal arg and change that to
      * protected so that the users with 'view_trash' cap can view
      * single trashed topics/replies in the front-end as wp_query
      * doesn't allow any hack for the trashed topics to be viewed.
      */
     global $wp_post_statuses;
     if (!empty($wp_post_statuses['trash'])) {
         // User can view trash so set internal to false
         if (current_user_can('view_trash')) {
             $wp_post_statuses['trash']->internal = false;
             $wp_post_statuses['trash']->protected = true;
             // User cannot view trash so set internal to true
         } else {
             $wp_post_statuses['trash']->internal = true;
         }
     }
 }
 public function get_views()
 {
     global $wpdb;
     $view_labels = array(1 => _nx_noop('Incomplete <span class="count">(%s)</span>', 'Incomplete <span class="count">(%s)</span>', 'purchase logs'), 2 => _nx_noop('Received <span class="count">(%s)</span>', 'Received <span class="count">(%s)</span>', 'purchase logs'), 3 => _nx_noop('Accepted <span class="count">(%s)</span>', 'Accepted <span class="count">(%s)</span>', 'purchase logs'), 4 => _nx_noop('Dispatched <span class="count">(%s)</span>', 'Dispatched <span class="count">(%s)</span>', 'purchase logs'), 5 => _nx_noop('Closed <span class="count">(%s)</span>', 'Closed <span class="count">(%s)</span>', 'purchase logs'), 6 => _nx_noop('Declined <span class="count">(%s)</span>', 'Declined <span class="count">(%s)</span>', 'purchase logs'));
     $sql = "SELECT DISTINCT processed, COUNT(*) AS count FROM " . WPSC_TABLE_PURCHASE_LOGS . " GROUP BY processed ORDER BY processed";
     $results = $wpdb->get_results($sql);
     $statuses = array();
     $total_count = 0;
     if (!empty($results)) {
         foreach ($results as $status) {
             $statuses[$status->processed] = $status->count;
         }
         $total_count = array_sum($statuses);
     }
     $all_text = sprintf(_nx('All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_count, 'purchase logs', 'wpsc'), number_format_i18n($total_count));
     $all_href = remove_query_arg(array('status', 'paged', 'action', 'action2', 'm', 'deleted', 'updated', 'paged', 's'));
     $all_class = $this->status == 'all' && empty($_REQUEST['m']) && empty($_REQUEST['s']) ? 'class="current"' : '';
     $views = array('all' => sprintf('<a href="%s" %s>%s</a>', esc_url($all_href), $all_class, $all_text));
     foreach ($statuses as $status => $count) {
         if (!isset($view_labels[$status])) {
             continue;
         }
         $text = sprintf(translate_nooped_plural($view_labels[$status], $count, 'wpsc'), number_format_i18n($count));
         $href = add_query_arg('status', $status);
         $href = remove_query_arg(array('deleted', 'updated', 'action', 'action2', 'm', 'paged', 's'), $href);
         $class = $this->status == $status ? 'class="current"' : '';
         $views[$status] = sprintf('<a href="%s" %s>%s</a>', esc_url($href), $class, $text);
     }
     return $views;
 }
 /**
  * Returns an associative array listing all the views that can be used with this table.
  *
  * @return array
  */
 function get_views()
 {
     global $post_id, $comment_status, $comment_type, $wpdb;
     $status_links = array();
     // Get commment (review) counts for eahc status
     $num_comments = $post_id ? wc_count_reviews($post_id) : wc_count_reviews();
     // Available status links, aka 'stati'
     $stati = array('all' => _nx_noop('All', 'All', 'comments', WC_Product_Reviews_Pro::TEXT_DOMAIN), 'moderated' => _n_noop('Pending <span class="count">(<span class="pending-count">%s</span>)</span>', 'Pending <span class="count">(<span class="pending-count">%s</span>)</span>', WC_Product_Reviews_Pro::TEXT_DOMAIN), 'approved' => _n_noop('Approved', 'Approved', WC_Product_Reviews_Pro::TEXT_DOMAIN), 'spam' => _n_noop('Spam <span class="count">(<span class="spam-count">%s</span>)</span>', 'Spam <span class="count">(<span class="spam-count">%s</span>)</span>', WC_Product_Reviews_Pro::TEXT_DOMAIN), 'trash' => _n_noop('Trash <span class="count">(<span class="trash-count">%s</span>)</span>', 'Trash <span class="count">(<span class="trash-count">%s</span>)</span>', WC_Product_Reviews_Pro::TEXT_DOMAIN));
     if (!EMPTY_TRASH_DAYS) {
         unset($stati['trash']);
     }
     // Prepare the base link
     $link = add_query_arg('page', 'reviews', 'admin.php');
     // Add comment type to the base link
     if (!empty($comment_type) && 'all' !== $comment_type) {
         $link = add_query_arg('comment_type', $comment_type, $link);
     }
     // Prepare status links and counts
     foreach ($stati as $status => $label) {
         $link = add_query_arg('comment_status', $status, $link);
         $class = $status == $comment_status ? ' class="current"' : '';
         if (!isset($num_comments->{$status})) {
             $num_comments->{$status} = 10;
         }
         // If viewing reviews for a specific product, add that to the link as well
         if ($post_id) {
             $link = add_query_arg('p', absint($post_id), $link);
         }
         // Translate and format link
         $status_links[$status] = "<a href='" . esc_url($link) . "'{$class}>" . sprintf(translate_nooped_plural($label, $num_comments->{$status}), number_format_i18n($num_comments->{$status})) . '</a>';
     }
     /**
      * Filter the review status links.
      *
      * @param array $status_links An array of fully-formed status links. Default 'All'.
      *                            Accepts 'All', 'Pending', 'Approved', 'Spam', and 'Trash'.
      */
     return apply_filters('review_status_links', $status_links);
 }
    }
    if (isset($_GET['action'])) {
        $sendback = remove_query_arg(array('action', 'action2', 'post_parent', 'page_template', 'post_author', 'comment_status', 'ping_status', '_status', 'post', 'bulk_edit', 'post_view', 'post_type'), $sendback);
    }
    wp_redirect($sendback);
    exit;
} elseif (isset($_GET['_wp_http_referer']) && !empty($_GET['_wp_http_referer'])) {
    wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI'])));
    exit;
}
if (empty($title)) {
    $title = __('Edit Pages');
}
$parent_file = 'edit-pages.php';
wp_enqueue_script('inline-edit-post');
$post_stati = array('publish' => array(_x('Published', 'page'), __('Published pages'), _nx_noop('Published <span class="count">(%s)</span>', 'Published <span class="count">(%s)</span>', 'page')), 'future' => array(_x('Scheduled', 'page'), __('Scheduled pages'), _nx_noop('Scheduled <span class="count">(%s)</span>', 'Scheduled <span class="count">(%s)</span>', 'page')), 'pending' => array(_x('Pending Review', 'page'), __('Pending pages'), _nx_noop('Pending Review <span class="count">(%s)</span>', 'Pending Review <span class="count">(%s)</span>', 'page')), 'draft' => array(_x('Draft', 'page'), _x('Drafts', 'manage posts header'), _nx_noop('Draft <span class="count">(%s)</span>', 'Drafts <span class="count">(%s)</span>', 'page')), 'private' => array(_x('Private', 'page'), __('Private pages'), _nx_noop('Private <span class="count">(%s)</span>', 'Private <span class="count">(%s)</span>', 'page')), 'trash' => array(_x('Trash', 'page'), __('Trash pages'), _nx_noop('Trash <span class="count">(%s)</span>', 'Trash <span class="count">(%s)</span>', 'page')));
if (!EMPTY_TRASH_DAYS) {
    unset($post_stati['trash']);
}
$post_stati = apply_filters('page_stati', $post_stati);
$query = array('post_type' => 'page', 'orderby' => 'menu_order title', 'posts_per_page' => -1, 'posts_per_archive_page' => -1, 'order' => 'asc');
$post_status_label = __('Pages');
if (isset($_GET['post_status']) && in_array($_GET['post_status'], array_keys($post_stati))) {
    $post_status_label = $post_stati[$_GET['post_status']][1];
    $query['post_status'] = $_GET['post_status'];
    $query['perm'] = 'readable';
}
$query = apply_filters('manage_pages_query', $query);
wp($query);
if (is_singular()) {
    wp_enqueue_script('admin-comments');
<?php

/**
 * Test that all l10n functions are properly recognized.
 *
 * @package WP_L10n_Validator\Tests
 * @since 0.1.0
 */
__('test', 'wp-l10n-validator-tests');
_e('test', 'wp-l10n-validator-tests');
_c('test|context', 'wp-l10n-validator-tests');
_nc('test|context', 'single', 'plural', 'wp-l10n-validator-tests');
__ngettext('single', 'plural', 1, 'wp-l10n-validator-tests');
_n('single', 'plural', 1, 'wp-l10n-validator-tests');
__ngettext_noop('single', 'plural', 'wp-l10n-validator-tests');
_n_noop('single', 'plural', 'wp-l10n-validator-tests');
_x('test', 'context', 'wp-l10n-validator-tests');
_ex('test', 'context', 'wp-l10n-validator-tests');
_nx('singular', 'plural', 1, 'context', 'wp-l10n-validator-tests');
_nx_noop('single', 'plural', 'context', 'wp-l10n-validator-tests');
esc_attr__('test', 'wp-l10n-validator-tests');
esc_html__('test', 'wp-l10n-validator-tests');
esc_html_e('test', 'wp-l10n-validator-tests');
esc_attr_e('test', 'wp-l10n-validator-tests');
esc_attr_x('test', 'context', 'wp-l10n-validator-tests');
esc_html_x('test', 'context', 'wp-l10n-validator-tests');
 /**
  * Register our custom post statuses, used for order/subscription status
  */
 public static function register_post_status()
 {
     $subscription_statuses = wcs_get_subscription_statuses();
     $registered_statuses = apply_filters('woocommerce_subscriptions_registered_statuses', array('wc-active' => _nx_noop('Active <span class="count">(%s)</span>', 'Active <span class="count">(%s)</span>', 'post status label including post count', 'woocommerce-subscriptions'), 'wc-switched' => _nx_noop('Switched <span class="count">(%s)</span>', 'Switched <span class="count">(%s)</span>', 'post status label including post count', 'woocommerce-subscriptions'), 'wc-expired' => _nx_noop('Expired <span class="count">(%s)</span>', 'Expired <span class="count">(%s)</span>', 'post status label including post count', 'woocommerce-subscriptions'), 'wc-pending-cancel' => _nx_noop('Pending Cancellation <span class="count">(%s)</span>', 'Pending Cancellation <span class="count">(%s)</span>', 'post status label including post count', 'woocommerce-subscriptions')));
     if (is_array($subscription_statuses) && is_array($registered_statuses)) {
         foreach ($registered_statuses as $status => $label_count) {
             register_post_status($status, array('label' => $subscription_statuses[$status], 'public' => false, 'exclude_from_search' => false, 'show_in_admin_all_list' => true, 'show_in_admin_status_list' => true, 'label_count' => $label_count));
         }
     }
 }
/**
 * Register the Event post statuses
 *
 * @since 0.1.9
 */
function wp_event_calendar_register_post_statuses()
{
    // Register the event type
    register_post_status('passed', array('label' => esc_html_x('Past', 'events', 'wp-event-calendar'), 'label_count' => _nx_noop('Past <span class="count">(%s)</span>', 'Past <span class="count">(%s)</span>', 'events', 'wp-event-calendar'), 'exclude_from_search' => get_post_type_object('event')->exclude_from_search, 'public' => get_post_type_object('event')->public, 'publicly_queryable' => get_post_type_object('event')->publicly_queryable, 'show_in_admin_status_list' => true, 'show_in_admin_all_list' => true));
}
 /**
  * Register a list of functions available into Twig templates.
  * 
  * @return array|\Twig_SimpleFunction[]
  */
 public function getFunctions()
 {
     return [new Twig_SimpleFunction('wp_head', 'wp_head'), new Twig_SimpleFunction('wp_footer', 'wp_footer'), new Twig_SimpleFunction('body_class', function ($class = '') {
         return body_class($class);
     }), new Twig_SimpleFunction('post_class', function ($class = '', $id = null) {
         return post_class($class, $id);
     }), new Twig_SimpleFunction('wpautop', function ($text, $br = true) {
         return wpautop($text, $br);
     }), new Twig_SimpleFunction('wp_trim_words', function ($text, $num_words = 55, $more = null) {
         return wp_trim_words($text, $num_words, $more);
     }), new Twig_SimpleFunction('fn', function ($functionName) {
         $args = func_get_args();
         // By default, the function name should always be the first argument.
         // This remove it from the arguments list.
         array_shift($args);
         if (is_string($functionName)) {
             $functionName = trim($functionName);
         }
         return call_user_func_array($functionName, $args);
     }), new Twig_SimpleFunction('meta', function ($key, $id = null, $context = 'post', $single = true) {
         return meta($key, $id, $context, $single);
     }), new Twig_SimpleFunction('translate', function ($text, $domain = 'default') {
         return translate($text, $domain);
     }), new Twig_SimpleFunction('__', function ($text, $domain = 'default') {
         return __($text, $domain);
     }), new Twig_SimpleFunction('_e', function ($text, $domain = 'default') {
         return _e($text, $domain);
     }), new Twig_SimpleFunction('_n', function ($single, $plural, $number, $domain = 'default') {
         return _n($single, $plural, $number, $domain);
     }), new Twig_SimpleFunction('_x', function ($text, $context, $domain = 'default') {
         return _x($text, $context, $domain);
     }), new Twig_SimpleFunction('_ex', function ($text, $context, $domain = 'default') {
         return _ex($text, $context, $domain);
     }), new Twig_SimpleFunction('_nx', function ($single, $plural, $number, $context, $domain = 'default') {
         return _nx($single, $plural, $number, $context, $domain);
     }), new Twig_SimpleFunction('_n_noop', function ($singular, $plural, $domain = 'default') {
         return _n_noop($singular, $plural, $domain);
     }), new Twig_SimpleFunction('_nx_noop', function ($singular, $plural, $context, $domain = 'default') {
         return _nx_noop($singular, $plural, $context, $domain);
     }), new Twig_SimpleFunction('translate_nooped_plural', function ($nooped_plural, $count, $domain = 'default') {
         return translate_nooped_plural($nooped_plural, $count, $domain);
     })];
 }
<?php

__('Hello World', 'my-domain');
_x('Post', 'verb', 'my-domain');
_e('Hello World', 'my-domain');
_ex('Post', 'verb', 'my-domain');
esc_html__('Hello World', 'my-domain');
esc_html_e('Hello World', 'my-domain');
esc_html_x('Post', 'verb', 'my-domain');
esc_attr__('Hello World', 'my-domain');
esc_attr_e('Hello World', 'my-domain');
esc_attr_x('Post', 'verb', 'my-domain');
$apples = 4;
_n('%d apple', '%d apples', $apples, 'my-domain');
_nx('%d post', '%d posts', $apples, 'noun, job positions', 'my-domain');
_n_noop('%d apple', '%d apples', 'my-domain');
_nx_noop('%d post', '%d posts', 'noun, job positions', 'my-domain');
<?php

$domain = 'my-domain';
//Allthough correct, this should fail.
__('Hello World', $domain);
_x('Post', 'verb', $domain);
_e('Hello World', $domain);
_ex('Post', 'verb', $domain);
esc_html__('Hello World', $domain);
esc_html_e('Hello World', $domain);
esc_html_x('Post', 'verb', $domain);
esc_attr__('Hello World', $domain);
esc_attr_e('Hello World', $domain);
esc_attr_x('Post', 'verb', $domain);
$apples = 4;
_n('%d apple', '%d apples', $apples, $domain);
_nx('%d post', '%d posts', $apples, 'noun, job positions', $domain);
_n_noop('%d apple', '%d apples', $domain);
_nx_noop('%d post', '%d posts', 'noun, job positions', $domain);
Exemple #17
0
function wpsc_get_customer_orders_statuses()
{
    if (_wpsc_get_current_controller_name() != 'customer-account' || _wpsc_get_current_controller_slug() != 'orders') {
        return '';
    }
    $controller = _wpsc_get_current_controller();
    $view_labels = array(0 => _nx_noop('All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', 'purchase logs', 'wp-e-commerce'), 1 => _nx_noop('Incomplete <span class="count">(%s)</span>', 'Incomplete <span class="count">(%s)</span>', 'purchase logs', 'wp-e-commerce'), 2 => _nx_noop('Received <span class="count">(%s)</span>', 'Received <span class="count">(%s)</span>', 'purchase logs', 'wp-e-commerce'), 3 => _nx_noop('Accepted <span class="count">(%s)</span>', 'Accepted <span class="count">(%s)</span>', 'purchase logs', 'wp-e-commerce'), 4 => _nx_noop('Dispatched <span class="count">(%s)</span>', 'Dispatched <span class="count">(%s)</span>', 'purchase logs', 'wp-e-commerce'), 5 => _nx_noop('Closed <span class="count">(%s)</span>', 'Closed <span class="count">(%s)</span>', 'purchase logs', 'wp-e-commerce'), 6 => _nx_noop('Declined <span class="count">(%s)</span>', 'Declined <span class="count">(%s)</span>', 'purchase logs', 'wp-e-commerce'));
    $views = array();
    foreach ($controller->status_filters as $status => $count) {
        if (!isset($view_labels[$status]) || $status && !$count) {
            continue;
        }
        $text = sprintf(translate_nooped_plural($view_labels[$status], $count, 'wp-e-commerce'), number_format_i18n($count));
        $url = $status ? wpsc_get_customer_account_url('orders/status/' . $status) : wpsc_get_customer_account_url();
        $link = '<a href="' . esc_url($url) . '">' . $text . '</a>';
        $views[$status] = '<span class="wpsc-order-status-' . $status . '">' . $link . '</span>';
    }
    if (count($views) == 2) {
        unset($views[1]);
    }
    $output = '<div class="wpsc-order-statuses">';
    $output .= implode('<span class="wpsc-order-status-separator"> | </span>', $views);
    $output .= '</div>';
    return $output;
}
Exemple #18
0
/**
 * Calculate the time difference - a replacement for `human_time_diff()` until it is improved.
 *
 * Based on BuddyPress function `bp_core_time_since()`, which in turn is based on functions created by
 * Dunstan Orchard - http://1976design.com
 *
 * This function will return an text representation of the time elapsed since a
 * given date, giving the two largest units e.g.:
 *
 *  - 2 hours and 50 minutes
 *  - 4 days
 *  - 4 weeks and 6 days
 *
 * @since 1.7.0
 *
 * @param int      $older_date     Unix timestamp of date you want to calculate the time since for`.
 * @param int|bool $newer_date     Optional. Unix timestamp of date to compare older date to. Default false (current time).
 * @param int      $relative_depth Optional, how many units to include in relative date. Default 2.
 * @return string The time difference between two dates.
 */
function genesis_human_time_diff($older_date, $newer_date = false, $relative_depth = 2)
{
    // If no newer date is given, assume now.
    $newer_date = $newer_date ? $newer_date : time();
    // Difference in seconds.
    $since = absint($newer_date - $older_date);
    if (!$since) {
        return '0 ' . _x('seconds', 'time difference', 'genesis');
    }
    // Hold units of time in seconds, and their pluralised strings (not translated yet).
    $units = array(array(31536000, _nx_noop('%s year', '%s years', 'time difference', 'genesis')), array(2592000, _nx_noop('%s month', '%s months', 'time difference', 'genesis')), array(604800, _nx_noop('%s week', '%s weeks', 'time difference', 'genesis')), array(86400, _nx_noop('%s day', '%s days', 'time difference', 'genesis')), array(3600, _nx_noop('%s hour', '%s hours', 'time difference', 'genesis')), array(60, _nx_noop('%s minute', '%s minutes', 'time difference', 'genesis')), array(1, _nx_noop('%s second', '%s seconds', 'time difference', 'genesis')));
    // Build output with as many units as specified in $relative_depth.
    $relative_depth = intval($relative_depth) ? intval($relative_depth) : 2;
    $i = 0;
    $counted_seconds = 0;
    $date_partials = array();
    while (count($date_partials) < $relative_depth && $i < count($units)) {
        $seconds = $units[$i][0];
        if (($count = floor(($since - $counted_seconds) / $seconds)) != 0) {
            $date_partials[] = sprintf(translate_nooped_plural($units[$i][1], $count, 'genesis'), $count);
            $counted_seconds = $counted_seconds + $count * $seconds;
        }
        $i++;
    }
    if (empty($date_partials)) {
        $output = '';
    } elseif (1 == count($date_partials)) {
        $output = $date_partials[0];
    } else {
        // Combine all but last partial using commas.
        $output = implode(', ', array_slice($date_partials, 0, -1));
        // Add 'and' separator.
        $output .= ' ' . _x('and', 'separator in time difference', 'genesis') . ' ';
        // Add last partial.
        $output .= end($date_partials);
    }
    return $output;
}
/**
 * wpsc_core_load_purchase_log_statuses()
 *
 * @global array $wpsc_purchlog_statuses
 */
function wpsc_core_load_purchase_log_statuses()
{
    global $wpsc_purchlog_statuses;
    $wpsc_purchlog_statuses = array(array('internalname' => 'incomplete_sale', 'label' => __('Incomplete Sale', 'wpsc'), 'view_label' => _nx_noop('Incomplete Sale <span class="count">(%d)</span>', 'Incomplete Sale <span class="count">(%d)</span>', 'Purchase log view links', 'wpsc'), 'order' => 1), array('internalname' => 'order_received', 'label' => __('Order Received', 'wpsc'), 'view_label' => _nx_noop('Order Received <span class="count">(%d)</span>', 'Order Received <span class="count">(%d)</span>', 'Purchase log view links', 'wpsc'), 'order' => 2), array('internalname' => 'accepted_payment', 'label' => __('Accepted Payment', 'wpsc'), 'view_label' => _nx_noop('Accepted Payment <span class="count">(%d)</span>', 'Accepted Payment <span class="count">(%d)</span>', 'Purchase log view links', 'wpsc'), 'is_transaction' => true, 'order' => 3), array('internalname' => 'job_dispatched', 'label' => __('Job Dispatched', 'wpsc'), 'view_label' => _nx_noop('Job Dispatched <span class="count">(%d)</span>', 'Job Dispatched <span class="count">(%d)</span>', 'Purchase log view links', 'wpsc'), 'is_transaction' => true, 'order' => 4), array('internalname' => 'closed_order', 'label' => __('Closed Order', 'wpsc'), 'view_label' => _nx_noop('Closed Order <span class="count">(%d)</span>', 'Closed Order <span class="count">(%d)</span>', 'Purchase log view links', 'wpsc'), 'is_transaction' => true, 'order' => 5), array('internalname' => 'declined_payment', 'label' => __('Payment Declined', 'wpsc'), 'view_label' => _nx_noop('Payment Declined <span class="count">(%d)</span>', 'Payment Declined <span class="count">(%d)</span>', 'Purchase log view links', 'wpsc'), 'order' => 6));
    $wpsc_purchlog_statuses = apply_filters('wpsc_set_purchlog_statuses', $wpsc_purchlog_statuses);
}
Exemple #20
0
 /**
  * Register and return the Aggregator Record Custom Post Status
  * Instead of having a method for returning and another registering
  * we do it all in one single method depending if it exists or not
  *
  * @param  string $status Which status object you are looking for
  *
  * @return stdClass|WP_Error|array
  */
 public function get_status($status = null)
 {
     $registered_by_key = (object) array();
     $registered_by_name = (object) array();
     foreach (self::$status as $key => $name) {
         $object = get_post_status_object($name);
         $registered_by_key->{$key} = $object;
         $registered_by_name->{$name} = $object;
     }
     // Check if we already have the Status registered
     if (isset($registered_by_key->{$status}) && is_object($registered_by_key->{$status})) {
         return $registered_by_key->{$status};
     }
     // Check if we already have the Status registered
     if (isset($registered_by_name->{$status}) && is_object($registered_by_name->{$status})) {
         return $registered_by_name->{$status};
     }
     // Register the Success post status
     $args = array('label' => esc_html_x('Imported', 'event aggregator status', 'the-events-calendar'), 'label_count' => _nx_noop('Imported <span class="count">(%s)</span>', 'Imported <span class="count">(%s)</span>', 'event aggregator status', 'the-events-calendar'), 'public' => true, 'publicly_queryable' => true);
     $object = register_post_status(self::$status->success, $args);
     $registered_by_key->success = $registered_by_name->{'tribe-aggregator-success'} = $object;
     // Register the Failed post status
     $args = array('label' => esc_html_x('Failed', 'event aggregator status', 'the-events-calendar'), 'label_count' => _nx_noop('Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'event aggregator status', 'the-events-calendar'), 'public' => true, 'publicly_queryable' => true);
     $object = register_post_status(self::$status->failed, $args);
     $registered_by_key->failed = $registered_by_name->{'tribe-aggregator-failed'} = $object;
     // Register the Schedule post status
     $args = array('label' => esc_html_x('Schedule', 'event aggregator status', 'the-events-calendar'), 'label_count' => _nx_noop('Schedule <span class="count">(%s)</span>', 'Schedule <span class="count">(%s)</span>', 'event aggregator status', 'the-events-calendar'), 'public' => true, 'publicly_queryable' => true);
     $object = register_post_status(self::$status->schedule, $args);
     $registered_by_key->schedule = $registered_by_name->{'tribe-aggregator-schedule'} = $object;
     // Register the Pending post status
     $args = array('label' => esc_html_x('Pending', 'event aggregator status', 'the-events-calendar'), 'label_count' => _nx_noop('Pending <span class="count">(%s)</span>', 'Pending <span class="count">(%s)</span>', 'event aggregator status', 'the-events-calendar'), 'public' => true, 'publicly_queryable' => true);
     $object = register_post_status(self::$status->pending, $args);
     $registered_by_key->pending = $registered_by_name->{'tribe-aggregator-pending'} = $object;
     // Register the Pending post status
     $args = array('label' => esc_html_x('Draft', 'event aggregator status', 'the-events-calendar'), 'label_count' => _nx_noop('Draft <span class="count">(%s)</span>', 'Draft <span class="count">(%s)</span>', 'event aggregator status', 'the-events-calendar'), 'public' => true, 'publicly_queryable' => true);
     $object = register_post_status(self::$status->draft, $args);
     $registered_by_key->draft = $registered_by_name->{'tribe-aggregator-draft'} = $object;
     // Check if we already have the Status registered
     if (isset($registered_by_key->{$status}) && is_object($registered_by_key->{$status})) {
         return $registered_by_key->{$status};
     }
     // Check if we already have the Status registered
     if (isset($registered_by_name->{$status}) && is_object($registered_by_name->{$status})) {
         return $registered_by_name->{$status};
     }
     return $registered_by_key;
 }
 /**
  * Register queue post status and add most of the hooks.
  *
  * @since 1.0
  * @access public
  */
 public function init()
 {
     /**
      * Fires before init method.
      *
      * @since 1.0
      */
     do_action('ptq_before_init');
     // Register post status
     $default_post_status_args = array('label' => _x('Queued', 'post status name', 'post-to-queue'), 'label_count' => _nx_noop('Queued <span class="count">(%s)</span>', 'Queued <span class="count">(%s)</span>', 'post status count label', 'post-to-queue'), 'protected' => true, 'exclude_from_search' => true, 'show_in_admin_status_list' => true, 'show_in_admin_all_list' => true);
     /**
      * Filter parameters used when registering queue post status.
      *
      * @see register_post_status()
      *
      * @since 1.0
      *
      * @param array $args {
      *     The array of parameters used when registering queue post status.
      *
      *     @type string $label                     Name of the post status used in UI.
      *     @type array  $label_count               Array of registered plural strings of post status' name.
      *     @type bool   $protected                 Defaults to true.
      *     @type bool   $exclude_from_search       Whether to exclude queued posts from search results. Defaults to true.
      *     @type bool   $show_in_admin_status_list Whether to include posts in the edit listing for their post type. Defaults to true.
      *     @type bool   $show_in_admin_all_list    Whether to show in the list of statuses with post counts. Defaults to true.
      * }
      */
     $post_status_args = (array) apply_filters('ptq_register_post_status_args', $default_post_status_args);
     $post_status_args = wp_parse_args($post_status_args, $default_post_status_args);
     register_post_status($this->status, $post_status_args);
     // Add queue order on post saving
     add_action('save_post', array($this, 'add_queue_order'));
     // Remove queue order on post trashing
     add_action('trashed_post', array($this, 'delete_order'));
     // Cleanup queue existence statuses on saving
     add_action('save_post', array($this, 'delete_queued_existence'));
     // Schedule reschedule of all events when PTQ settings change
     add_action('add_option_ptq_settings', array($this, 'schedule_reschedule'));
     add_action('update_option_ptq_settings', array($this, 'schedule_reschedule'));
     add_action('delete_option_ptq_settings', array($this, 'schedule_reschedule'));
     // Schedule reschedule of all events when time zone change
     add_action('add_option_gmt_offset', array($this, 'schedule_reschedule'));
     add_action('update_option_gmt_offset', array($this, 'schedule_reschedule'));
     add_action('delete_option_gmt_offset', array($this, 'schedule_reschedule'));
     add_action('add_option_timezone_string', array($this, 'schedule_reschedule'));
     add_action('update_option_timezone_string', array($this, 'schedule_reschedule'));
     add_action('delete_option_timezone_string', array($this, 'schedule_reschedule'));
     // Reschedule all events when single event happens
     add_action('ptq_single_event_reschedule', array($this, 'reschedule'));
     // Maybe schedule post type event when single event happens
     add_action('ptq_single_event_maybe_schedule', array($this, 'maybe_schedule_event'));
     /**
      * Fires after init method.
      *
      * @since 1.0
      */
     do_action('ptq_after_init');
 }
<?php

/**
 * A set of WordPress translation functions.
 *
 * @see wp-includes/l10n.php
 */
translate('translate');
translate_with_gettext_context('translate_with_gettext_context', 'translate_with_gettext_context-context');
__('__');
esc_attr__('esc_attr__');
esc_html__('esc_html__');
_e('_e');
esc_attr_e('esc_attr_e');
esc_html_e('esc_html_e');
_x('_x', '_x-context');
_ex('_ex', '_ex-context');
esc_attr_x('esc_attr_x', 'esc_attr_x-context');
esc_html_x('esc_html_x', 'esc_html_x-context');
_n('_n-single', '_n-plural', 2);
_nx('_nx-single', '_nx-plural', 2, '_nx-context');
_n_noop('_n_noop-singular', '_n_noop-plural');
_nx_noop('_nx_noop-singular', '_nx_noop-plural', '_nx_noop-context');
 /**
  * Register the custom post status used by the plugin
  *
  * @since 1.0.0
  *
  * @return null
  */
 public function register_post_status()
 {
     // Reported
     register_post_status($this->get_reported_status_id(), apply_filters('bbp_rc_register_reported_post_status', array('label' => _x('User Reported', 'post', 'bbpress-report-content'), 'label_count' => _nx_noop('User Reported <span class="count">(%s)</span>', 'User Reported <span class="count">(%s)</span>', 'post', 'bbpress-report-content'), 'public' => true, 'exclude_from_search' => true, 'show_in_admin_status_list' => true, 'show_in_admin_all_list' => true)));
 }
/** setup content specific variables **/
$content_title = $this->get_type_label();
$content_title_plural = $this->get_type_label_plural();
$post_type = $this->get_content_type();
/** END setup content specific variables **/
if (!current_user_can('edit_pages')) {
    wp_die(__('Cheatin&#8217; uh?'));
}
if (empty($title)) {
    $title = "Edit {$content_title_plural}";
}
$parent_file = 'edit-pages.php';
wp_enqueue_script('inline-edit-post');
$post_stati = array('publish' => array(_x('Published', 'page'), __('Published pages'), _nx_noop('Published <span class="count">(%s)</span>', 'Published <span class="count">(%s)</span>', 'page')), 'future' => array(_x('Scheduled', 'page'), __('Scheduled pages'), _nx_noop('Scheduled <span class="count">(%s)</span>', 'Scheduled <span class="count">(%s)</span>', 'page')), 'pending' => array(_x('Pending Review', 'page'), __('Pending pages'), _nx_noop('Pending Review <span class="count">(%s)</span>', 'Pending Review <span class="count">(%s)</span>', 'page')), 'draft' => array(_x('Draft', 'page'), _x('Drafts', 'manage posts header'), _nx_noop('Draft <span class="count">(%s)</span>', 'Drafts <span class="count">(%s)</span>', 'page')), 'private' => array(_x('Private', 'page'), __('Private pages'), _nx_noop('Private <span class="count">(%s)</span>', 'Private <span class="count">(%s)</span>', 'page')));
if (function_exists('wp_trash_post')) {
    $post_stati['trash'] = array(_x('Trash', 'page'), __('Trash pages'), _nx_noop('Trash <span class="count">(%s)</span>', 'Trash <span class="count">(%s)</span>', 'page'));
}
$post_stati = apply_filters('page_stati', $post_stati);
$query = array('post_type' => $post_type, 'orderby' => 'post_date', 'posts_per_page' => -1, 'posts_per_archive_page' => -1, 'order' => 'desc');
$post_status_label = __('Pages');
if (isset($_GET['post_status']) && in_array($_GET['post_status'], array_keys($post_stati))) {
    $post_status_label = $post_stati[$_GET['post_status']][1];
    $query['post_status'] = $_GET['post_status'];
    $query['perm'] = 'readable';
}
$query = apply_filters('manage_pages_query', $query);
wp($query);
global $wp_query, $posts;
if (is_singular()) {
    wp_enqueue_script('admin-comments');
    enqueue_comment_hotkeys_js();
                    break;
            }
        }
        echo '<div id="moderated" class="updated"><p>' . implode("<br/>\n", $messages) . '</p></div>';
    }
}
?>

<form id="comments-form" action="" method="get">
<ul class="subsubsub">
<?php 
$status_links = array();
$num_comments = $post_id ? wp_count_comments($post_id) : wp_count_comments();
//, number_format_i18n($num_comments->moderated) ), "<span class='comment-count'>" . number_format_i18n($num_comments->moderated) . "</span>"),
//, number_format_i18n($num_comments->spam) ), "<span class='spam-comment-count'>" . number_format_i18n($num_comments->spam) . "</span>")
$stati = array('all' => _nx_noop('All', 'All', 'comments'), 'moderated' => _n_noop('Pending <span class="count">(<span class="pending-count">%s</span>)</span>', 'Pending <span class="count">(<span class="pending-count">%s</span>)</span>'), 'approved' => _n_noop('Approved', 'Approved'), 'spam' => _n_noop('Spam <span class="count">(<span class="spam-count">%s</span>)</span>', 'Spam <span class="count">(<span class="spam-count">%s</span>)</span>'), 'trash' => _n_noop('Trash <span class="count">(<span class="trash-count">%s</span>)</span>', 'Trash <span class="count">(<span class="trash-count">%s</span>)</span>'));
if (!EMPTY_TRASH_DAYS) {
    unset($stati['trash']);
}
$link = 'edit-comments.php';
if (!empty($comment_type) && 'all' != $comment_type) {
    $link = add_query_arg('comment_type', $comment_type, $link);
}
foreach ($stati as $status => $label) {
    $class = $status == $comment_status ? ' class="current"' : '';
    if (!isset($num_comments->{$status})) {
        $num_comments->{$status} = 10;
    }
    $link = add_query_arg('comment_status', $status, $link);
    if ($post_id) {
        $link = add_query_arg('p', absint($post_id), $link);
Exemple #26
0
 /**
  *
  *
  * @param Twig_Environment $twig
  * @return Twig_Environment
  */
 public function add_timber_filters($twig)
 {
     /* image filters */
     $twig->addFilter(new \Twig_SimpleFilter('resize', array('Timber\\ImageHelper', 'resize')));
     $twig->addFilter(new \Twig_SimpleFilter('retina', array('Timber\\ImageHelper', 'retina_resize')));
     $twig->addFilter(new \Twig_SimpleFilter('letterbox', array('Timber\\ImageHelper', 'letterbox')));
     $twig->addFilter(new \Twig_SimpleFilter('tojpg', array('Timber\\ImageHelper', 'img_to_jpg')));
     /* debugging filters */
     $twig->addFilter(new \Twig_SimpleFilter('get_class', 'get_class'));
     $twig->addFilter(new \Twig_SimpleFilter('get_type', 'get_type'));
     $twig->addFilter(new \Twig_SimpleFilter('print_r', function ($arr) {
         return print_r($arr, true);
     }));
     /* other filters */
     $twig->addFilter(new \Twig_SimpleFilter('stripshortcodes', 'strip_shortcodes'));
     $twig->addFilter(new \Twig_SimpleFilter('array', array($this, 'to_array')));
     $twig->addFilter(new \Twig_SimpleFilter('excerpt', 'wp_trim_words'));
     $twig->addFilter(new \Twig_SimpleFilter('excerpt_chars', array('Timber\\TextHelper', 'trim_characters')));
     $twig->addFilter(new \Twig_SimpleFilter('function', array($this, 'exec_function')));
     $twig->addFilter(new \Twig_SimpleFilter('pretags', array($this, 'twig_pretags')));
     $twig->addFilter(new \Twig_SimpleFilter('sanitize', 'sanitize_title'));
     $twig->addFilter(new \Twig_SimpleFilter('shortcodes', 'do_shortcode'));
     $twig->addFilter(new \Twig_SimpleFilter('time_ago', array($this, 'time_ago')));
     $twig->addFilter(new \Twig_SimpleFilter('wpautop', 'wpautop'));
     $twig->addFilter(new \Twig_SimpleFilter('list', array($this, 'add_list_separators')));
     $twig->addFilter(new \Twig_SimpleFilter('pluck', array('Timber\\Helper', 'pluck')));
     $twig->addFilter(new \Twig_SimpleFilter('relative', function ($link) {
         return URLHelper::get_rel_url($link, true);
     }));
     $twig->addFilter(new \Twig_SimpleFilter('date', array($this, 'intl_date')));
     $twig->addFilter(new \Twig_SimpleFilter('truncate', function ($text, $len) {
         return TextHelper::trim_words($text, $len);
     }));
     /* actions and filters */
     $twig->addFunction(new \Twig_SimpleFunction('action', function ($context) {
         $args = func_get_args();
         array_shift($args);
         $args[] = $context;
         call_user_func_array('do_action', $args);
     }, array('needs_context' => true)));
     $twig->addFilter(new \Twig_SimpleFilter('apply_filters', function () {
         $args = func_get_args();
         $tag = current(array_splice($args, 1, 1));
         return apply_filters_ref_array($tag, $args);
     }));
     $twig->addFunction(new \Twig_SimpleFunction('function', array(&$this, 'exec_function')));
     $twig->addFunction(new \Twig_SimpleFunction('fn', array(&$this, 'exec_function')));
     $twig->addFunction(new \Twig_SimpleFunction('shortcode', 'do_shortcode'));
     /* TimberObjects */
     $twig->addFunction(new \Twig_SimpleFunction('TimberPost', function ($pid, $PostClass = 'Timber\\Post') {
         if (is_array($pid) && !Helper::is_array_assoc($pid)) {
             foreach ($pid as &$p) {
                 $p = new $PostClass($p);
             }
             return $pid;
         }
         return new $PostClass($pid);
     }));
     $twig->addFunction(new \Twig_SimpleFunction('TimberImage', function ($pid = false, $ImageClass = 'Timber\\Image') {
         if (is_array($pid) && !Helper::is_array_assoc($pid)) {
             foreach ($pid as &$p) {
                 $p = new $ImageClass($p);
             }
             return $pid;
         }
         return new $ImageClass($pid);
     }));
     $twig->addFunction(new \Twig_SimpleFunction('TimberTerm', function ($pid, $TermClass = 'Timber\\Term') {
         if (is_array($pid) && !Helper::is_array_assoc($pid)) {
             foreach ($pid as &$p) {
                 $p = new $TermClass($p);
             }
             return $pid;
         }
         return new $TermClass($pid);
     }));
     $twig->addFunction(new \Twig_SimpleFunction('TimberUser', function ($pid, $UserClass = 'Timber\\User') {
         if (is_array($pid) && !Helper::is_array_assoc($pid)) {
             foreach ($pid as &$p) {
                 $p = new $UserClass($p);
             }
             return $pid;
         }
         return new $UserClass($pid);
     }));
     /* TimberObjects Alias */
     $twig->addFunction(new \Twig_SimpleFunction('Post', function ($pid, $PostClass = 'Timber\\Post') {
         if (is_array($pid) && !Helper::is_array_assoc($pid)) {
             foreach ($pid as &$p) {
                 $p = new $PostClass($p);
             }
             return $pid;
         }
         return new $PostClass($pid);
     }));
     $twig->addFunction(new \Twig_SimpleFunction('Image', function ($pid, $ImageClass = 'Timber\\Image') {
         if (is_array($pid) && !Helper::is_array_assoc($pid)) {
             foreach ($pid as &$p) {
                 $p = new $ImageClass($p);
             }
             return $pid;
         }
         return new $ImageClass($pid);
     }));
     $twig->addFunction(new \Twig_SimpleFunction('Term', function ($pid, $TermClass = 'Timber\\Term') {
         if (is_array($pid) && !Helper::is_array_assoc($pid)) {
             foreach ($pid as &$p) {
                 $p = new $TermClass($p);
             }
             return $pid;
         }
         return new $TermClass($pid);
     }));
     $twig->addFunction(new \Twig_SimpleFunction('User', function ($pid, $UserClass = 'Timber\\User') {
         if (is_array($pid) && !Helper::is_array_assoc($pid)) {
             foreach ($pid as &$p) {
                 $p = new $UserClass($p);
             }
             return $pid;
         }
         return new $UserClass($pid);
     }));
     /* bloginfo and translate */
     $twig->addFunction(new \Twig_SimpleFunction('bloginfo', function ($show = '', $filter = 'raw') {
         return get_bloginfo($show, $filter);
     }));
     $twig->addFunction(new \Twig_SimpleFunction('__', function ($text, $domain = 'default') {
         return __($text, $domain);
     }));
     $twig->addFunction(new \Twig_SimpleFunction('translate', function ($text, $domain = 'default') {
         return translate($text, $domain);
     }));
     $twig->addFunction(new \Twig_SimpleFunction('_e', function ($text, $domain = 'default') {
         return _e($text, $domain);
     }));
     $twig->addFunction(new \Twig_SimpleFunction('_n', function ($single, $plural, $number, $domain = 'default') {
         return _n($single, $plural, $number, $domain);
     }));
     $twig->addFunction(new \Twig_SimpleFunction('_x', function ($text, $context, $domain = 'default') {
         return _x($text, $context, $domain);
     }));
     $twig->addFunction(new \Twig_SimpleFunction('_ex', function ($text, $context, $domain = 'default') {
         return _ex($text, $context, $domain);
     }));
     $twig->addFunction(new \Twig_SimpleFunction('_nx', function ($single, $plural, $number, $context, $domain = 'default') {
         return _nx($single, $plural, $number, $context, $domain);
     }));
     $twig->addFunction(new \Twig_SimpleFunction('_n_noop', function ($singular, $plural, $domain = 'default') {
         return _n_noop($singular, $plural, $domain);
     }));
     $twig->addFunction(new \Twig_SimpleFunction('_nx_noop', function ($singular, $plural, $context, $domain = 'default') {
         return _nx_noop($singular, $plural, $context, $domain);
     }));
     $twig->addFunction(new \Twig_SimpleFunction('translate_nooped_plural', function ($nooped_plural, $count, $domain = 'default') {
         return translate_nooped_plural($nooped_plural, $count, $domain);
     }));
     $twig = apply_filters('timber/twig', $twig);
     /**
      * get_twig is deprecated, use timber/twig
      */
     $twig = apply_filters('get_twig', $twig);
     return $twig;
 }
 /**
  * Get an array of the untranslated, base view labels for the purchase log statuses.
  *
  * @return array The untranslated, base view label for each status.
  */
 private function get_status_view_labels()
 {
     global $wpsc_purchlog_statuses;
     $view_labels = array();
     foreach ($wpsc_purchlog_statuses as $status) {
         if (!empty($status['view_label'])) {
             // The status provides a view label i18n _nx_noop-able object.
             $view_labels[$status['order']]['view_label'] = $status['view_label'];
         } else {
             // The status doesn't provide a view label i18n string. Use a generic one.
             $view_labels[$status['order']]['view_label'] = _nx_noop('%s <span class="count">(%d)</span>', '%s <span class="count">(%d)</span>', 'Purchase log view links for custom status with no explicit translation.', 'wp-e-commerce');
             $view_labels[$status['order']]['label'] = $status['label'];
         }
     }
     return $view_labels;
 }
/**
 * Register the Event post statuses
 *
 * @since 0.1.9
 */
function wp_event_calendar_register_post_statuses()
{
    // Register the event type
    register_post_status('passed', array('label' => esc_html_x('Passed', 'events', 'wp-event-calendar'), 'label_count' => _nx_noop('Passed <span class="count">(%s)</span>', 'Passed <span class="count">(%s)</span>', 'events', 'wp-event-calendar'), 'exclude_from_search' => true, 'public' => null, 'internal' => null, 'protected' => null, 'private' => null, 'publicly_queryable' => false, 'show_in_admin_status_list' => true, 'show_in_admin_all_list' => true));
}
 /**
  *
  * @global int $post_id
  * @global string $comment_status
  * @global string $comment_type
  */
 protected function get_views()
 {
     global $post_id, $comment_status, $comment_type;
     $status_links = array();
     $num_comments = $post_id ? wp_count_comments($post_id) : wp_count_comments();
     //, number_format_i18n($num_comments->moderated) ), "<span class='comment-count'>" . number_format_i18n($num_comments->moderated) . "</span>"),
     //, number_format_i18n($num_comments->spam) ), "<span class='spam-comment-count'>" . number_format_i18n($num_comments->spam) . "</span>")
     $stati = array('all' => _nx_noop('All', 'All', 'comments'), 'moderated' => _n_noop('Pending <span class="count">(<span class="pending-count">%s</span>)</span>', 'Pending <span class="count">(<span class="pending-count">%s</span>)</span>'), 'approved' => _n_noop('Approved <span class="count">(<span class="approved-count">%s</span>)</span>', 'Approved <span class="count">(<span class="approved-count">%s</span>)</span>'), 'spam' => _n_noop('Spam <span class="count">(<span class="spam-count">%s</span>)</span>', 'Spam <span class="count">(<span class="spam-count">%s</span>)</span>'), 'trash' => _n_noop('Trash <span class="count">(<span class="trash-count">%s</span>)</span>', 'Trash <span class="count">(<span class="trash-count">%s</span>)</span>'));
     if (!EMPTY_TRASH_DAYS) {
         unset($stati['trash']);
     }
     $link = 'edit-comments.php';
     if (!empty($comment_type) && 'all' != $comment_type) {
         $link = add_query_arg('comment_type', $comment_type, $link);
     }
     foreach ($stati as $status => $label) {
         $class = $status == $comment_status ? ' class="current"' : '';
         if (!isset($num_comments->{$status})) {
             $num_comments->{$status} = 10;
         }
         $link = add_query_arg('comment_status', $status, $link);
         if ($post_id) {
             $link = add_query_arg('p', absint($post_id), $link);
         }
         /*
         // I toyed with this, but decided against it. Leaving it in here in case anyone thinks it is a good idea. ~ Mark
         if ( !empty( $_REQUEST['s'] ) )
         	$link = add_query_arg( 's', esc_attr( wp_unslash( $_REQUEST['s'] ) ), $link );
         */
         $status_links[$status] = "<a href='{$link}'{$class}>" . sprintf(translate_nooped_plural($label, $num_comments->{$status}), number_format_i18n($num_comments->{$status})) . '</a>';
     }
     /**
      * Filter the comment status links.
      *
      * @since 2.5.0
      *
      * @param array $status_links An array of fully-formed status links. Default 'All'.
      *                            Accepts 'All', 'Pending', 'Approved', 'Spam', and 'Trash'.
      */
     return apply_filters('comment_status_links', $status_links);
 }
 function register_post_statuses()
 {
     register_post_status('cancel', array('label' => _x('Cancelled', 'post', 'camptix'), 'label_count' => _nx_noop('Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'camptix'), 'public' => false, 'protected' => true, 'show_in_admin_all_list' => true, 'show_in_admin_status_list' => true));
     register_post_status('failed', array('label' => _x('Failed', 'post', 'camptix'), 'label_count' => _nx_noop('Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'camptix'), 'public' => false, 'protected' => true, 'show_in_admin_all_list' => true, 'show_in_admin_status_list' => true));
     register_post_status('timeout', array('label' => _x('Timeout', 'post', 'camptix'), 'label_count' => _nx_noop('Timeout <span class="count">(%s)</span>', 'Timeout <span class="count">(%s)</span>', 'camptix'), 'public' => false, 'protected' => true, 'show_in_admin_all_list' => true, 'show_in_admin_status_list' => true));
     register_post_status('refund', array('label' => _x('Refunded', 'post', 'camptix'), 'label_count' => _nx_noop('Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'camptix'), 'public' => false, 'protected' => true, 'show_in_admin_all_list' => true, 'show_in_admin_status_list' => true));
     add_filter('display_post_states', array($this, 'display_post_states'));
 }