Eliminate some of our last remaining `create_function()` instances
* Moved some into private function callbacks * Eliminated some that weren't necessary anymore props obenland, markjaquith, nacin. fixes #14424 Built from https://develop.svn.wordpress.org/trunk@27373 git-svn-id: http://core.svn.wordpress.org/trunk@27222 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
420afb81de
commit
fb56a9942b
|
@ -74,7 +74,7 @@ foreach ( $popular_importers as $pop_importer => $pop_data ) {
|
|||
if ( empty( $importers ) ) {
|
||||
echo '<p>' . __('No importers are available.') . '</p>'; // TODO: make more helpful
|
||||
} else {
|
||||
uasort($importers, create_function('$a, $b', 'return strnatcasecmp($a[0], $b[0]);'));
|
||||
uasort( $importers, '_uasort_by_first_member' );
|
||||
?>
|
||||
<table class="widefat importers">
|
||||
|
||||
|
|
|
@ -15,11 +15,28 @@
|
|||
*/
|
||||
function get_importers() {
|
||||
global $wp_importers;
|
||||
if ( is_array($wp_importers) )
|
||||
uasort($wp_importers, create_function('$a, $b', 'return strcmp($a[0], $b[0]);'));
|
||||
if ( is_array( $wp_importers ) ) {
|
||||
uasort( $wp_importers, '_uasort_by_first_member' );
|
||||
}
|
||||
return $wp_importers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts a multidimensional array by first member of each top level member
|
||||
*
|
||||
* Used by uasort() as a callback, should not be used directly.
|
||||
*
|
||||
* @since 2.9.0
|
||||
* @access private
|
||||
*
|
||||
* @param array $a
|
||||
* @param array $b
|
||||
* @return int
|
||||
*/
|
||||
function _uasort_by_first_member( $a, $b ) {
|
||||
return strnatcasecmp( $a[0], $b[0] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Register importer for WordPress.
|
||||
*
|
||||
|
|
|
@ -2255,15 +2255,18 @@ function media_upload_library_form($errors) {
|
|||
if ( get_user_setting('uploader') )
|
||||
$form_class .= ' html-uploader';
|
||||
|
||||
$_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';" ) );
|
||||
$q = $_GET;
|
||||
$q['posts_per_page'] = 10;
|
||||
$q = 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();
|
||||
list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query( $q );
|
||||
|
||||
?>
|
||||
|
||||
|
|
|
@ -934,21 +934,13 @@ function wp_edit_attachments_query( $q = false ) {
|
|||
unset($q['post_mime_type']);
|
||||
|
||||
if ( isset($q['detached']) )
|
||||
add_filter('posts_where', '_edit_attachments_query_helper');
|
||||
$q['post_parent'] = 0;
|
||||
|
||||
wp( $q );
|
||||
|
||||
if ( isset($q['detached']) )
|
||||
remove_filter('posts_where', '_edit_attachments_query_helper');
|
||||
|
||||
return array($post_mime_types, $avail_post_mime_types);
|
||||
}
|
||||
|
||||
function _edit_attachments_query_helper($where) {
|
||||
global $wpdb;
|
||||
return $where .= " AND {$wpdb->posts}.post_parent < 1";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of classes to be used by a metabox
|
||||
*
|
||||
|
|
|
@ -622,10 +622,7 @@ function wp_generate_tag_cloud( $tags, $args = '' ) {
|
|||
);
|
||||
|
||||
if ( !isset( $args['topic_count_text_callback'] ) && isset( $args['single_text'] ) && isset( $args['multiple_text'] ) ) {
|
||||
$body = 'return sprintf (
|
||||
_n(' . var_export($args['single_text'], true) . ', ' . var_export($args['multiple_text'], true) . ', $count),
|
||||
number_format_i18n( $count ));';
|
||||
$args['topic_count_text_callback'] = create_function('$count', $body);
|
||||
$args['topic_count_text_callback'] = '_plugin_topic_count';
|
||||
}
|
||||
|
||||
$args = wp_parse_args( $args, $defaults );
|
||||
|
@ -725,6 +722,21 @@ function _wp_object_count_sort_cb( $a, $b ) {
|
|||
return ( $a->count > $b->count );
|
||||
}
|
||||
|
||||
/**
|
||||
* Default text for tooltip for tag links
|
||||
*
|
||||
* @since 3.9.0
|
||||
* @access private
|
||||
*
|
||||
* @param integer $count Number of posts with that tag.
|
||||
* @param object $tag Tag object.
|
||||
* @param array $args Arguments for the tag cloud.
|
||||
* @return string Text for the tooltip of a tag link.
|
||||
*/
|
||||
function _plugin_topic_count( $count, $tag, $args ) {
|
||||
return sprintf( 1 == $count? $args['single_text'] : $args['multiple_text'], number_format_i18n( $count ) );
|
||||
}
|
||||
|
||||
//
|
||||
// Helper functions
|
||||
//
|
||||
|
|
Loading…
Reference in New Issue