X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/8f374b7233bc2815ccc387e448d208c5434eb961..a6f44f0edcda2471c5a33e4156c1c9488c7f3210:/wp-admin/includes/template.php diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index 38348745..18349644 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -34,7 +34,7 @@ class Walker_Category_Checklist extends Walker { $output .= "$indent\n"; } - function start_el( &$output, $category, $depth, $args, $id = 0 ) { + function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) { extract($args); if ( empty($taxonomy) ) $taxonomy = 'category'; @@ -166,20 +166,16 @@ function wp_terms_checklist($post_id = 0, $args = array()) { * @return array List of popular term IDs. */ function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10, $echo = true ) { - global $post_ID; + $post = get_post(); - if ( $post_ID ) - $checked_terms = wp_get_object_terms($post_ID, $taxonomy, array('fields'=>'ids')); + if ( $post && $post->ID ) + $checked_terms = wp_get_object_terms($post->ID, $taxonomy, array('fields'=>'ids')); else $checked_terms = array(); $terms = get_terms( $taxonomy, array( 'orderby' => 'count', 'order' => 'DESC', 'number' => $number, 'hierarchical' => false ) ); $tax = get_taxonomy($taxonomy); - if ( ! current_user_can($tax->cap->assign_terms) ) - $disabled = 'disabled="disabled"'; - else - $disabled = ''; $popular_ids = array(); foreach ( (array) $terms as $term ) { @@ -192,7 +188,7 @@ function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10, $ech @@ -244,7 +240,7 @@ function wp_link_category_checklist( $link_id = 0 ) { */ function get_inline_data($post) { $post_type_object = get_post_type_object($post->post_type); - if ( ! current_user_can($post_type_object->cap->edit_post, $post->ID) ) + if ( ! current_user_can( 'edit_post', $post->ID ) ) return; $title = esc_textarea( trim( $post->post_title ) ); @@ -332,35 +328,35 @@ function wp_comment_reply($position = '1', $checkbox = false, $mode = 'single',
'strong,em,link,block,del,ins,img,ul,ol,li,code,spell,close' ); - wp_editor( '', 'replycontent', array( 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings, 'tabindex' => 104 ) ); + $quicktags_settings = array( 'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close' ); + wp_editor( '', 'replycontent', array( 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings ) ); ?>

- - + - + +

@@ -421,7 +417,7 @@ function list_meta( $meta ) { ' . __( 'Value' ) . ' - + '; //TBODY needed for list-manipulation JS @@ -436,7 +432,7 @@ function list_meta( $meta ) { - + "; - $r .= "\n\t\t"; + $r .= "\n\t\t"; $r .= "\n\t\t
"; - $r .= get_submit_button( __( 'Delete' ), "delete:the-list:meta-{$entry['meta_id']}::_ajax_nonce=$delete_nonce deletemeta", "deletemeta[{$entry['meta_id']}]", false, array( 'tabindex' => '6' ) ); + $r .= get_submit_button( __( 'Delete' ), 'deletemeta small', "deletemeta[{$entry['meta_id']}]", false, array( 'data-wp-lists' => "delete:the-list:meta-{$entry['meta_id']}::_ajax_nonce=$delete_nonce" ) ); $r .= "\n\t\t"; - $r .= get_submit_button( __( 'Update' ), "add:the-list:meta-{$entry['meta_id']}::_ajax_nonce-add-meta=$update_nonce updatemeta" , 'updatemeta', false, array( 'tabindex' => '6' ) ); + $r .= get_submit_button( __( 'Update' ), 'updatemeta small', "meta-{$entry['meta_id']}-submit", false, array( 'data-wp-lists' => "add:the-list:meta-{$entry['meta_id']}::_ajax_nonce-add-meta=$update_nonce" ) ); $r .= "
"; $r .= wp_nonce_field( 'change-meta', '_ajax_nonce', false, false ); $r .= ""; - $r .= "\n\t\t\n\t"; + $r .= "\n\t\t\n\t"; return $r; } @@ -534,28 +530,32 @@ function meta_form() { - " . esc_html($key) . ""; } ?> - + - + - + - - 'addmetasub', 'tabindex' => '9' ) ); ?> + +
+ 'newmeta-submit', 'data-wp-lists' => 'add:the-list:newmeta' ) ); ?> +
@@ -575,7 +575,8 @@ function meta_form() { * @param unknown_type $multi */ function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) { - global $wp_locale, $post, $comment; + global $wp_locale, $comment; + $post = get_post(); if ( $for_post ) $edit = ! ( in_array($post->post_status, array('draft', 'pending') ) && (!$post->post_date_gmt || '0000-00-00 00:00:00' == $post->post_date_gmt ) ); @@ -618,8 +619,8 @@ function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) { $minute = ''; echo '
'; - /* translators: 1: month input, 2: day input, 3: year input, 4: hour input, 5: minute input */ - printf(__('%1$s%2$s, %3$s @ %4$s : %5$s'), $month, $day, $year, $hour, $minute); + /* translators: 1: month, 2: day, 3: year, 4: hour, 5: minute */ + printf( __( '%1$s %2$s, %3$s @ %4$s : %5$s' ), $month, $day, $year, $hour, $minute ); echo '
'; @@ -670,17 +671,16 @@ function page_template_dropdown( $default = '' ) { * @return unknown */ function parent_dropdown( $default = 0, $parent = 0, $level = 0 ) { - global $wpdb, $post_ID; + global $wpdb; + $post = get_post(); $items = $wpdb->get_results( $wpdb->prepare("SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' ORDER BY menu_order", $parent) ); if ( $items ) { foreach ( $items as $item ) { // A page cannot be its own parent. - if (!empty ( $post_ID ) ) { - if ( $item->ID == $post_ID ) { - continue; - } - } + if ( $post && $post->ID && $item->ID == $post->ID ) + continue; + $pad = str_repeat( ' ', $level * 3 ); if ( $item->ID == $default) $current = ' selected="selected"'; @@ -705,7 +705,7 @@ function parent_dropdown( $default = 0, $parent = 0, $level = 0 ) { */ function the_attachment_links( $id = false ) { $id = (int) $id; - $post = & get_post( $id ); + $post = get_post( $id ); if ( $post->post_type != 'attachment' ) return false; @@ -769,56 +769,6 @@ function wp_dropdown_roles( $selected = false ) { echo $p . $r; } -/** - * {@internal Missing Short Description}} - * - * @since 2.3.0 - * - * @param unknown_type $size - * @return unknown - */ -function wp_convert_hr_to_bytes( $size ) { - $size = strtolower($size); - $bytes = (int) $size; - if ( strpos($size, 'k') !== false ) - $bytes = intval($size) * 1024; - elseif ( strpos($size, 'm') !== false ) - $bytes = intval($size) * 1024 * 1024; - elseif ( strpos($size, 'g') !== false ) - $bytes = intval($size) * 1024 * 1024 * 1024; - return $bytes; -} - -/** - * {@internal Missing Short Description}} - * - * @since 2.3.0 - * - * @param unknown_type $bytes - * @return unknown - */ -function wp_convert_bytes_to_hr( $bytes ) { - $units = array( 0 => 'B', 1 => 'kB', 2 => 'MB', 3 => 'GB' ); - $log = log( $bytes, 1024 ); - $power = (int) $log; - $size = pow(1024, $log - $power); - return $size . $units[$power]; -} - -/** - * {@internal Missing Short Description}} - * - * @since 2.5.0 - * - * @return unknown - */ -function wp_max_upload_size() { - $u_bytes = wp_convert_hr_to_bytes( ini_get( 'upload_max_filesize' ) ); - $p_bytes = wp_convert_hr_to_bytes( ini_get( 'post_max_size' ) ); - $bytes = apply_filters( 'upload_size_limit', min($u_bytes, $p_bytes), $u_bytes, $p_bytes ); - return $bytes; -} - /** * Outputs the form used by the importers to accept the data to be imported * @@ -828,14 +778,14 @@ function wp_max_upload_size() { */ function wp_import_upload_form( $action ) { $bytes = apply_filters( 'import_upload_size_limit', wp_max_upload_size() ); - $size = wp_convert_bytes_to_hr( $bytes ); + $size = size_format( $bytes ); $upload_dir = wp_upload_dir(); if ( ! empty( $upload_dir['error'] ) ) : ?>

-
+

() @@ -859,6 +809,7 @@ function wp_import_upload_form( $action ) { * @param string|object $screen Optional. The screen on which to show the box (post, page, link). Defaults to current screen. * @param string $context Optional. The context within the page where the boxes should show ('normal', 'advanced'). * @param string $priority Optional. The priority within the context where the boxes should show ('high', 'low'). + * @param array $callback_args Optional. Data that should be set as the "args" property of the box array (which is the second parameter passed to your callback). */ function add_meta_box( $id, $title, $callback, $screen = null, $context = 'advanced', $priority = 'default', $callback_args = null ) { global $wp_meta_boxes; @@ -965,7 +916,6 @@ function do_meta_boxes( $screen, $context, $object ) { if ( false == $box || ! $box['title'] ) continue; $i++; - $style = ''; $hidden_class = in_array($box['id'], $hidden) ? ' hide-if-js' : ''; echo '

' . "\n"; if ( 'dashboard_browser_nag' != $box['id'] ) @@ -1016,6 +966,79 @@ function remove_meta_box($id, $screen, $context) { $wp_meta_boxes[$page][$context][$priority][$id] = false; } +/** + * Meta Box Accordion Template Function + * + * Largely made up of abstracted code from {@link do_meta_boxes()}, this + * function serves to build meta boxes as list items for display as + * a collapsible accordion. + * + * @since 3.6.0 + * + * @uses global $wp_meta_boxes Used to retrieve registered meta boxes. + * + * @param string|object $screen The screen identifier. + * @param string $context The meta box context. + * @param mixed $object gets passed to the section callback function as first parameter. + * @return int number of meta boxes as accordion sections. + */ +function do_accordion_sections( $screen, $context, $object ) { + global $wp_meta_boxes; + + wp_enqueue_script( 'accordion' ); + + if ( empty( $screen ) ) + $screen = get_current_screen(); + elseif ( is_string( $screen ) ) + $screen = convert_to_screen( $screen ); + + $page = $screen->id; + + $hidden = get_hidden_meta_boxes( $screen ); + ?> +
+
    + +
  • +

    +
    +
    + +
    +
    +
  • + +
+
+ {$section['title']}\n"; - call_user_func($section['callback'], $section); - if ( !isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section['id']]) ) + + if ( $section['callback'] ) + call_user_func( $section['callback'], $section ); + + if ( ! isset( $wp_settings_fields ) || !isset( $wp_settings_fields[$page] ) || !isset( $wp_settings_fields[$page][$section['id']] ) ) continue; echo ''; - do_settings_fields($page, $section['id']); + do_settings_fields( $page, $section['id'] ); echo '
'; } } @@ -1148,7 +1184,7 @@ function do_settings_fields($page, $section) { foreach ( (array) $wp_settings_fields[$page][$section] as $field ) { echo ''; if ( !empty($field['args']['label_for']) ) - echo ''; + echo ''; else echo '' . $field['title'] . ''; echo ''; @@ -1224,27 +1260,29 @@ function get_settings_errors( $setting = '', $sanitize = false ) { // This allows the $sanitize_callback from register_setting() to run, adding // any settings errors you want to show by default. if ( $sanitize ) - sanitize_option( $setting, get_option($setting)); + sanitize_option( $setting, get_option( $setting ) ); // If settings were passed back from options.php then use them - // Ignore transients if $sanitize is true, we don't want the old values anyway - if ( isset($_GET['settings-updated']) && $_GET['settings-updated'] && get_transient('settings_errors') ) { - $settings_errors = get_transient('settings_errors'); - delete_transient('settings_errors'); - // Otherwise check global in case validation has been run on this pageload - } elseif ( count( $wp_settings_errors ) ) { - $settings_errors = $wp_settings_errors; - } else { - return; + if ( isset( $_GET['settings-updated'] ) && $_GET['settings-updated'] && get_transient( 'settings_errors' ) ) { + $wp_settings_errors = array_merge( (array) $wp_settings_errors, get_transient( 'settings_errors' ) ); + delete_transient( 'settings_errors' ); } + // Check global in case errors have been added on this pageload + if ( ! count( $wp_settings_errors ) ) + return array(); + // Filter the results to those of a specific setting if one was set if ( $setting ) { - foreach ( (array) $settings_errors as $key => $details ) - if ( $setting != $details['setting'] ) - unset( $settings_errors[$key] ); + $setting_errors = array(); + foreach ( (array) $wp_settings_errors as $key => $details ) { + if ( $setting == $details['setting'] ) + $setting_errors[] = $wp_settings_errors[$key]; + } + return $setting_errors; } - return $settings_errors; + + return $wp_settings_errors; } /** @@ -1276,7 +1314,7 @@ function settings_errors( $setting = '', $sanitize = false, $hide_on_update = fa $settings_errors = get_settings_errors( $setting, $sanitize ); - if ( ! is_array( $settings_errors ) ) + if ( empty( $settings_errors ) ) return; $output = ''; @@ -1311,18 +1349,8 @@ function find_posts_div($found_action = '') { -
- - true), 'objects' ); - foreach ( $post_types as $post ) { - if ( 'attachment' == $post->name ) - continue; - ?> - name, 'post'); ?> /> - - + +
@@ -1344,8 +1372,9 @@ function find_posts_div($found_action = '') { * @since 2.7.0 */ function the_post_password() { - global $post; - if ( isset( $post->post_password ) ) echo esc_attr( $post->post_password ); + $post = get_post(); + if ( isset( $post->post_password ) ) + echo esc_attr( $post->post_password ); } /** @@ -1355,13 +1384,13 @@ function the_post_password() { * returned. * * @since 2.7.0 - * @param int $post_id The post id. If not supplied the global $post is used. + * @param mixed $post Post id or object. If not supplied the global $post is used. * @return string The post title if set */ -function _draft_or_post_title( $post_id = 0 ) { - $title = get_the_title($post_id); - if ( empty($title) ) - $title = __('(no title)'); +function _draft_or_post_title( $post = 0 ) { + $title = get_the_title( $post ); + if ( empty( $title ) ) + $title = __( '(no title)' ); return $title; } @@ -1376,7 +1405,7 @@ function _draft_or_post_title( $post_id = 0 ) { * */ function _admin_search_query() { - echo isset($_REQUEST['s']) ? esc_attr( stripslashes( $_REQUEST['s'] ) ) : ''; + echo isset($_REQUEST['s']) ? esc_attr( wp_unslash( $_REQUEST['s'] ) ) : ''; } /** @@ -1394,6 +1423,7 @@ function iframe_header( $title = '', $limit_styles = false ) { $current_screen = get_current_screen(); + @header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) ); _wp_admin_html_begin(); ?> <?php bloginfo('name') ?> › <?php echo $title ?> — <?php _e('WordPress'); ?> @@ -1404,12 +1434,7 @@ wp_enqueue_style( 'colors' ); //', - 'uid': 'ID; ?>', - 'time':'' - }, - ajaxurl = '', +var ajaxurl = '', pagenow = 'id; ?>', typenow = 'post_type; ?>', adminpage = '', @@ -1430,7 +1455,7 @@ do_action('admin_head'); $admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_locale() ) ) ); ?> - class="wp-admin no-js iframe "> + class="wp-admin wp-core-ui no-js iframe ">