コード例 #1
1
ファイル: template.php プロジェクト: turtlepod/entry-views
/**
 * Template tag for getting a specific post's view count.  It will default to the current post in The 
 * Loop.  To use the 'text' argument, either pass a nooped plural using _n_noop() or a single text string.
 *
 * @since  1.0.0
 * @access public
 * @param  array  $args
 * @return string
 */
function ev_get_post_views($args = array())
{
    $defaults = array('post_id' => get_the_ID(), 'before' => '', 'after' => '', 'text' => _n_noop('%s View', '%s Views', 'entry-views'), 'wrap' => '<span %s>%s</span>');
    $args = wp_parse_args($args, $defaults);
    $views = ev_get_post_view_count($args['post_id']);
    $text = is_array($args['text']) ? translate_nooped_plural($args['text'], $views) : $args['text'];
    $html = sprintf($args['wrap'], 'class="entry-views" itemprop="interactionCount" itemscope="itemscope" itemtype="http://schema.org/UserPageVisits"', sprintf($text, $views));
    return $args['before'] . $html . $args['after'];
}
 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&amp;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&amp;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;
 }
コード例 #3
0
 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;
 }
コード例 #4
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 $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;
}
コード例 #5
0
 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();
 }
コード例 #6
0
 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;
 }
コード例 #7
0
/**
 * @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);
}
コード例 #8
0
 function get_views()
 {
     $status_links = array();
     $num_posts = wp_count_posts(self::$storage_post_type, 'readable');
     $entries_stati = get_post_stati(array('show_in_admin_status_list' => true), 'objects');
     $view_link = add_query_arg(array('page' => 'cf7_storage'), admin_url('admin.php'));
     $status_links['all'] = sprintf('<a href="%s">%s <span class="count">(%d)</span></a>', $view_link, esc_html__('All', 'cf7-storage'), $num_posts->publish);
     $status_links['trash'] = sprintf('<a href="%s" %s>%s</a>', add_query_arg('post_status', 'trash', $view_link), $this->is_trash ? 'class="current"' : null, sprintf(translate_nooped_plural($entries_stati['trash']->label_count, $num_posts->trash), number_format_i18n($num_posts->trash)));
     return $status_links;
 }
コード例 #9
0
 /**
  * @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));
 }
コード例 #10
0
ファイル: enabled-views.php プロジェクト: sedici/wpmu-istec
 /**
  * Convert values to bo used in rendering
  */
 protected function _convert_values()
 {
     foreach ($this->_args['value'] as &$view) {
         $view['enabled'] = $view['enabled'] ? 'checked="checked"' : '';
         $view['default'] = $view['default'] ? 'checked="checked"' : '';
         // Use mobile settings if available, else fall back to desktop settings.
         $view['enabled_mobile'] = isset($view['enabled_mobile']) ? $view['enabled_mobile'] ? 'checked="checked"' : '' : $view['enabled'];
         $view['default_mobile'] = isset($view['default_mobile']) ? $view['default_mobile'] ? 'checked="checked"' : '' : $view['default'];
         $view['longname'] = translate_nooped_plural($view['longname'], 1);
     }
 }
コード例 #11
0
 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}&amp;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}&amp;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;
 }
コード例 #12
0
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');
}
コード例 #13
0
ファイル: wp_media_custom.php プロジェクト: zruiz/NG
 public static function wp_custom_recount_attachments($views)
 {
     $_total_posts = array();
     $_num_posts = array();
     global $wpdb, $current_user, $post_mime_types, $avail_post_mime_types;
     $views = array();
     $count = $wpdb->get_results("\r\n\t\t\t\t\tSELECT post_mime_type, COUNT( * ) AS num_posts \r\n\t\t\t\t\tFROM {$wpdb->posts} \r\n\t\t\t\t\tWHERE post_type = 'attachment' \r\n\t\t\t\t\tAND post_author = {$current_user->ID} \r\n\t\t\t\t\tAND post_status != 'trash' \r\n\t\t\t\t\tGROUP BY post_mime_type\r\n\t\t\t\t", ARRAY_A);
     foreach ($count as $row) {
         $_num_posts[$row['post_mime_type']] = $row['num_posts'];
     }
     $_total_posts = array_sum($_num_posts);
     $detached = isset($_REQUEST['detached']) || isset($_REQUEST['find_detached']);
     if (!isset($total_orphans)) {
         $total_orphans = $wpdb->get_var("\r\n\t\t\t\t\t\tSELECT COUNT( * ) \r\n\t\t\t\t\t\tFROM {$wpdb->posts} \r\n\t\t\t\t\t\tWHERE post_type = 'attachment' \r\n\t\t\t\t\t\tAND post_author = {$current_user->ID} \r\n\t\t\t\t\t\tAND post_status != 'trash' \r\n\t\t\t\t\t\tAND post_parent < 1\r\n\t\t\t\t\t");
     }
     $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']) && !$detached && !isset($_GET['status']) ? ' class="current"' : '';
     $views['all'] = "<a href='upload.php'{$class}>" . sprintf(__('All <span class="count">(%s)</span>', '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])) {
             $views[$mime_type] = "<a href='upload.php?post_mime_type={$mime_type}'{$class}>" . sprintf(translate_nooped_plural($label[2], $num_posts[$mime_type]), $num_posts[$mime_type]) . '</a>';
         }
     }
     $views['detached'] = '<a href="upload.php?detached=1"' . ($detached ? ' class="current"' : '') . '>' . sprintf(__('Unattached <span class="count">(%s)</span>', 'detached files'), $total_orphans) . '</a>';
     return $views;
 }
コード例 #14
0
 function get_views()
 {
     global $post_type_object, $locked_post_status, $avail_post_stati;
     $post_type = $this->post_type;
     if (!empty($locked_post_status)) {
         return array();
     }
     $status_links = array();
     $num_posts = $this->count_posts($post_type, 'readable');
     $class = '';
     $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($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>';
     $statuses = get_post_stati(array('show_in_admin_status_list' => true), 'objects');
     foreach ($statuses 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}&amp;post_type={$post_type}'{$class}>" . sprintf(translate_nooped_plural($status->label_count, $num_posts->{$status_name}), number_format_i18n($num_posts->{$status_name})) . '</a>';
     }
     $num_posts->total = $total_posts;
     return apply_filters("cpm_{$this->post_type}_table_views", $status_links, $num_posts, $statuses, $this->post_parent);
 }
コード例 #15
0
 /**
  *
  * @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);
 }
コード例 #16
0
 /**
  *
  * @global array $locked_post_status This seems to be deprecated.
  * @global array $avail_post_stati
  * @return array
  */
 protected function get_views()
 {
     global $locked_post_status, $avail_post_stati;
     $post_type = $this->screen->post_type;
     if (!empty($locked_post_status)) {
         return array();
     }
     $status_links = array();
     $num_posts = wp_count_posts($post_type, 'readable');
     $total_posts = array_sum((array) $num_posts);
     $class = '';
     $current_user_id = get_current_user_id();
     $all_args = array('post_type' => $post_type);
     $mine = '';
     // 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};
     }
     if ($this->user_posts_count && $this->user_posts_count !== $total_posts) {
         if (isset($_GET['author']) && $_GET['author'] == $current_user_id) {
             $class = 'current';
         }
         $mine_args = array('post_type' => $post_type, 'author' => $current_user_id);
         $mine_inner_html = 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));
         $mine = $this->get_edit_link($mine_args, $mine_inner_html, $class);
         $all_args['all_posts'] = 1;
         $class = '';
     }
     if (empty($class) && ($this->is_base_request() || isset($_REQUEST['all_posts']))) {
         $class = 'current';
     }
     $all_inner_html = sprintf(_nx('All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_posts, 'posts'), number_format_i18n($total_posts));
     $status_links['all'] = $this->get_edit_link($all_args, $all_inner_html, $class);
     if ($mine) {
         $status_links['mine'] = $mine;
     }
     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) || empty($num_posts->{$status_name})) {
             continue;
         }
         if (isset($_REQUEST['post_status']) && $status_name === $_REQUEST['post_status']) {
             $class = 'current';
         }
         $status_args = array('post_status' => $status_name, 'post_type' => $post_type);
         $status_label = sprintf(translate_nooped_plural($status->label_count, $num_posts->{$status_name}), number_format_i18n($num_posts->{$status_name}));
         $status_links[$status_name] = $this->get_edit_link($status_args, $status_label, $class);
     }
     if (!empty($this->sticky_posts_count)) {
         $class = !empty($_REQUEST['show_sticky']) ? 'current' : '';
         $sticky_args = array('post_type' => $post_type, 'show_sticky' => 1);
         $sticky_inner_html = 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));
         $sticky_link = array('sticky' => $this->get_edit_link($sticky_args, $sticky_inner_html, $class));
         // 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;
 }
