Permalink
Browse files

Mine attachment count added.

  • Loading branch information...
1 parent 2fcfd5e commit ef2469423a3023a28f395efcb9ce47898ffebb1f @samikeijonen committed Sep 9, 2012
Binary file not shown.
@@ -2,16 +2,16 @@ msgid ""
msgstr ""
"Project-Id-Version: Media Filter Plugin v0.1\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2012-09-09 12:44+0200\n"
-"PO-Revision-Date: 2012-09-09 12:44+0200\n"
+"POT-Creation-Date: 2012-09-09 15:23+0200\n"
+"PO-Revision-Date: 2012-09-09 15:23+0200\n"
"Last-Translator: Sami Keijonen <sami.keijonen@foxnet.fi>\n"
"Language-Team: Foxnet <sami.keijonen@foxnet.fi>\n"
"Language: en_EN\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Poedit-KeywordsList: _;gettext;gettext_noop;__;_e;_x;esc_attr__;esc_attr_e;"
-"esc_html__;esc_html_e;_n;_x:1,2c;_n_noop:1,2\n"
+"esc_html__;esc_html_e;_n;_x:1,2c;_n_noop:1,2;_n:1,2\n"
"X-Poedit-Basepath: ../\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Poedit-SearchPath-0: .\n"
@@ -62,6 +62,9 @@ msgid_plural "ZIPs <span class=\"count\">(%s)</span>"
msgstr[0] ""
msgstr[1] ""
-#: media-filter.php:186
-msgid "Mine"
-msgstr ""
+#: media-filter.php:197
+#, php-format
+msgid "Mine <span class=\"count\">(%s)</span>"
+msgid_plural "Mine <span class=\"count\">(%s)</span>"
+msgstr[0] ""
+msgstr[1] ""
Binary file not shown.
@@ -2,16 +2,16 @@ msgid ""
msgstr ""
"Project-Id-Version: Media Filter Plugin v0.1\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2012-09-09 12:44+0200\n"
-"PO-Revision-Date: 2012-09-09 12:44+0200\n"
+"POT-Creation-Date: 2012-09-09 15:23+0200\n"
+"PO-Revision-Date: 2012-09-09 15:23+0200\n"
"Last-Translator: Sami Keijonen <sami.keijonen@foxnet.fi>\n"
"Language-Team: Foxnet <sami.keijonen@foxnet.fi>\n"
"Language: fi\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Poedit-KeywordsList: _;gettext;gettext_noop;__;_e;_x;esc_attr__;esc_attr_e;"
-"esc_html__;esc_html_e;_n;_x:1,2c;_n_noop:1,2\n"
+"esc_html__;esc_html_e;_n;_x:1,2c;_n_noop:1,2;_n:1,2\n"
"X-Poedit-Basepath: ../\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Poedit-SourceCharset: UTF-8\n"
@@ -63,9 +63,17 @@ msgid_plural "ZIPs <span class=\"count\">(%s)</span>"
msgstr[0] "ZIP <span class=\"count\">(%s)</span>"
msgstr[1] "ZIP:t <span class=\"count\">(%s)</span>"
-#: media-filter.php:186
-msgid "Mine"
-msgstr "Omat"
+#: media-filter.php:197
+#, php-format
+msgid "Mine <span class=\"count\">(%s)</span>"
+msgid_plural "Mine <span class=\"count\">(%s)</span>"
+msgstr[0] "Oma <span class=\"count\">(%s)</span>"
+msgstr[1] "Omat <span class=\"count\">(%s)</span>"
+
+#~ msgid "Mine"
+#~ msgid_plural "Mine"
+#~ msgstr[0] "Oma"
+#~ msgstr[1] "Omat"
#~ msgid "PDF"
#~ msgstr "PDF"
View
@@ -166,8 +166,6 @@ function media_filter_post_mime_types( $post_mime_types ) {
* @since 0.1.0
*/
function media_filter_upload_views_filterable( $views ) {
-
- //$class = ( isset( $_GET['author'] ) && $_GET['author'] == get_current_user_id() ) ? ' class="current"' : '';
if ( isset( $_GET['author'] ) && $_GET['author'] == get_current_user_id() ) {
@@ -181,11 +179,25 @@ function media_filter_upload_views_filterable( $views ) {
else {
$class = '';
}
+
+ /* Get current user attachment count. @link: http://codex.wordpress.org/Class_Reference/wpdb */
+ global $wpdb, $current_user;
+ $media_filter_count_mine_attachment = $wpdb->get_var( $wpdb->prepare(
+ "
+ SELECT COUNT(*)
+ FROM $wpdb->posts
+ WHERE post_type = 'attachment'
+ AND post_author = $current_user->ID
+ AND post_status != 'trash'
+ "
+ ) );
$new_views = array(
- 'mine-media' => sprintf( '<a %s href="%s">%s</a>', $class, esc_url( add_query_arg( 'author', get_current_user_id(), 'upload.php' ) ), __( 'Mine', 'media-filter' ) )
+ //'mine-media' => sprintf( '<a %s href="%s">%s</a>', $class, esc_url( add_query_arg( 'author', get_current_user_id(), 'upload.php' ) ), _n( 'Mine <span class="count">(%d)</span>', 'Mine <span class="count">(%d)</span>', $media_filter_count_mine_attachment, 'media-filter' ), number_format_i18n( $media_filter_count_mine_attachment ) )
+ 'media-filter-mine' => sprintf( '<a %s href="%s">%s</a>', $class, esc_url( add_query_arg( 'author', get_current_user_id(), 'upload.php' ) ), sprintf( _n( 'Mine <span class="count">(%s)</span>', 'Mine <span class="count">(%s)</span>', $media_filter_count_mine_attachment, 'media-filter' ), number_format_i18n( $media_filter_count_mine_attachment ) ) )
);
-
+
+ /* Return $views so that 'Mine' attachments are first. */
return array_merge( $new_views, $views );
}

0 comments on commit ef24694

Please sign in to comment.