diff --git a/wp-admin/admin-ajax.php b/wp-admin/admin-ajax.php
index e8dcbbbc9f..6d30aad32d 100644
--- a/wp-admin/admin-ajax.php
+++ b/wp-admin/admin-ajax.php
@@ -1021,6 +1021,34 @@ case 'meta-box-order':
if ( $page_columns )
update_usermeta($user->ID, "screen_layout_$page", $page_columns);
+ die('1');
+ break;
+case 'set-screen-option':
+ if ( ! $user = wp_get_current_user() )
+ die(-1);
+ $option = $_POST['option'];
+ $value = $_POST['value'];
+
+ if ( !preg_match( '/^[a-z_-]+$/', $option ) )
+ die(-1);
+
+ $option = str_replace('-', '_', $option);
+
+ switch ( $option ) {
+ case 'edit_per_page':
+ case 'edit_pages_per_page':
+ case 'edit_comments_per_page':
+ case 'upload_per_page':
+ $value = (int) $value;
+ break;
+ default:
+ $value = apply_filters('set-screen-option', false, $option, $value);
+ if ( false === $value )
+ die(-1);
+ break;
+ }
+
+ update_usermeta($user->ID, $option, $value);
die('1');
break;
case 'get-permalink':
diff --git a/wp-admin/edit-comments.php b/wp-admin/edit-comments.php
index a8867315da..186a6e5a7f 100644
--- a/wp-admin/edit-comments.php
+++ b/wp-admin/edit-comments.php
@@ -182,7 +182,10 @@ unset($status_links);
post_count / $per_page);
diff --git a/wp-admin/includes/post.php b/wp-admin/includes/post.php
index 195f26eaaf..7f8b23c2d2 100644
--- a/wp-admin/includes/post.php
+++ b/wp-admin/includes/post.php
@@ -815,7 +815,10 @@ function wp_edit_posts_query( $q = false ) {
$orderby = 'date';
}
- $posts_per_page = apply_filters('edit_posts_per_page', 15);
+ $posts_per_page = get_user_option('edit_per_page');
+ if ( empty($posts_per_page) )
+ $posts_per_page = 15;
+ $posts_per_page = apply_filters('edit_posts_per_page', $posts_per_page);
wp("post_type=post&what_to_show=posts$post_status_q&posts_per_page=$posts_per_page&order=$order&orderby=$orderby");
@@ -853,7 +856,10 @@ function wp_edit_attachments_query( $q = false ) {
$q['cat'] = isset( $q['cat'] ) ? (int) $q['cat'] : 0;
$q['post_type'] = 'attachment';
$q['post_status'] = 'any';
- $q['posts_per_page'] = 15;
+ $media_per_page = get_user_option('upload_per_page');
+ if ( empty($media_per_page) )
+ $media_per_page = 20;
+ $q['posts_per_page'] = $media_per_page;
$post_mime_types = array( // array( adj, noun )
'image' => array(__('Images'), __('Manage Images'), _n_noop('Image (%s)', 'Images (%s)')),
'audio' => array(__('Audio'), __('Manage Audio'), _n_noop('Audio (%s)', 'Audio (%s)')),
diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php
index af5e2ba001..7432dcc693 100644
--- a/wp-admin/includes/template.php
+++ b/wp-admin/includes/template.php
@@ -3386,6 +3386,7 @@ function screen_meta($screen) {
+
@@ -3506,6 +3507,36 @@ function screen_layout($screen) {
return $return;
}
+function screen_options($screen) {
+ switch ( $screen ) {
+ case 'edit':
+ $per_page_label = __('Posts per page:');
+ break;
+ case 'edit-pages':
+ $per_page_label = __('Pages per page:');
+ break;
+ case 'edit-comments':
+ $per_page_label = __('Comments per page:');
+ break;
+ case 'upload':
+ $per_page_label = __('Media items per page:');
+ break;
+ default:
+ return '';
+ }
+
+ $per_page = get_user_option("${screen}_per_page");
+ if ( empty($per_page) )
+ $per_page = 20;
+
+ $return = '' . __('Options') . "
\n";
+ $return .= "\n";
+ if ( !empty($per_page_label) )
+ $return .= " \n";
+ $return .= "
\n";
+ return $return;
+}
+
function screen_icon($name = '') {
global $parent_file, $hook_suffix;
diff --git a/wp-admin/js/common.dev.js b/wp-admin/js/common.dev.js
index 5fe06273b1..3b55cbbff4 100644
--- a/wp-admin/js/common.dev.js
+++ b/wp-admin/js/common.dev.js
@@ -113,7 +113,31 @@ columns = {
});
}
}
+
$(document).ready(function(){columns.init();});
+
+screenOptions = {
+ init : function() {
+ $('.screen-option').change(function() {
+ var option = $(this).map(function() { return this.id; }).get();
+ var value = $(this).val();
+ screenOptions.save_screen_option(option, value);
+ });
+ },
+
+ save_screen_option : function (option, value) {
+ $.post(ajaxurl, {
+ action: 'set-screen-option',
+ option: option,
+ value: value,
+ screenoptionnonce: $('#screenoptionnonce').val(),
+ page: pagenow
+ });
+ }
+}
+
+$(document).ready(function(){screenOptions.init();});
+
})(jQuery);
// stub for doing better warnings
diff --git a/wp-admin/js/common.js b/wp-admin/js/common.js
index 7fbff9c8c8..3385c83b74 100644
--- a/wp-admin/js/common.js
+++ b/wp-admin/js/common.js
@@ -1 +1 @@
-var showNotice,adminMenu,columns;(function(a){adminMenu={init:function(){a("#adminmenu div.wp-menu-toggle").each(function(){if(a(this).siblings(".wp-submenu").length){a(this).click(function(){adminMenu.toggle(a(this).siblings(".wp-submenu"))})}else{a(this).hide()}});a("#adminmenu li.menu-top .wp-menu-image").click(function(){window.location=a(this).siblings("a.menu-top")[0].href});this.favorites();a(".wp-menu-separator").click(function(){if(a("#wpcontent").hasClass("folded")){adminMenu.fold(1);setUserSetting("mfold","o")}else{adminMenu.fold();setUserSetting("mfold","f")}});if("f"!=getUserSetting("mfold")){this.restoreMenuState()}else{this.fold()}},restoreMenuState:function(){a("#adminmenu li.wp-has-submenu").each(function(c,d){var b=getUserSetting("m"+c);if(a(d).hasClass("wp-has-current-submenu")){return true}if("o"==b){a(d).addClass("wp-menu-open")}else{if("c"==b){a(d).removeClass("wp-menu-open")}}})},toggle:function(b){b.slideToggle(150,function(){b.css("display","")}).parent().toggleClass("wp-menu-open");a("#adminmenu li.wp-has-submenu").each(function(d,f){var c=a(f).hasClass("wp-menu-open")?"o":"c";setUserSetting("m"+d,c)});return false},fold:function(b){if(b){a("#wpcontent").removeClass("folded");a("#adminmenu li.wp-has-submenu").unbind()}else{a("#wpcontent").addClass("folded");a("#adminmenu li.wp-has-submenu").hoverIntent({over:function(i){var c=a(this).find(".wp-submenu"),f=i.clientY,d=a(window).height(),g=c.height(),j;if((f+g+10)>d){j=(f+g+10)-d;c.css({marginTop:"-"+j+"px"})}else{if(c.css("marginTop")){c.css({marginTop:""})}}c.addClass("sub-open")},out:function(){a(this).find(".wp-submenu").removeClass("sub-open").css({marginTop:""})},timeout:220,sensitivity:8,interval:100})}},favorites:function(){a("#favorite-inside").width(a("#favorite-actions").width()-4);a("#favorite-toggle, #favorite-inside").bind("mouseenter",function(){a("#favorite-inside").removeClass("slideUp").addClass("slideDown");setTimeout(function(){if(a("#favorite-inside").hasClass("slideDown")){a("#favorite-inside").slideDown(100);a("#favorite-first").addClass("slide-down")}},200)});a("#favorite-toggle, #favorite-inside").bind("mouseleave",function(){a("#favorite-inside").removeClass("slideDown").addClass("slideUp");setTimeout(function(){if(a("#favorite-inside").hasClass("slideUp")){a("#favorite-inside").slideUp(100,function(){a("#favorite-first").removeClass("slide-down")})}},300)})}};a(document).ready(function(){adminMenu.init()});columns={init:function(){a(".hide-column-tog").click(function(){var c=a(this).val(),b=a(this).attr("checked");if(b){a(".column-"+c).show()}else{a(".column-"+c).hide()}columns.save_manage_columns_state()})},save_manage_columns_state:function(){var b=a(".manage-column").filter(":hidden").map(function(){return this.id}).get().join(",");a.post(ajaxurl,{action:"hidden-columns",hidden:b,hiddencolumnsnonce:a("#hiddencolumnsnonce").val(),page:pagenow})}};a(document).ready(function(){columns.init()})})(jQuery);showNotice={warn:function(){var a=commonL10n.warnDelete||"";if(confirm(a)){return true}return false},note:function(a){alert(a)}};jQuery(document).ready(function(d){var f=false,a,e,c,b;d(".fade").animate({backgroundColor:"#ffffe0"},300).animate({backgroundColor:"#fffbcc"},300).animate({backgroundColor:"#ffffe0"},300).animate({backgroundColor:"#fffbcc"},300);d("div.wrap h2 ~ div.updated, div.wrap h2 ~ div.error").addClass("below-h2");d("div.updated, div.error").not(".below-h2").insertAfter("div.wrap h2:first");d("#doaction, #doaction2").click(function(){if(d('select[name^="action"]').val()=="delete"){return showNotice.warn()}});d("#show-settings-link").click(function(){if(!d("#screen-options-wrap").hasClass("screen-options-open")){d("#contextual-help-link-wrap").addClass("invisible")}d("#screen-options-wrap").slideToggle("fast",function(){if(d(this).hasClass("screen-options-open")){d("#show-settings-link").css({backgroundImage:'url("images/screen-options-right.gif")'});d("#contextual-help-link-wrap").removeClass("invisible");d(this).removeClass("screen-options-open")}else{d("#show-settings-link").css({backgroundImage:'url("images/screen-options-right-up.gif")'});d(this).addClass("screen-options-open")}});return false});d("#contextual-help-link").click(function(){if(!d("#contextual-help-wrap").hasClass("contextual-help-open")){d("#screen-options-link-wrap").addClass("invisible")}d("#contextual-help-wrap").slideToggle("fast",function(){if(d(this).hasClass("contextual-help-open")){d("#contextual-help-link").css({backgroundImage:'url("images/screen-options-right.gif")'});d("#screen-options-link-wrap").removeClass("invisible");d(this).removeClass("contextual-help-open")}else{d("#contextual-help-link").css({backgroundImage:'url("images/screen-options-right-up.gif")'});d(this).addClass("contextual-help-open")}});return false});d("#contextual-help-link-wrap, #screen-options-link-wrap").show();d("table:visible tbody .check-column :checkbox").click(function(g){if("undefined"==g.shiftKey){return true}if(g.shiftKey){if(!f){return true}a=d(f).parents("form:first").find(":checkbox");e=a.index(f);c=a.index(this);b=d(this).attr("checked");if(0d){j=(f+g+10)-d;c.css({marginTop:"-"+j+"px"})}else{if(c.css("marginTop")){c.css({marginTop:""})}}c.addClass("sub-open")},out:function(){a(this).find(".wp-submenu").removeClass("sub-open").css({marginTop:""})},timeout:220,sensitivity:8,interval:100})}},favorites:function(){a("#favorite-inside").width(a("#favorite-actions").width()-4);a("#favorite-toggle, #favorite-inside").bind("mouseenter",function(){a("#favorite-inside").removeClass("slideUp").addClass("slideDown");setTimeout(function(){if(a("#favorite-inside").hasClass("slideDown")){a("#favorite-inside").slideDown(100);a("#favorite-first").addClass("slide-down")}},200)});a("#favorite-toggle, #favorite-inside").bind("mouseleave",function(){a("#favorite-inside").removeClass("slideDown").addClass("slideUp");setTimeout(function(){if(a("#favorite-inside").hasClass("slideUp")){a("#favorite-inside").slideUp(100,function(){a("#favorite-first").removeClass("slide-down")})}},300)})}};a(document).ready(function(){adminMenu.init()});columns={init:function(){a(".hide-column-tog").click(function(){var c=a(this).val(),b=a(this).attr("checked");if(b){a(".column-"+c).show()}else{a(".column-"+c).hide()}columns.save_manage_columns_state()})},save_manage_columns_state:function(){var b=a(".manage-column").filter(":hidden").map(function(){return this.id}).get().join(",");a.post(ajaxurl,{action:"hidden-columns",hidden:b,hiddencolumnsnonce:a("#hiddencolumnsnonce").val(),page:pagenow})}};a(document).ready(function(){columns.init()});screenOptions={init:function(){a(".screen-option").change(function(){var b=a(this).map(function(){return this.id}).get();var c=a(this).val();screenOptions.save_screen_option(b,c)})},save_screen_option:function(b,c){a.post(ajaxurl,{action:"set-screen-option",option:b,value:c,screenoptionnonce:a("#screenoptionnonce").val(),page:pagenow})}};a(document).ready(function(){screenOptions.init()})})(jQuery);showNotice={warn:function(){var a=commonL10n.warnDelete||"";if(confirm(a)){return true}return false},note:function(a){alert(a)}};jQuery(document).ready(function(d){var f=false,a,e,c,b;d(".fade").animate({backgroundColor:"#ffffe0"},300).animate({backgroundColor:"#fffbcc"},300).animate({backgroundColor:"#ffffe0"},300).animate({backgroundColor:"#fffbcc"},300);d("div.wrap h2 ~ div.updated, div.wrap h2 ~ div.error").addClass("below-h2");d("div.updated, div.error").not(".below-h2").insertAfter("div.wrap h2:first");d("#doaction, #doaction2").click(function(){if(d('select[name^="action"]').val()=="delete"){return showNotice.warn()}});d("#show-settings-link").click(function(){if(!d("#screen-options-wrap").hasClass("screen-options-open")){d("#contextual-help-link-wrap").addClass("invisible")}d("#screen-options-wrap").slideToggle("fast",function(){if(d(this).hasClass("screen-options-open")){d("#show-settings-link").css({backgroundImage:'url("images/screen-options-right.gif")'});d("#contextual-help-link-wrap").removeClass("invisible");d(this).removeClass("screen-options-open")}else{d("#show-settings-link").css({backgroundImage:'url("images/screen-options-right-up.gif")'});d(this).addClass("screen-options-open")}});return false});d("#contextual-help-link").click(function(){if(!d("#contextual-help-wrap").hasClass("contextual-help-open")){d("#screen-options-link-wrap").addClass("invisible")}d("#contextual-help-wrap").slideToggle("fast",function(){if(d(this).hasClass("contextual-help-open")){d("#contextual-help-link").css({backgroundImage:'url("images/screen-options-right.gif")'});d("#screen-options-link-wrap").removeClass("invisible");d(this).removeClass("contextual-help-open")}else{d("#contextual-help-link").css({backgroundImage:'url("images/screen-options-right-up.gif")'});d(this).addClass("contextual-help-open")}});return false});d("#contextual-help-link-wrap, #screen-options-link-wrap").show();d("table:visible tbody .check-column :checkbox").click(function(g){if("undefined"==g.shiftKey){return true}if(g.shiftKey){if(!f){return true}a=d(f).parents("form:first").find(":checkbox");e=a.index(f);c=a.index(this);b=d(this).attr("checked");if(0