コード例 #17
0
 /**
  * @return array
  */
 function get_views()
 {
     global $wpdb;
     $status_links = array();
     $states = get_post_stati(array('show_in_admin_all_list' => true));
     $states['trash'] = 'trash';
     $states = esc_sql($states);
     $all_states = "'" . implode("', '", $states) . "'";
     $subquery = $this->get_base_subquery();
     $total_posts = $wpdb->get_var("\n\t\t\t\t\tSELECT COUNT(ID) FROM {$subquery}\n\t\t\t\t\tWHERE post_status IN ({$all_states})\n\t\t\t\t");
     $post_status = filter_input(INPUT_GET, 'post_status');
     $class = empty($post_status) ? ' class="current"' : '';
     $status_links['all'] = '<a href="' . esc_url(admin_url('admin.php?page=YMBESEO_tools&tool=bulk-editor' . $this->page_url)) . '"' . $class . '>' . sprintf(_nx('All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_posts, 'posts', 'ymbeseo'), number_format_i18n($total_posts)) . '</a>';
     $post_stati = get_post_stati(array('show_in_admin_all_list' => true), 'objects');
     if (is_array($post_stati) && $post_stati !== array()) {
         foreach ($post_stati as $status) {
             $status_name = esc_sql($status->name);
             $total = (int) $wpdb->get_var($wpdb->prepare("\n\t\t\t\t\t\t\t\tSELECT COUNT(ID) FROM {$subquery}\n\t\t\t\t\t\t\t\tWHERE post_status = %s\n\t\t\t\t\t\t\t", $status_name));
             if ($total === 0) {
                 continue;
             }
             $class = '';
             if ($status_name === $post_status) {
                 $class = ' class="current"';
             }
             $status_links[$status_name] = '<a href="' . esc_url(add_query_arg(array('post_status' => $status_name), admin_url('admin.php?page=YMBESEO_tools&tool=bulk-editor' . $this->page_url))) . '"' . $class . '>' . sprintf(translate_nooped_plural($status->label_count, $total), number_format_i18n($total)) . '</a>';
         }
     }
     unset($post_stati, $status, $status_name, $total, $class);
     $trashed_posts = $wpdb->get_var("\n\t\t\t\t\tSELECT COUNT(ID) FROM {$subquery}\n\t\t\t\t\tWHERE post_status IN ('trash')\n\t\t\t\t");
     $class = '';
     if ('trash' === $post_status) {
         $class = 'class="current"';
     }
     $status_links['trash'] = '<a href="' . esc_url(admin_url('admin.php?page=YMBESEO_tools&tool=bulk-editor&post_status=trash' . $this->page_url)) . '"' . $class . '>' . sprintf(_nx('Trash <span class="count">(%s)</span>', 'Trash <span class="count">(%s)</span>', $trashed_posts, 'posts', 'ymbeseo'), number_format_i18n($trashed_posts)) . '</a>';
     return $status_links;
 }
コード例 #18
0
 /**
  * Table list views
  *
  * @return array
  */
 protected function get_views()
 {
     $status_links = array();
     $num_posts = wp_count_posts('shop_webhook', 'readable');
     $class = '';
     $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['status']) ? ' class="current"' : '';
     $status_links['all'] = "<a href='admin.php?page=wc-settings&amp;tab=api&amp;section=webhooks'{$class}>" . sprintf(_nx('All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_posts, 'posts', 'woocommerce'), 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, array('publish', 'draft', 'pending', 'trash', 'future', 'private', 'auto-draft'))) {
             continue;
         }
         if (empty($num_posts->{$status_name})) {
             continue;
         }
         if (isset($_REQUEST['status']) && $status_name == $_REQUEST['status']) {
             $class = ' class="current"';
         }
         $label = $this->get_status_label($status_name, $status);
         $status_links[$status_name] = "<a href='admin.php?page=wc-settings&amp;tab=api&amp;section=webhooks&amp;status={$status_name}'{$class}>" . sprintf(translate_nooped_plural($label, $num_posts->{$status_name}), number_format_i18n($num_posts->{$status_name})) . '</a>';
     }
     return $status_links;
 }
コード例 #19
0
ファイル: list.php プロジェクト: jfbelisle/magexpress
_e('Activate', 'w3-total-cache');
?>
</option>
            <option value="deactivate-selected"><?php 
_e('Deactivate', 'w3-total-cache');
?>
</option>
        </select>
        <input type="submit" name="" id="doaction" class="w3tc-button-save button action" value="<?php 
esc_attr_e('Apply');
?>
">
    </div>
    <div class="tablenav-pages one-page">
        <span class="displaying-num"><?php 
printf(translate_nooped_plural(_n_noop('%s extension', '%s extensions'), sizeof($extensions), 'w3-total-cache'), sizeof($extensions));
?>
</span>
    </div>
    <br class="clear">
</div>

<?php 
if (is_network_admin()) {
    ?>
    <p class="submit">
    <?php 
    echo $this->nonce_field('w3tc');
    ?>
    <input type="submit" name="w3tc_save_options" class="w3tc-button-save button-primary" value="<?php 
    _e('Save network settings', 'w3-total-cache');
コード例 #20
0
 /**
  * Update event counts.
  *
  * @param array $counts The counts array.
  *
  * @return array The modified counts array.
  */
 public static function update_event_counts($counts)
 {
     global $post_type, $post_type_object, $locked_post_status, $avail_post_stati;
     $num_posts = self::count_events();
     $total_posts = array_sum((array) $num_posts);
     foreach (get_post_stati(array('show_in_admin_all_list' => false)) as $state) {
         $total_posts -= $num_posts->{$state};
     }
     $counts['all'] = "<a href='edit.php?post_type=tribe_events' class='current'>" . sprintf(esc_html_x('All %s', '%s Event count in admin list', 'the-events-calendar'), "<span class='count'>({$total_posts})</span>") . '</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"';
         }
         $counts[$status_name] = "<a href='edit.php?post_status={$status_name}&amp;post_type={$post_type}'{$class}>" . sprintf(translate_nooped_plural($status->label_count, $num_posts->{$status_name}), number_format_i18n($num_posts->{$status_name})) . '</a>';
     }
     return $counts;
 }
