WordPress.org

Make WordPress Core

Changeset 10847


Ignore:
Timestamp:
03/27/2009 10:47:47 PM (13 years ago)
Author:
ryan
Message:

Add per page option to Screen Options for comments, posts, pages, and media.

Location:
trunk/wp-admin
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/admin-ajax.php

    r10774 r10847  
    10241024    die('1');
    10251025    break;
     1026case 'set-screen-option':
     1027    if ( ! $user = wp_get_current_user() )
     1028        die(-1);
     1029    $option = $_POST['option'];
     1030    $value = $_POST['value'];
     1031
     1032    if ( !preg_match( '/^[a-z_-]+$/', $option ) )
     1033        die(-1);
     1034
     1035    $option = str_replace('-', '_', $option);
     1036
     1037    switch ( $option ) {
     1038        case 'edit_per_page':
     1039        case 'edit_pages_per_page':
     1040        case 'edit_comments_per_page':
     1041        case 'upload_per_page':
     1042            $value = (int) $value;
     1043            break;
     1044        default:
     1045            $value = apply_filters('set-screen-option', false, $option, $value);
     1046            if ( false === $value )
     1047                die(-1);
     1048            break;
     1049    }
     1050
     1051    update_usermeta($user->ID, $option, $value);
     1052    die('1');
     1053    break;
    10261054case 'get-permalink':
    10271055    check_ajax_referer( 'getpermalink', 'getpermalinknonce' );
  • trunk/wp-admin/edit-comments.php

    r10810 r10847  
    183183
    184184<?php
    185 $comments_per_page = apply_filters('comments_per_page', 20, $comment_status);
     185$comments_per_page = get_user_option('edit_comments_per_page');
     186if ( empty($comments_per_page) )
     187    $comments_per_page = 20;
     188$comments_per_page = apply_filters('comments_per_page', $comments_per_page, $comment_status);
    186189
    187190if ( isset( $_GET['apage'] ) )
  • trunk/wp-admin/edit-pages.php

    r10774 r10847  
    187187if ( empty($pagenum) )
    188188    $pagenum = 1;
    189 if( ! isset( $per_page ) || $per_page < 0 )
     189$per_page = get_user_option('edit_pages_per_page');
     190if ( empty( $per_page ) || $per_page < 0 )
    190191    $per_page = 20;
    191192
  • trunk/wp-admin/includes/post.php

    r10810 r10847  
    816816    }
    817817
    818     $posts_per_page = apply_filters('edit_posts_per_page', 15);
     818    $posts_per_page = get_user_option('edit_per_page');
     819    if ( empty($posts_per_page) )
     820        $posts_per_page = 15;
     821    $posts_per_page = apply_filters('edit_posts_per_page', $posts_per_page);
    819822
    820823    wp("post_type=post&what_to_show=posts$post_status_q&posts_per_page=$posts_per_page&order=$order&orderby=$orderby");
     
    854857    $q['post_type'] = 'attachment';
    855858    $q['post_status'] = 'any';
    856     $q['posts_per_page'] = 15;
     859    $media_per_page = get_user_option('upload_per_page');
     860    if ( empty($media_per_page) )
     861        $media_per_page = 20;
     862    $q['posts_per_page'] = $media_per_page;
    857863    $post_mime_types = array(   //  array( adj, noun )
    858864                'image' => array(__('Images'), __('Manage Images'), _n_noop('Image <span class="count">(%s)</span>', 'Images <span class="count">(%s)</span>')),
  • trunk/wp-admin/includes/template.php

    r10839 r10847  
    33873387    </div>
    33883388<?php echo screen_layout($screen); ?>
     3389<?php echo screen_options($screen); ?>
    33893390</form>
    33903391</div>
     
    35073508}
    35083509
     3510function screen_options($screen) {
     3511    switch ( $screen ) {
     3512        case 'edit':
     3513            $per_page_label = __('Posts per page:');
     3514            break;
     3515        case 'edit-pages':
     3516            $per_page_label = __('Pages per page:');
     3517            break;
     3518        case 'edit-comments':
     3519            $per_page_label = __('Comments per page:');
     3520            break;
     3521        case 'upload':
     3522            $per_page_label = __('Media items per page:');
     3523            break;
     3524        default:
     3525            return '';
     3526    }
     3527
     3528    $per_page = get_user_option("${screen}_per_page");
     3529    if ( empty($per_page) )
     3530        $per_page = 20;
     3531
     3532    $return = '<h5>' . __('Options') . "</h5>\n";
     3533    $return .= "<div class='screen-options'>\n";
     3534    if ( !empty($per_page_label) )
     3535        $return .=  "<label for='${screen}-per-page'>$per_page_label</label> <input type='text' class='screen-option small-text' name='${screen}_per_page' id='${screen}-per-page' value='$per_page' />\n";
     3536    $return .= "</div>\n";
     3537    return $return;
     3538}
     3539
    35093540function screen_icon($name = '') {
    35103541    global $parent_file, $hook_suffix;
  • trunk/wp-admin/js/common.dev.js

    r10488 r10847  
    114114    }
    115115}
     116
    116117$(document).ready(function(){columns.init();});
     118
     119screenOptions = {
     120    init : function() {
     121        $('.screen-option').change(function() {
     122            var option = $(this).map(function() { return this.id; }).get();
     123            var value = $(this).val();
     124            screenOptions.save_screen_option(option, value);
     125        });
     126    },
     127
     128    save_screen_option : function (option, value) {
     129        $.post(ajaxurl, {
     130            action: 'set-screen-option',
     131            option: option,
     132            value: value,
     133            screenoptionnonce: $('#screenoptionnonce').val(),
     134            page: pagenow
     135        });
     136    }
     137}
     138
     139$(document).ready(function(){screenOptions.init();});
     140
    117141})(jQuery);
    118142
  • trunk/wp-admin/js/common.js

    r10488 r10847  
    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(0<e&&0<c&&e!=c){a.slice(e,c).attr("checked",function(){if(d(this).parents("tr").is(":visible")){return b?"checked":""}return""})}}f=this;return true});d("thead :checkbox, tfoot :checkbox").click(function(i){var j=d(this).attr("checked"),h="undefined"==typeof toggleWithKeyboard?false:toggleWithKeyboard,g=i.shiftKey||h;d(this).parents("form:first").find("table tbody:visible").find(".check-column :checkbox").attr("checked",function(){if(d(this).parents("tr").is(":hidden")){return""}if(g){return d(this).attr("checked")?"":"checked"}else{if(j){return"checked"}}return""});d(this).parents("form:first").find("table thead:visible, table tfoot:visible").find(".check-column :checkbox").attr("checked",function(){if(g){return""}else{if(j){return"checked"}}return""})})});(function(){if("undefined"!=typeof google&&google.gears){return}var a=false;if("undefined"!=typeof GearsFactory){a=new GearsFactory()}else{try{a=new ActiveXObject("Gears.Factory");if(factory.getBuildInfo().indexOf("ie_mobile")!=-1){a.privateSetGlobalObject(this)}}catch(b){if(("undefined"!=typeof navigator.mimeTypes)&&navigator.mimeTypes["application/x-googlegears"]){a=document.createElement("object");a.style.display="none";a.width=0;a.height=0;a.type="application/x-googlegears";document.documentElement.appendChild(a)}}}if(a&&a.hasPermission){return}jQuery(".turbo-nag").show()})();
     1var 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()});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<e&&0<c&&e!=c){a.slice(e,c).attr("checked",function(){if(d(this).parents("tr").is(":visible")){return b?"checked":""}return""})}}f=this;return true});d("thead :checkbox, tfoot :checkbox").click(function(i){var j=d(this).attr("checked"),h="undefined"==typeof toggleWithKeyboard?false:toggleWithKeyboard,g=i.shiftKey||h;d(this).parents("form:first").find("table tbody:visible").find(".check-column :checkbox").attr("checked",function(){if(d(this).parents("tr").is(":hidden")){return""}if(g){return d(this).attr("checked")?"":"checked"}else{if(j){return"checked"}}return""});d(this).parents("form:first").find("table thead:visible, table tfoot:visible").find(".check-column :checkbox").attr("checked",function(){if(g){return""}else{if(j){return"checked"}}return""})})});(function(){if("undefined"!=typeof google&&google.gears){return}var a=false;if("undefined"!=typeof GearsFactory){a=new GearsFactory()}else{try{a=new ActiveXObject("Gears.Factory");if(factory.getBuildInfo().indexOf("ie_mobile")!=-1){a.privateSetGlobalObject(this)}}catch(b){if(("undefined"!=typeof navigator.mimeTypes)&&navigator.mimeTypes["application/x-googlegears"]){a=document.createElement("object");a.style.display="none";a.width=0;a.height=0;a.type="application/x-googlegears";document.documentElement.appendChild(a)}}}if(a&&a.hasPermission){return}jQuery(".turbo-nag").show()})();
Note: See TracChangeset for help on using the changeset viewer.