コード例 #21
0
 /**
  * Echoes required plugin notice.
  *
  * Outputs a message telling users that a specific plugin is required for
  * their theme. If appropriate, it includes a link to the form page where
  * users can install and activate the plugin.
  *
  * @since 1.0.0
  *
  * @global object $current_screen
  * @return null Returns early if we're on the Install page
  */
 public function notices()
 {
     global $current_screen;
     /** Remove nag on the install page */
     if ($this->is_tgmpa_page()) {
         return;
     }
     $installed_plugins = get_plugins();
     // Retrieve a list of all the plugins
     $this->populate_file_path();
     $message = array();
     // Store the messages in an array to be outputted after plugins have looped through
     $install_link = false;
     // Set to false, change to true in loop if conditions exist, used for action link 'install'
     $update_link = false;
     // Set to false, change to true in loop if conditions exist, used for action link 'install'
     $install_link_count = 0;
     // Used to determine plurality of install action link text
     $update_link_count = 0;
     // Used to determine plurality of install action link text
     $activate_link = false;
     // Set to false, change to true in loop if conditions exist, used for action link 'activate'
     $activate_link_count = 0;
     // Used to determine plurality of activate action link text
     $update_available = false;
     foreach ($this->plugins as $plugin) {
         /** If the plugin is installed and active, check for minimum version argument before moving forward */
         if (is_plugin_active($plugin['file_path'])) {
             /** A minimum version has been specified */
             if (isset($plugin['version'])) {
                 if (isset($installed_plugins[$plugin['file_path']]['Version'])) {
                     /** If the current version is less than the minimum required version, we display a message */
                     if (version_compare($installed_plugins[$plugin['file_path']]['Version'], $plugin['version'], '<')) {
                         $update_link = true;
                         // We need to display the 'install' action link
                         $update_link_count++;
                         // Increment the install link count
                         if (current_user_can('install_plugins')) {
                             if ($plugin['required']) {
                                 $message['notice_can_install_required'][] = $plugin['name'];
                             } else {
                                 $message['notice_can_install_update'][] = $plugin['name'];
                             }
                         } else {
                             $message['notice_cannot_install'][] = $plugin['name'];
                         }
                         $update_available = true;
                     }
                 } else {
                     continue;
                 }
             } else {
                 continue;
             }
         }
         /** Not installed */
         if (!isset($installed_plugins[$plugin['file_path']])) {
             $install_link = true;
             // We need to display the 'install' action link
             $install_link_count++;
             // Increment the install link count
             if (current_user_can('install_plugins')) {
                 if ($plugin['required']) {
                     $message['notice_can_install_required'][] = $plugin['name'];
                 } else {
                     $message['notice_can_install_recommended'][] = $plugin['name'];
                 }
             } else {
                 $message['notice_cannot_install'][] = $plugin['name'];
             }
         } elseif (is_plugin_inactive($plugin['file_path'])) {
             $activate_link = true;
             // We need to display the 'activate' action link
             $activate_link_count++;
             // Increment the activate link count
             if (current_user_can('activate_plugins')) {
                 if (isset($plugin['required']) && $plugin['required']) {
                     $message['notice_can_activate_required'][] = $plugin['name'];
                 } else {
                     $message['notice_can_activate_recommended'][] = $plugin['name'];
                 }
             } else {
                 $message['notice_cannot_activate'][] = $plugin['name'];
             }
         }
     }
     if ($update_available) {
         update_user_meta(get_current_user_id(), 'tgmpa_dismissed_notice', 0);
     }
     if ($update_available && isset($_GET[sanitize_key('tgmpa-dismiss')])) {
         update_user_meta(get_current_user_id(), 'tgmpa_dismissed_notice', 1);
         $update_available = false;
     }
     /** Only process the nag messages if the user has not dismissed them already */
     if (!get_user_meta(get_current_user_id(), 'tgmpa_dismissed_notice', true) || $update_available) {
         /** If we have notices to display, we move forward */
         if (!empty($message)) {
             krsort($message);
             // Sort messages
             $rendered = '';
             // Display all nag messages as strings
             /** Grab all plugin names */
             foreach ($message as $type => $plugin_groups) {
                 $linked_plugin_groups = array();
                 /** Count number of plugins in each message group to calculate singular/plural message */
                 $count = count($plugin_groups);
                 /** Loop through the plugin names to make the ones pulled from the .org repo linked */
                 foreach ($plugin_groups as $plugin_group_single_name) {
                     $external_url = $this->_get_plugin_data_from_name($plugin_group_single_name, 'external_url');
                     $source = $this->_get_plugin_data_from_name($plugin_group_single_name, 'source');
                     if ($external_url && preg_match('|^http(s)?://|', $external_url)) {
                         $linked_plugin_groups[] = '<a href="' . esc_url($external_url) . '" title="' . $plugin_group_single_name . '" target="_blank">' . $plugin_group_single_name . '</a>';
                     } elseif (!$source || preg_match('|^http://wordpress.org/extend/plugins/|', $source)) {
                         $url = add_query_arg(array('tab' => 'plugin-information', 'plugin' => $this->_get_plugin_data_from_name($plugin_group_single_name), 'TB_iframe' => 'true', 'width' => '640', 'height' => '500'), admin_url('plugin-install.php'));
                         $linked_plugin_groups[] = '<a href="' . esc_url($url) . '" class="thickbox" title="' . $plugin_group_single_name . '">' . $plugin_group_single_name . '</a>';
                     } else {
                         $linked_plugin_groups[] = $plugin_group_single_name;
                         // No hyperlink
                     }
                     if (isset($linked_plugin_groups) && (array) $linked_plugin_groups) {
                         $plugin_groups = $linked_plugin_groups;
                     }
                 }
                 $last_plugin = array_pop($plugin_groups);
                 // Pop off last name to prep for readability
                 $imploded = empty($plugin_groups) ? '<em>' . $last_plugin . '</em>' : '<em>' . (implode(', ', $plugin_groups) . '</em> and <em>' . $last_plugin . '</em>');
                 $rendered .= '<p>' . sprintf(translate_nooped_plural($this->strings[$type], $count, THEMENAME), $imploded, $count) . '</p>';
                 // All messages now stored
             }
             /** Setup variables to determine if action links are needed */
             $show_install_link = $install_link ? '<a href="' . add_query_arg('page', $this->menu, admin_url($this->parent_url_slug)) . '">' . translate_nooped_plural($this->strings['install_link'], $install_link_count, THEMENAME) . '</a>' : '';
             $show_activate_link = $activate_link ? '<a href="' . admin_url('plugins.php') . '">' . translate_nooped_plural($this->strings['activate_link'], $activate_link_count, THEMENAME) . '</a>' : '';
             $show_update_link = $update_link ? '<a href="' . add_query_arg('page', $this->menu, admin_url($this->parent_url_slug)) . '">' . translate_nooped_plural($this->strings['update_link'], $update_link_count, THEMENAME) . '</a>' : '';
             /** Define all of the action links */
             $action_links = apply_filters('tgmpa_notice_action_links', array('install' => current_user_can('install_plugins') ? $show_install_link : '', 'update' => current_user_can('install_plugins') ? $show_update_link : '', 'activate' => current_user_can('activate_plugins') ? $show_activate_link : '', 'dismiss' => '<a class="dismiss-notice" href="' . add_query_arg('tgmpa-dismiss', 'dismiss_admin_notices') . '" target="_parent">' . __('Dismiss this notice', THEMENAME) . '</a>'));
             $action_links = array_filter($action_links);
             // Remove any empty array items
             if ($action_links) {
                 $rendered .= '<p>' . implode(' | ', $action_links) . '</p>';
             }
             /** Register the nag messages and prepare them to be processed */
             if (isset($this->strings['nag_type'])) {
                 add_settings_error('tgmpa', 'tgmpa', $rendered, sanitize_html_class(strtolower($this->strings['nag_type']), 'updated'));
             } else {
                 add_settings_error('tgmpa', 'tgmpa', $rendered, 'updated');
             }
         }
     }
     /** Admin options pages already output settings_errors, so this is to avoid duplication */
     if ('options-general' !== $current_screen->parent_base) {
         settings_errors('tgmpa');
     }
 }
 public function get_views()
 {
     global $locked_post_status;
     $parent = get_post($this->product_id);
     $avail_post_stati = get_available_post_statuses('wpsc-product');
     $post_type_object = get_post_type_object('wpsc-product');
     $post_type = $post_type_object->name;
     $url_base = add_query_arg(array('action' => 'wpsc_product_variations_table', 'product_id' => $_REQUEST['product_id'], '_wpnonce' => wp_create_nonce('wpsc_product_variations_table')), admin_url('admin-ajax.php'));
     if (!empty($locked_post_status)) {
         return array();
     }
     $status_links = array();
     $num_posts = $this->count_variations();
     $class = '';
     $current_user_id = get_current_user_id();
     if (isset($num_posts->inherit)) {
         $key = $parent->post_status;
         if (!isset($num_posts->{$key})) {
             $num_posts->{$key} = 0;
         }
         $num_posts->{$key} += $num_posts->inherit;
         unset($num_posts->inherit);
     }
     $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) {
         if (isset($num_posts->{$state})) {
             $total_posts -= $num_posts->{$state};
         }
     }
     $class = empty($class) && empty($_REQUEST['post_status']) && empty($_REQUEST['show_sticky']) ? ' class="current"' : '';
     $status_links['all'] = "<a href='{$url_base}'{$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 ($status_name == 'publish') {
             continue;
         }
         if (!in_array($status_name, $avail_post_stati)) {
             continue;
         }
         if (empty($num_posts->{$status_name})) {
             if (isset($_REQUEST['post_status']) && $status_name == $_REQUEST['post_status']) {
                 $num_posts->{$_REQUEST}['post_status'] = 0;
             } else {
                 continue;
             }
         }
         if (isset($_REQUEST['post_status']) && $status_name == $_REQUEST['post_status']) {
             $class = ' class="current"';
         }
         $status_links[$status_name] = "<a href='" . esc_url(add_query_arg('post_status', $status_name, $url_base)) . "'{$class}>" . sprintf(translate_nooped_plural($status->label_count, $num_posts->{$status_name}), number_format_i18n($num_posts->{$status_name})) . '</a>';
     }
     return $status_links;
 }
コード例 #23
0
 /**
  * Returns an array of views for the list table.
  *
  * @since  1.0.0
  * @access protected
  * @return array
  */
 protected function get_views()
 {
     $active = members_get_role_group('active');
     $inactive = members_get_role_group('inactive');
     if ($active) {
         $active->roles = members_get_active_role_slugs();
     }
     if ($inactive) {
         $inactive->roles = members_get_inactive_role_slugs();
     }
     $views = array();
     $current = ' class="current"';
     $all_count = count(members_get_role_slugs());
     // Add the default/all view.
     $views['all'] = sprintf('<a%s href="%s">%s</a>', 'all' === $this->role_view ? $current : '', esc_url(members_get_edit_roles_url()), sprintf(_n('All %s', 'All %s', $all_count, 'members'), sprintf('<span class="count">(%s)</span>', number_format_i18n($all_count))));
     // Loop through the role groups and put them into the view list.
     foreach (members_get_role_groups() as $group) {
         // Skip role groups that shouldn't be shown in the view list.
         if (!$group->show_in_view_list) {
             continue;
         }
         $count = count($group->roles);
         // Skip any views with 0 roles.
         if (0 >= $count) {
             continue;
         }
         $noop = $group->label_count;
         // Add the view link.
         $views[$group->name] = sprintf('<a%s href="%s">%s</a>', $group->name === $this->role_view ? $current : '', 'all' === $group->name ? esc_url(members_get_edit_roles_url()) : esc_url(members_get_role_view_url($group->name)), sprintf(translate_nooped_plural($noop, $count, $noop['domain']), sprintf('<span class="count">(%s)</span>', number_format_i18n($count))));
     }
     return apply_filters('members_manage_roles_views', $views, $this->role_view, members_get_edit_roles_url());
 }
コード例 #24
0
 /**
  * Return an associative array ( id => link ) with the list of views
  * available for this table.
  *
  * Calculates the count for each view.
  *
  * @since 1.0.0
  */
 function get_views()
 {
     global $wpdb;
     $post_type = 'audiotheme_gig';
     $post_type_object = get_post_type_object($post_type);
     $avail_post_stati = get_available_post_statuses($post_type);
     $base_url = get_audiotheme_gig_admin_url();
     $status_links = array();
     $num_posts = wp_count_posts($post_type, 'readable');
     $allposts = '';
     $current_user_id = get_current_user_id();
     /*
     // @todo This could be useful in a multiple artist context (for a label).
     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 $status) {
         $total_posts -= $num_posts->{$status};
     }
     $sql = "SELECT COUNT( DISTINCT p.ID )\r\n\t\t\tFROM {$wpdb->posts} p\r\n\t\t\tINNER JOIN {$wpdb->postmeta} pm ON p.ID=pm.post_id\r\n\t\t\tWHERE p.post_type='audiotheme_gig' AND p.post_status!='auto-draft' AND pm.meta_key='_audiotheme_gig_datetime'";
     $upcoming_count = $wpdb->get_var($wpdb->prepare($sql . ' AND pm.meta_value>=%s', current_time('mysql')));
     $status_links['upcoming'] = sprintf('<a href="%s"%s>%s <span class="count">(%d)</span></a>', esc_url($base_url), 'upcoming' === $this->current_view ? ' class="current"' : '', __('Upcoming', 'audiotheme'), $upcoming_count);
     $past_count = $wpdb->get_var($wpdb->prepare($sql . ' AND pm.meta_value<%s', current_time('mysql')));
     $status_links['past'] = sprintf('<a href="%s"%s>%s <span class="count">(%d)</span></a>', esc_url(add_query_arg(array('gig_date' => current_time('mysql'), 'compare' => '%3C'), $base_url)), 'past' === $this->current_view ? ' class="current"' : '', __('Past', 'audiotheme'), $past_count);
     $class = 'any' === $this->current_view ? ' class="current"' : '';
     $all_url = esc_url(add_query_arg('post_status', 'any', $base_url));
     $status_links['all'] = "<a href='{$all_url}{$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 ($status_name === $this->current_view) {
             $class = ' class="current"';
         }
         $status_url = esc_url(add_query_arg(array('post_status' => $status_name, 'post_type' => $post_type), $base_url));
         $status_links[$status_name] = "<a href='{$status_url}'{$class}>" . sprintf(translate_nooped_plural($status->label_count, $num_posts->{$status_name}), number_format_i18n($num_posts->{$status_name})) . '</a>';
     }
     return $status_links;
 }
コード例 #25
0
 /**
  * Echoes required plugin notice.
  *
  * Outputs a message telling users that a specific plugin is required for
  * their theme. If appropriate, it includes a link to the form page where
  * users can install and activate the plugin.
  *
  * @since 1.0.0
  *
  * @global object $current_screen
  * @return null Returns early if we're on the Install page.
  */
 public function notices()
 {
     global $current_screen;
     // Remove nag on the install page.
     if ($this->is_tgmpa_page()) {
         return;
     }
     // Return early if the nag message has been dismissed.
     if (get_user_meta(get_current_user_id(), 'tgmpa_dismissed_notice_' . $this->id, true)) {
         return;
     }
     $installed_plugins = get_plugins();
     // Retrieve a list of all the plugins
     $this->populate_file_path();
     $message = array();
     // Store the messages in an array to be outputted after plugins have looped through.
     $install_link = false;
     // Set to false, change to true in loop if conditions exist, used for action link 'install'.
     $install_link_count = 0;
     // Used to determine plurality of install action link text.
     $activate_link = false;
     // Set to false, change to true in loop if conditions exist, used for action link 'activate'.
     $activate_link_count = 0;
     // Used to determine plurality of activate action link text.
     foreach ($this->plugins as $plugin) {
         // If the plugin is installed and active, check for minimum version argument before moving forward.
         if (is_plugin_active($plugin['file_path']) || isset($plugin['is_callable']) && is_callable($plugin['is_callable'])) {
             // A minimum version has been specified.
             if (isset($plugin['version'])) {
                 if (isset($installed_plugins[$plugin['file_path']]['Version'])) {
                     // If the current version is less than the minimum required version, we display a message.
                     if (version_compare($installed_plugins[$plugin['file_path']]['Version'], $plugin['version'], '<')) {
                         if (current_user_can('install_plugins')) {
                             $message['notice_ask_to_update'][] = $plugin['name'];
                         } else {
                             $message['notice_cannot_update'][] = $plugin['name'];
                         }
                     }
                 } else {
                     continue;
                 }
             } else {
                 continue;
             }
         }
         // Not installed.
         if (!isset($installed_plugins[$plugin['file_path']])) {
             $install_link = true;
             // We need to display the 'install' action link.
             $install_link_count++;
             // Increment the install link count.
             if (current_user_can('install_plugins')) {
                 if (isset($plugin['required']) && $plugin['required']) {
                     $message['notice_can_install_required'][] = $plugin['name'];
                 } else {
                     $message['notice_can_install_recommended'][] = $plugin['name'];
                 }
             } else {
                 $message['notice_cannot_install'][] = $plugin['name'];
             }
         } elseif (is_plugin_inactive($plugin['file_path'])) {
             $activate_link = true;
             // We need to display the 'activate' action link.
             $activate_link_count++;
             // Increment the activate link count.
             if (current_user_can('activate_plugins')) {
                 if (isset($plugin['required']) && $plugin['required']) {
                     $message['notice_can_activate_required'][] = $plugin['name'];
                 } else {
                     $message['notice_can_activate_recommended'][] = $plugin['name'];
                 }
             } else {
                 $message['notice_cannot_activate'][] = $plugin['name'];
             }
         }
     }
     // If we have notices to display, we move forward.
     if (!empty($message)) {
         krsort($message);
         // Sort messages.
         $rendered = '';
         // Display all nag messages as strings.
         // If dismissable is false and a message is set, output it now.
         if (!$this->dismissable && !empty($this->dismiss_msg)) {
             $rendered .= '<p><strong>' . wp_kses_post($this->dismiss_msg) . '</strong></p>';
         }
         // Grab all plugin names.
         foreach ($message as $type => $plugin_groups) {
             $linked_plugin_groups = array();
             // Count number of plugins in each message group to calculate singular/plural message.
             $count = count($plugin_groups);
             // Loop through the plugin names to make the ones pulled from the .org repo linked.
             foreach ($plugin_groups as $plugin_group_single_name) {
                 $external_url = $this->_get_plugin_data_from_name($plugin_group_single_name, 'external_url');
                 $source = $this->_get_plugin_data_from_name($plugin_group_single_name, 'source');
                 if ($external_url && preg_match('|^http(s)?://|', $external_url)) {
                     $linked_plugin_groups[] = '<a href="' . esc_url($external_url) . '" target="_blank">' . $plugin_group_single_name . '</a>';
                 } elseif (!$source || preg_match('|^http://wordpress.org/extend/plugins/|', $source)) {
                     $url = add_query_arg(array('tab' => 'plugin-information', 'plugin' => urlencode($this->_get_plugin_data_from_name($plugin_group_single_name)), 'TB_iframe' => 'true', 'width' => '640', 'height' => '500'), self_admin_url('plugin-install.php'));
                     $linked_plugin_groups[] = '<a href="' . esc_url($url) . '" class="thickbox">' . $plugin_group_single_name . '</a>';
                 } else {
                     $linked_plugin_groups[] = $plugin_group_single_name;
                     // No hyperlink.
                 }
                 if (isset($linked_plugin_groups) && (array) $linked_plugin_groups) {
                     $plugin_groups = $linked_plugin_groups;
                 }
             }
             $last_plugin = array_pop($plugin_groups);
             // Pop off last name to prep for readability.
             $imploded = empty($plugin_groups) ? '<em>' . $last_plugin . '</em>' : '<em>' . (implode(', ', $plugin_groups) . '</em> and <em>' . $last_plugin . '</em>');
             $rendered .= '<p>' . sprintf(translate_nooped_plural($this->strings[$type], $count, 'tgmpa'), $imploded, $count) . '</p>';
         }
         // Setup variables to determine if action links are needed.
         $show_install_link = $install_link ? '<a href="' . esc_url(add_query_arg('page', urlencode($this->menu), self_admin_url($this->parent_slug))) . '">' . translate_nooped_plural($this->strings['install_link'], $install_link_count, 'tgmpa') . '</a>' : '';
         $show_activate_link = $activate_link ? '<a href="' . esc_url(add_query_arg('page', urlencode($this->menu), self_admin_url($this->parent_slug))) . '">' . translate_nooped_plural($this->strings['activate_link'], $activate_link_count, 'tgmpa') . '</a>' : '';
         // Define all of the action links.
         $action_links = apply_filters('tgmpa_notice_action_links', array('install' => current_user_can('install_plugins') ? $show_install_link : '', 'activate' => current_user_can('activate_plugins') ? $show_activate_link : '', 'dismiss' => $this->dismissable ? '<a class="dismiss-notice" href="' . esc_url(add_query_arg('tgmpa-dismiss', 'dismiss_admin_notices')) . '" target="_parent">' . $this->strings['dismiss'] . '</a>' : ''));
         $action_links = array_filter($action_links);
         // Remove any empty array items.
         if ($action_links) {
             $rendered .= apply_filters('tgmpa_notice_rendered_action_links', '<p>' . implode(' | ', $action_links) . '</p>');
         }
         // Register the nag messages and prepare them to be processed.
         $nag_class = version_compare($this->wp_version, '3.8', '<') ? 'updated' : 'update-nag';
         if (!empty($this->strings['nag_type'])) {
             add_settings_error('tgmpa', 'tgmpa', $rendered, sanitize_html_class(strtolower($this->strings['nag_type'])));
         } else {
             add_settings_error('tgmpa', 'tgmpa', $rendered, $nag_class);
         }
     }
     // Admin options pages already output settings_errors, so this is to avoid duplication.
     if ('options-general' !== $current_screen->parent_base) {
         $this->display_settings_errors();
     }
 }
コード例 #26
0
/**
 * Generates a tag cloud (heatmap) from provided data.
 *
 * @todo Complete functionality.
 * @since 2.3.0
 *
 * @param array $tags List of tags.
 * @param string|array $args {
 *     Optional. Array of string of arguments for generating a tag cloud.
 *
 *     @type int      $smallest                   Smallest font size used to display tags. Paired
 *                                                with the value of `$unit`, to determine CSS text
 *                                                size unit. Default 8 (pt).
 *     @type int      $largest                    Largest font size used to display tags. Paired
 *                                                with the value of `$unit`, to determine CSS text
 *                                                size unit. Default 22 (pt).
 *     @type string   $unit                       CSS text size unit to use with the `$smallest`
 *                                                and `$largest` values. Accepts any valid CSS text
 *                                                size unit. Default 'pt'.
 *     @type int      $number                     The number of tags to return. Accepts any
 *                                                positive integer or zero to return all.
 *                                                Default 0.
 *     @type string   $format                     Format to display the tag cloud in. Accepts 'flat'
 *                                                (tags separated with spaces), 'list' (tags displayed
 *                                                in an unordered list), or 'array' (returns an array).
 *                                                Default 'flat'.
 *     @type string   $separator                  HTML or text to separate the tags. Default "\n" (newline).
 *     @type string   $orderby                    Value to order tags by. Accepts 'name' or 'count'.
 *                                                Default 'name'. The {@see 'tag_cloud_sort'} filter
 *                                                can also affect how tags are sorted.
 *     @type string   $order                      How to order the tags. Accepts 'ASC' (ascending),
 *                                                'DESC' (descending), or 'RAND' (random). Default 'ASC'.
 *     @type int|bool $filter                     Whether to enable filtering of the final output
 *                                                via {@see 'wp_generate_tag_cloud'}. Default 1|true.
 *     @type string   $topic_count_text           Nooped plural text from _n_noop() to supply to
 *                                                tag tooltips. Default null.
 *     @type callable $topic_count_text_callback  Callback used to generate nooped plural text for
 *                                                tag tooltips based on the count. Default null.
 *     @type callable $topic_count_scale_callback Callback used to determine the tag count scaling
 *                                                value. Default default_topic_count_scale().
 * }
 * @return string|array Tag cloud as a string or an array, depending on 'format' argument.
 */
function wp_generate_tag_cloud($tags, $args = '')
{
    $defaults = array('smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 0, 'format' => 'flat', 'separator' => "\n", 'orderby' => 'name', 'order' => 'ASC', 'topic_count_text' => null, 'topic_count_text_callback' => null, 'topic_count_scale_callback' => 'default_topic_count_scale', 'filter' => 1);
    $args = wp_parse_args($args, $defaults);
    $return = 'array' === $args['format'] ? array() : '';
    if (empty($tags)) {
        return $return;
    }
    // Juggle topic count tooltips:
    if (isset($args['topic_count_text'])) {
        // First look for nooped plural support via topic_count_text.
        $translate_nooped_plural = $args['topic_count_text'];
    } elseif (!empty($args['topic_count_text_callback'])) {
        // Look for the alternative callback style. Ignore the previous default.
        if ($args['topic_count_text_callback'] === 'default_topic_count_text') {
            $translate_nooped_plural = _n_noop('%s topic', '%s topics');
        } else {
            $translate_nooped_plural = false;
        }
    } elseif (isset($args['single_text']) && isset($args['multiple_text'])) {
        // If no callback exists, look for the old-style single_text and multiple_text arguments.
        $translate_nooped_plural = _n_noop($args['single_text'], $args['multiple_text']);
    } else {
        // This is the default for when no callback, plural, or argument is passed in.
        $translate_nooped_plural = _n_noop('%s topic', '%s topics');
    }
    /**
     * Filters how the items in a tag cloud are sorted.
     *
     * @since 2.8.0
     *
     * @param array $tags Ordered array of terms.
     * @param array $args An array of tag cloud arguments.
     */
    $tags_sorted = apply_filters('tag_cloud_sort', $tags, $args);
    if (empty($tags_sorted)) {
        return $return;
    }
    if ($tags_sorted !== $tags) {
        $tags = $tags_sorted;
        unset($tags_sorted);
    } else {
        if ('RAND' === $args['order']) {
            shuffle($tags);
        } else {
            // SQL cannot save you; this is a second (potentially different) sort on a subset of data.
            if ('name' === $args['orderby']) {
                uasort($tags, '_wp_object_name_sort_cb');
            } else {
                uasort($tags, '_wp_object_count_sort_cb');
            }
            if ('DESC' === $args['order']) {
                $tags = array_reverse($tags, true);
            }
        }
    }
    if ($args['number'] > 0) {
        $tags = array_slice($tags, 0, $args['number']);
    }
    $counts = array();
    $real_counts = array();
    // For the alt tag
    foreach ((array) $tags as $key => $tag) {
        $real_counts[$key] = $tag->count;
        $counts[$key] = call_user_func($args['topic_count_scale_callback'], $tag->count);
    }
    $min_count = min($counts);
    $spread = max($counts) - $min_count;
    if ($spread <= 0) {
        $spread = 1;
    }
    $font_spread = $args['largest'] - $args['smallest'];
    if ($font_spread < 0) {
        $font_spread = 1;
    }
    $font_step = $font_spread / $spread;
    // Assemble the data that will be used to generate the tag cloud markup.
    $tags_data = array();
    foreach ($tags as $key => $tag) {
        $tag_id = isset($tag->id) ? $tag->id : $key;
        $count = $counts[$key];
        $real_count = $real_counts[$key];
        if ($translate_nooped_plural) {
            $title = sprintf(translate_nooped_plural($translate_nooped_plural, $real_count), number_format_i18n($real_count));
        } else {
            $title = call_user_func($args['topic_count_text_callback'], $real_count, $tag, $args);
        }
        $tags_data[] = array('id' => $tag_id, 'url' => '#' != $tag->link ? $tag->link : '#', 'role' => '#' != $tag->link ? '' : ' role="button"', 'name' => $tag->name, 'title' => $title, 'slug' => $tag->slug, 'real_count' => $real_count, 'class' => 'tag-link-' . $tag_id, 'font_size' => $args['smallest'] + ($count - $min_count) * $font_step);
    }
    /**
     * Filters the data used to generate the tag cloud.
     *
     * @since 4.3.0
     *
     * @param array $tags_data An array of term data for term used to generate the tag cloud.
     */
    $tags_data = apply_filters('wp_generate_tag_cloud_data', $tags_data);
    $a = array();
    // generate the output links array
    foreach ($tags_data as $key => $tag_data) {
        $class = $tag_data['class'] . ' tag-link-position-' . ($key + 1);
        $a[] = "<a href='" . esc_url($tag_data['url']) . "'" . $tag_data['role'] . " class='" . esc_attr($class) . "' title='" . esc_attr($tag_data['title']) . "' style='font-size: " . esc_attr(str_replace(',', '.', $tag_data['font_size']) . $args['unit']) . ";'>" . esc_html($tag_data['name']) . "</a>";
    }
    switch ($args['format']) {
        case 'array':
            $return =& $a;
            break;
        case 'list':
            $return = "<ul class='wp-tag-cloud'>\n\t<li>";
            $return .= join("</li>\n\t<li>", $a);
            $return .= "</li>\n</ul>\n";
            break;
        default:
            $return = join($args['separator'], $a);
            break;
    }
    if ($args['filter']) {
        /**
         * Filters the generated output of a tag cloud.
         *
         * The filter is only evaluated if a true value is passed
         * to the $filter argument in wp_generate_tag_cloud().
         *
         * @since 2.3.0
         *
         * @see wp_generate_tag_cloud()
         *
         * @param array|string $return String containing the generated HTML tag cloud output
         *                             or an array of tag links if the 'format' argument
         *                             equals 'array'.
         * @param array        $tags   An array of terms used in the tag cloud.
         * @param array        $args   An array of wp_generate_tag_cloud() arguments.
         */
        return apply_filters('wp_generate_tag_cloud', $return, $tags, $args);
    } else {
        return $return;
    }
}
コード例 #27
0
ファイル: media.php プロジェクト: HaraShun/WordPress
/**
 * {@internal Missing Short Description}}
 *
 * @since 2.5.0
 *
 * @param array $errors
 */
function media_upload_library_form($errors)
{
    global $wpdb, $wp_query, $wp_locale, $type, $tab, $post_mime_types;
    media_upload_header();
    $post_id = isset($_REQUEST['post_id']) ? intval($_REQUEST['post_id']) : 0;
    $form_action_url = admin_url("media-upload.php?type={$type}&tab=library&post_id={$post_id}");
    /** This filter is documented in wp-admin/includes/media.php */
    $form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type);
    $form_class = 'media-upload-form validate';
    if (get_user_setting('uploader')) {
        $form_class .= ' html-uploader';
    }
    $q = $_GET;
    $q['posts_per_page'] = 10;
    $q['paged'] = isset($q['paged']) ? intval($q['paged']) : 0;
    if ($q['paged'] < 1) {
        $q['paged'] = 1;
    }
    $q['offset'] = ($q['paged'] - 1) * 10;
    if ($q['offset'] < 1) {
        $q['offset'] = 0;
    }
    list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query($q);
    ?>

<form id="filter" action="" method="get">
<input type="hidden" name="type" value="<?php 
    echo esc_attr($type);
    ?>
" />
<input type="hidden" name="tab" value="<?php 
    echo esc_attr($tab);
    ?>
" />
<input type="hidden" name="post_id" value="<?php 
    echo (int) $post_id;
    ?>
" />
<input type="hidden" name="post_mime_type" value="<?php 
    echo isset($_GET['post_mime_type']) ? esc_attr($_GET['post_mime_type']) : '';
    ?>
" />
<input type="hidden" name="context" value="<?php 
    echo isset($_GET['context']) ? esc_attr($_GET['context']) : '';
    ?>
" />

<p id="media-search" class="search-box">
	<label class="screen-reader-text" for="media-search-input"><?php 
    _e('Search Media');
    ?>
:</label>
	<input type="search" id="media-search-input" name="s" value="<?php 
    the_search_query();
    ?>
" />
	<?php 
    submit_button(__('Search Media'), 'button', '', false);
    ?>
</p>

<ul class="subsubsub">
<?php 
    $type_links = array();
    $_num_posts = (array) wp_count_attachments();
    $matches = wp_match_mime_types(array_keys($post_mime_types), array_keys($_num_posts));
    foreach ($matches as $_type => $reals) {
        foreach ($reals as $real) {
            if (isset($num_posts[$_type])) {
                $num_posts[$_type] += $_num_posts[$real];
            } else {
                $num_posts[$_type] = $_num_posts[$real];
            }
        }
    }
    // If available type specified by media button clicked, filter by that type
    if (empty($_GET['post_mime_type']) && !empty($num_posts[$type])) {
        $_GET['post_mime_type'] = $type;
        list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query();
    }
    if (empty($_GET['post_mime_type']) || $_GET['post_mime_type'] == 'all') {
        $class = ' class="current"';
    } else {
        $class = '';
    }
    $type_links[] = '<li><a href="' . esc_url(add_query_arg(array('post_mime_type' => 'all', 'paged' => false, 'm' => false))) . '"' . $class . '>' . __('All Types') . '</a>';
    foreach ($post_mime_types as $mime_type => $label) {
        $class = '';
        if (!wp_match_mime_types($mime_type, $avail_post_mime_types)) {
            continue;
        }
        if (isset($_GET['post_mime_type']) && wp_match_mime_types($mime_type, $_GET['post_mime_type'])) {
            $class = ' class="current"';
        }
        $type_links[] = '<li><a href="' . esc_url(add_query_arg(array('post_mime_type' => $mime_type, 'paged' => false))) . '"' . $class . '>' . sprintf(translate_nooped_plural($label[2], $num_posts[$mime_type]), '<span id="' . $mime_type . '-counter">' . number_format_i18n($num_posts[$mime_type]) . '</span>') . '</a>';
    }
    /**
     * Filter the media upload mime type list items.
     *
     * Returned values should begin with an <li> tag.
     *
     * @since 3.1.0
     *
     * @param array $type_links An array of list items containing mime type link HTML.
     */
    echo implode(' | </li>', apply_filters('media_upload_mime_type_links', $type_links)) . '</li>';
    unset($type_links);
    ?>
</ul>

<div class="tablenav">

<?php 
    $page_links = paginate_links(array('base' => add_query_arg('paged', '%#%'), 'format' => '', 'prev_text' => __('&laquo;'), 'next_text' => __('&raquo;'), 'total' => ceil($wp_query->found_posts / 10), 'current' => $q['paged']));
    if ($page_links) {
        echo "<div class='tablenav-pages'>{$page_links}</div>";
    }
    ?>

<div class="alignleft actions">
<?php 
    $arc_query = "SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM {$wpdb->posts} WHERE post_type = 'attachment' ORDER BY post_date DESC";
    $arc_result = $wpdb->get_results($arc_query);
    $month_count = count($arc_result);
    $selected_month = isset($_GET['m']) ? $_GET['m'] : 0;
    if ($month_count && !(1 == $month_count && 0 == $arc_result[0]->mmonth)) {
        ?>
<select name='m'>
<option<?php 
        selected($selected_month, 0);
        ?>
 value='0'><?php 
        _e('All dates');
        ?>
</option>
<?php 
        foreach ($arc_result as $arc_row) {
            if ($arc_row->yyear == 0) {
                continue;
            }
            $arc_row->mmonth = zeroise($arc_row->mmonth, 2);
            if ($arc_row->yyear . $arc_row->mmonth == $selected_month) {
                $default = ' selected="selected"';
            } else {
                $default = '';
            }
            echo "<option{$default} value='" . esc_attr($arc_row->yyear . $arc_row->mmonth) . "'>";
            echo esc_html($wp_locale->get_month($arc_row->mmonth) . " {$arc_row->yyear}");
            echo "</option>\n";
        }
        ?>
</select>
<?php 
    }
    ?>

<?php 
    submit_button(__('Filter &#187;'), 'button', 'post-query-submit', false);
    ?>

</div>

<br class="clear" />
</div>
</form>

<form enctype="multipart/form-data" method="post" action="<?php 
    echo esc_url($form_action_url);
    ?>
" class="<?php 
    echo $form_class;
    ?>
" id="library-form">

<?php 
    wp_nonce_field('media-form');
    //media_upload_form( $errors );
    ?>

<script type="text/javascript">
<!--
jQuery(function($){
	var preloaded = $(".media-item.preloaded");
	if ( preloaded.length > 0 ) {
		preloaded.each(function(){prepareMediaItem({id:this.id.replace(/[^0-9]/g, '')},'');});
		updateMediaForm();
	}
});
-->
</script>

<div id="media-items">
<?php 
    add_filter('attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2);
    echo get_media_items(null, $errors);
    ?>
</div>
<p class="ml-submit">
<?php 
    submit_button(__('Save all changes'), 'button savebutton', 'save', false);
    ?>
<input type="hidden" name="post_id" id="post_id" value="<?php 
    echo (int) $post_id;
    ?>
" />
</p>
</form>
<?php 
}
コード例 #28
0
    /**
     * {@internal Missing Short Description}}
     *
     * @since 2.5.0
     *
     * @param unknown_type $errors
     */
    function media_upload_shared_media($errors)
    {
        global $wpdb, $wp_query, $wp_locale, $type, $tab, $post_mime_types, $blog_id;
        media_upload_header();
        if (count($this->blogs) == 0) {
            echo '<form><h3 class="media-title">' . __("You don't have access to any other sites media...", 'networksharedmedia') . '</h3></form>';
            return;
        }
        // set the first part of the form action url now, to the current active site, to prevent X-Frame-Options problems
        $form_action_url = plugins_url('media-upload.php', __FILE__);
        $nsm_blog_id = null;
        if (!array_key_exists('blog_id', $_GET)) {
            $_GET['blog_id'] = null;
        }
        foreach ($this->blogs as $blog) {
            if ($_GET['blog_id'] == $blog['blog_id']) {
                $nsm_blog_id = $blog['blog_id'];
                break;
            }
        }
        if (null == $nsm_blog_id) {
            $nsm_blog_id = $this->blogs[0]['blog_id'];
        }
        switch_to_blog($nsm_blog_id);
        ?>

<?php 
        $post_id = intval($_REQUEST['post_id']);
        // fix to make get_media_item add "Insert" button
        unset($_GET['post_id']);
        $form_action_url .= "?type={$type}&tab=library&post_id={$post_id}&blog_id={$blog_id}";
        $form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type);
        $form_class = 'media-upload-form validate';
        $_GET['paged'] = isset($_GET['paged']) ? intval($_GET['paged']) : 0;
        if ($_GET['paged'] < 1) {
            $_GET['paged'] = 1;
        }
        $start = ($_GET['paged'] - 1) * 10;
        if ($start < 1) {
            $start = 0;
        }
        add_filter('post_limits', create_function('$a', "return 'LIMIT {$start}, 10';"));
        list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query();
        ?>
	
	<form id="filter" action="" method="get">
	<input type="hidden" name="type" value="<?php 
        echo esc_attr($type);
        ?>
" />
	<input type="hidden" name="tab" value="<?php 
        echo esc_attr($tab);
        ?>
" />
	<input type="hidden" name="post_id" value="<?php 
        echo (int) $post_id;
        ?>
" />
	<input type="hidden" name="blog_id" value="<?php 
        echo (int) $blog_id;
        ?>
" />
	<input type="hidden" name="post_mime_type" value="<?php 
        echo isset($_GET['post_mime_type']) ? esc_attr($_GET['post_mime_type']) : '';
        ?>
" />
	<?php 
        if (isset($_GET['chromeless'])) {
            ?>
	<input type="hidden" name="chromeless" value="<?php 
            echo (bool) $_GET['chromeless'];
            ?>
" />
	<?php 
        }
        ?>

	<style type="text/css">
		#media-upload #filter .nsm-site-select { float: none; width: 100%; margin: 0 1em 2em 1em; white-space: normal; }
	</style>

	<ul class="subsubsub nsm-site-select">
	<?php 
        if (count($this->blogs) == 1) {
            $blog = reset($this->blogs);
            echo "<li>" . __('Selected site:', 'networksharedmedia') . "</li>" . "<li><a href='" . esc_url(add_query_arg(array('blog_id' => $blog['blog_id'], 'paged' => false))) . "' class='current'>" . $blog['name'] . '</a>' . '</li>';
        } else {
            $all_blog_names = array();
            foreach ($this->blogs as $blog) {
                $all_blog_names[] = $blog['name'];
            }
            if (strlen(__('Select site:', 'networksharedmedia') . ' ' . implode(' | ', $all_blog_names)) < 71) {
                $blog_links = array();
                foreach ($this->blogs as $blog) {
                    $class = '';
                    if ($blog['blog_id'] == $blog_id) {
                        $class = ' class="current"';
                    }
                    $blog_links[] = "<li><a href='" . esc_url(add_query_arg(array('blog_id' => $blog['blog_id'], 'paged' => false))) . "'{$class}>" . $blog['name'] . '</a>';
                }
                echo "<li>" . __('Select site:', 'networksharedmedia') . " </li>" . implode(' | </li>', $blog_links) . '</li>';
                unset($blog_links);
            } else {
                $blog_options = array();
                foreach ($this->blogs as $blog) {
                    $selected = '';
                    if ($blog['blog_id'] == $blog_id) {
                        $selected = ' selected="selected"';
                    }
                    $blog_options[] = "<option value='{$blog['blog_id']}'{$selected}>" . $blog['name'] . '</option>';
                }
                echo "<li>" . __('Select site:', 'networksharedmedia') . "</li><li> <select name='blog_id'>" . implode('', $blog_options) . '</select></li><li> ' . get_submit_button(__('Select &#187;', 'networksharedmedia'), 'secondary', 'nsm-post-query-submit', false) . '</li>';
                unset($blog_options);
            }
            unset($all_blog_names);
        }
        ?>
	</ul>

	<p id="media-search" class="search-box">
		<label class="screen-reader-text" for="media-search-input"><?php 
        _e('Search Media');
        ?>
:</label>
		<input type="text" id="media-search-input" name="s" value="<?php 
        the_search_query();
        ?>
" />
		<?php 
        submit_button(__('Search Media'), 'button', '', false);
        ?>
	</p>
	
	<ul class="subsubsub">
	<?php 
        $type_links = array();
        $_num_posts = (array) wp_count_attachments();
        $matches = wp_match_mime_types(array_keys($post_mime_types), array_keys($_num_posts));
        foreach ($matches as $_type => $reals) {
            foreach ($reals as $real) {
                if (isset($num_posts[$_type])) {
                    $num_posts[$_type] += $_num_posts[$real];
                } else {
                    $num_posts[$_type] = $_num_posts[$real];
                }
            }
        }
        // If available type specified by media button clicked, filter by that type
        if (empty($_GET['post_mime_type']) && !empty($num_posts[$type])) {
            $_GET['post_mime_type'] = $type;
            list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query();
        }
        if (empty($_GET['post_mime_type']) || $_GET['post_mime_type'] == 'all') {
            $class = ' class="current"';
        } else {
            $class = '';
        }
        $type_links[] = "<li><a href='" . esc_url(add_query_arg(array('post_mime_type' => 'all', 'paged' => false, 'm' => false))) . "'{$class}>" . __('All Types') . "</a>";
        foreach ($post_mime_types as $mime_type => $label) {
            $class = '';
            if (!wp_match_mime_types($mime_type, $avail_post_mime_types)) {
                continue;
            }
            if (isset($_GET['post_mime_type']) && wp_match_mime_types($mime_type, $_GET['post_mime_type'])) {
                $class = ' class="current"';
            }
            $type_links[] = "<li><a href='" . esc_url(add_query_arg(array('post_mime_type' => $mime_type, 'paged' => false))) . "'{$class}>" . sprintf(translate_nooped_plural($label[2], $num_posts[$mime_type]), "<span id='{$mime_type}-counter'>" . number_format_i18n($num_posts[$mime_type]) . '</span>') . '</a>';
        }
        echo implode(' | </li>', apply_filters('media_upload_mime_type_links', $type_links)) . '</li>';
        unset($type_links);
        ?>
	</ul>
	
	<div class="tablenav">
	
	<?php 
        $page_links = paginate_links(array('base' => add_query_arg('paged', '%#%'), 'format' => '', 'prev_text' => __('&laquo;'), 'next_text' => __('&raquo;'), 'total' => ceil($wp_query->found_posts / 10), 'current' => $_GET['paged']));
        if ($page_links) {
            echo "<div class='tablenav-pages'>{$page_links}</div>";
        }
        ?>
	
	<div class="alignleft actions">
	<?php 
        $arc_query = "SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM {$wpdb->posts} WHERE post_type = 'attachment' ORDER BY post_date DESC";
        $arc_result = $wpdb->get_results($arc_query);
        $month_count = count($arc_result);
        if ($month_count && !(1 == $month_count && 0 == $arc_result[0]->mmonth)) {
            ?>
	<select name='m'>
	<option<?php 
            selected(@$_GET['m'], 0);
            ?>
 value='0'><?php 
            _e('Show all dates');
            ?>
</option>
	<?php 
            foreach ($arc_result as $arc_row) {
                if ($arc_row->yyear == 0) {
                    continue;
                }
                $arc_row->mmonth = zeroise($arc_row->mmonth, 2);
                if (isset($_GET['m']) && $arc_row->yyear . $arc_row->mmonth == $_GET['m']) {
                    $default = ' selected="selected"';
                } else {
                    $default = '';
                }
                echo "<option{$default} value='" . esc_attr($arc_row->yyear . $arc_row->mmonth) . "'>";
                echo esc_html($wp_locale->get_month($arc_row->mmonth) . " {$arc_row->yyear}");
                echo "</option>\n";
            }
            ?>
	</select>
	<?php 
        }
        ?>
	
	<?php 
        submit_button(__('Filter &#187;'), 'secondary', 'post-query-submit', false);
        ?>
	
	</div>
	
	<br class="clear" />
	</div>
	</form>
	
	<form enctype="multipart/form-data" method="post" action="<?php 
        echo esc_attr($form_action_url);
        ?>
" class="<?php 
        echo $form_class;
        ?>
" id="library-form">
	
	<?php 
        wp_nonce_field('media-form');
        ?>
	<?php 
        //media_upload_form( $errors );
        ?>

	<?php 
        if (isset($_GET['chromeless']) && $_GET['chromeless']) {
            // WP3.5+ Media Browser calls iframe 'chromeless' and handles inserting differently
            ?>
	<script type="text/javascript">
	/* <![CDATA[ */
	function nsm_media_send_to_editor(htmlString) {
		<?php 
            /* copied from /wp-admin/includes/media.php media_send_to_editor() */
            ?>
		var win = window.dialogArguments || opener || parent || top;
		win.send_to_editor(htmlString);
	}

	jQuery(function($){
		$('input[id^=send].button').click(function(event) {
			event.preventDefault();
			var $this = $(event.target);
			var form = $('#library-form');
			var result = $.ajax({
				url: form.attr('action'),
				type: form.attr('method'),
				data: form.serialize() + '&' + encodeURIComponent($this.attr('id') ) + '=true&chromeless=1',
				success: nsm_media_send_to_editor
			});
		});
	});
	/* ]]> */
	</script>
	<?php 
        }
        /* chromeless */
        ?>

	<script type="text/javascript">
	<!--
	jQuery(function($){
		var preloaded = $(".media-item.preloaded");
		if ( preloaded.length > 0 ) {
			preloaded.each(function(){prepareMediaItem({id:this.id.replace(/[^0-9]/g, '')},'');});
			updateMediaForm();
		}
	});
	-->
	</script>
	
	<div id="media-items">
	<?php 
        add_filter('attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2);
        ?>
	<?php 
        echo $this->get_media_items(null, $errors);
        ?>
	</div>
	<p class="ml-submit"></p>
	</form>
	<?php 
    }
コード例 #29
0
 /**
  * Echoes required plugin notice.
  *
  * Outputs a message telling users that a specific plugin is required for
  * their theme. If appropriate, it includes a link to the form page where
  * users can install and activate the plugin.
  *
  * Returns early if we're on the Install page.
  *
  * @since 1.0.0
  *
  * @global object $current_screen
  *
  * @return null Returns early if we're on the Install page.
  */
 public function notices()
 {
     // Remove nag on the install page / Return early if the nag message has been dismissed.
     if ($this->is_tgmpa_page() || get_user_meta(get_current_user_id(), 'tgmpa_dismissed_notice_' . $this->id, true)) {
         return;
     }
     // Store for the plugin slugs by message type.
     $message = array();
     // Initialize counters used to determine plurality of action link texts.
     $install_link_count = 0;
     $update_link_count = 0;
     $activate_link_count = 0;
     foreach ($this->plugins as $slug => $plugin) {
         if ($this->is_plugin_active($slug) && false === $this->does_plugin_have_update($slug)) {
             continue;
         }
         if (!$this->is_plugin_installed($slug)) {
             if (current_user_can('install_plugins')) {
                 $install_link_count++;
                 if (true === $plugin['required']) {
                     $message['notice_can_install_required'][] = $slug;
                 } else {
                     $message['notice_can_install_recommended'][] = $slug;
                 }
             } else {
                 // Need higher privileges to install the plugin.
                 $message['notice_cannot_install'][] = $slug;
             }
         } else {
             if (!$this->is_plugin_active($slug) && $this->can_plugin_activate($slug)) {
                 if (current_user_can('activate_plugins')) {
                     $activate_link_count++;
                     if (true === $plugin['required']) {
                         $message['notice_can_activate_required'][] = $slug;
                     } else {
                         $message['notice_can_activate_recommended'][] = $slug;
                     }
                 } else {
                     // Need higher privileges to activate the plugin.
                     $message['notice_cannot_activate'][] = $slug;
                 }
             }
             if ($this->does_plugin_require_update($slug) || false !== $this->does_plugin_have_update($slug)) {
                 if (current_user_can('install_plugins')) {
                     $update_link_count++;
                     if ($this->does_plugin_require_update($slug)) {
                         $message['notice_ask_to_update'][] = $slug;
                     } elseif (false !== $this->does_plugin_have_update($slug)) {
                         $message['notice_ask_to_update_maybe'][] = $slug;
                     }
                 } else {
                     // Need higher privileges to update the plugin.
                     $message['notice_cannot_update'][] = $slug;
                 }
             }
         }
     }
     unset($slug, $plugin);
     // If we have notices to display, we move forward.
     if (!empty($message)) {
         krsort($message);
         // Sort messages.
         $rendered = '';
         // As add_settings_error() wraps the final message in a <p> and as the final message can't be
         // filtered, using <p>'s in our html would render invalid html output.
         $line_template = '<span style="display: block; margin: 0.5em 0.5em 0 0; clear: both;">%s</span>' . "\n";
         // If dismissable is false and a message is set, output it now.
         if (!$this->dismissable && !empty($this->dismiss_msg)) {
             $rendered .= sprintf($line_template, wp_kses_post($this->dismiss_msg));
         }
         // Render the individual message lines for the notice.
         foreach ($message as $type => $plugin_group) {
             $linked_plugins = array();
             // Get the external info link for a plugin if one is available.
             foreach ($plugin_group as $plugin_slug) {
                 $linked_plugins[] = $this->get_info_link($plugin_slug);
             }
             unset($plugin_slug);
             $count = count($plugin_group);
             $linked_plugins = array_map(array('TGMPA_Utils', 'wrap_in_em'), $linked_plugins);
             $last_plugin = array_pop($linked_plugins);
             // Pop off last name to prep for readability.
             $imploded = empty($linked_plugins) ? $last_plugin : implode(', ', $linked_plugins) . ' ' . esc_html_x('and', 'plugin A *and* plugin B', 'tgmpa') . ' ' . $last_plugin;
             $rendered .= sprintf($line_template, sprintf(translate_nooped_plural($this->strings[$type], $count, 'tgmpa'), $imploded, $count));
             if (0 === strpos($type, 'notice_cannot')) {
                 $rendered .= $this->strings['contact_admin'];
             }
         }
         unset($type, $plugin_group, $linked_plugins, $count, $last_plugin, $imploded);
         // Setup action links.
         $action_links = array('install' => '', 'update' => '', 'activate' => '', 'dismiss' => $this->dismissable ? '<a href="' . esc_url(add_query_arg('tgmpa-dismiss', 'dismiss_admin_notices')) . '" class="dismiss-notice" target="_parent">' . esc_html($this->strings['dismiss']) . '</a>' : '');
         $link_template = '<a href="%2$s">%1$s</a>';
         if (current_user_can('install_plugins')) {
             if ($install_link_count > 0) {
                 $action_links['install'] = sprintf($link_template, translate_nooped_plural($this->strings['install_link'], $install_link_count, 'tgmpa'), esc_url($this->get_tgmpa_status_url('install')));
             }
             if ($update_link_count > 0) {
                 $action_links['update'] = sprintf($link_template, translate_nooped_plural($this->strings['update_link'], $update_link_count, 'tgmpa'), esc_url($this->get_tgmpa_status_url('update')));
             }
         }
         if (current_user_can('activate_plugins') && $activate_link_count > 0) {
             $action_links['activate'] = sprintf($link_template, translate_nooped_plural($this->strings['activate_link'], $activate_link_count, 'tgmpa'), esc_url($this->get_tgmpa_status_url('activate')));
         }
         $action_links = apply_filters('tgmpa_notice_action_links', $action_links);
         $action_links = array_filter((array) $action_links);
         // Remove any empty array items.
         if (!empty($action_links) && is_array($action_links)) {
             $action_links = sprintf($line_template, implode(' | ', $action_links));
             $rendered .= apply_filters('tgmpa_notice_rendered_action_links', $action_links);
         }
         // Register the nag messages and prepare them to be processed.
         if (!empty($this->strings['nag_type'])) {
             add_settings_error('tgmpa', 'tgmpa', $rendered, sanitize_html_class(strtolower($this->strings['nag_type'])));
         } else {
             $nag_class = version_compare($this->wp_version, '3.8', '<') ? 'updated' : 'update-nag';
             add_settings_error('tgmpa', 'tgmpa', $rendered, $nag_class);
         }
     }
     // Admin options pages already output settings_errors, so this is to avoid duplication.
     if ('options-general' !== $GLOBALS['current_screen']->parent_base) {
         $this->display_settings_errors();
     }
 }
コード例 #30
0
 /**
  * Generate the user action links for the admin notice.
  *
  * @since 2.6.0
  *
  * @param int $install_count  Number of plugins to install.
  * @param int $update_count   Number of plugins to update.
  * @param int $activate_count Number of plugins to activate.
  * @param int $line_template  Template for the HTML tag to output a line.
  * @return string Action links.
  */
 protected function create_user_action_links_for_notice($install_count, $update_count, $activate_count, $line_template)
 {
     // Setup action links.
     $action_links = array('install' => '', 'update' => '', 'activate' => '', 'dismiss' => $this->dismissable ? '<a href="' . esc_url(wp_nonce_url(add_query_arg('tgmpa-dismiss', 'dismiss_admin_notices'), 'tgmpa-dismiss-' . get_current_user_id())) . '" class="dismiss-notice" target="_parent">' . esc_html($this->strings['dismiss']) . '</a>' : '');
     $link_template = '<a href="%2$s">%1$s</a>';
     if (current_user_can('install_plugins')) {
         if ($install_count > 0) {
             $action_links['install'] = sprintf($link_template, translate_nooped_plural($this->strings['install_link'], $install_count, 'vantage'), esc_url($this->get_tgmpa_status_url('install')));
         }
         if ($update_count > 0) {
             $action_links['update'] = sprintf($link_template, translate_nooped_plural($this->strings['update_link'], $update_count, 'vantage'), esc_url($this->get_tgmpa_status_url('update')));
         }
     }
     if (current_user_can('activate_plugins') && $activate_count > 0) {
         $action_links['activate'] = sprintf($link_template, translate_nooped_plural($this->strings['activate_link'], $activate_count, 'vantage'), esc_url($this->get_tgmpa_status_url('activate')));
     }
     $action_links = apply_filters('tgmpa_notice_action_links', $action_links);
     $action_links = array_filter((array) $action_links);
     // Remove any empty array items.
     if (!empty($action_links)) {
         $action_links = sprintf($line_template, implode(' | ', $action_links));
         return apply_filters('tgmpa_notice_rendered_action_links', $action_links);
     } else {
         return '';
     }
 }