diff --git a/src/wp-admin/includes/class-walker-category-checklist.php b/src/wp-admin/includes/class-walker-category-checklist.php new file mode 100644 index 0000000000..00611117d3 --- /dev/null +++ b/src/wp-admin/includes/class-walker-category-checklist.php @@ -0,0 +1,124 @@ + 'parent', 'id' => 'term_id'); //TODO: decouple this + + /** + * Starts the list before the elements are added. + * + * @see Walker:start_lvl() + * + * @since 2.5.1 + * + * @param string $output Passed by reference. Used to append additional content. + * @param int $depth Depth of category. Used for tab indentation. + * @param array $args An array of arguments. @see wp_terms_checklist() + */ + public function start_lvl( &$output, $depth = 0, $args = array() ) { + $indent = str_repeat("\t", $depth); + $output .= "$indent
| + | + |
|---|
+
| + | + |
|---|---|
| + + + + + + + + | ++ |
|
+
+ 'newmeta-submit', 'data-wp-lists' => 'add:the-list:newmeta' ) ); ?>
+
+
+ | |
+ + +
+$template"; + } +} + +/** + * Print out option HTML elements for the page parents drop-down. + * + * @since 1.5.0 + * @since 4.4.0 `$post` argument was added. + * + * @global wpdb $wpdb + * + * @param int $default Optional. The default page ID to be pre-selected. Default 0. + * @param int $parent Optional. The parent page ID. Default 0. + * @param int $level Optional. Page depth level. Default 0. + * @param int|WP_Post $post Post ID or WP_Post object. + * + * @return null|false Boolean False if page has no children, otherwise print out html elements + */ +function parent_dropdown( $default = 0, $parent = 0, $level = 0, $post = null ) { + global $wpdb; + $post = get_post( $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 ( $post && $post->ID && $item->ID == $post->ID ) + continue; + + $pad = str_repeat( ' ', $level * 3 ); + $selected = selected( $default, $item->ID, false ); + + echo "\n\t"; + parent_dropdown( $default, $item->ID, $level +1 ); + } + } else { + return false; + } +} + +/** + * Print out option html elements for role selectors. + * + * @since 2.1.0 + * + * @param string $selected Slug for the role that should be already selected. + */ +function wp_dropdown_roles( $selected = '' ) { + $p = ''; + $r = ''; + + $editable_roles = array_reverse( get_editable_roles() ); + + foreach ( $editable_roles as $role => $details ) { + $name = translate_user_role($details['name'] ); + if ( $selected == $role ) // preselect specified role + $p = "\n\t"; + else + $r .= "\n\t"; + } + echo $p . $r; +} + +/** + * Outputs the form used by the importers to accept the data to be imported + * + * @since 2.0.0 + * + * @param string $action The action attribute for the form. + */ +function wp_import_upload_form( $action ) { + + /** + * Filter the maximum allowed upload size for import files. + * + * @since 2.3.0 + * + * @see wp_max_upload_size() + * + * @param int $max_upload_size Allowed upload size. Default 1 MB. + */ + $bytes = apply_filters( 'import_upload_size_limit', wp_max_upload_size() ); + $size = size_format( $bytes ); + $upload_dir = wp_upload_dir(); + if ( ! empty( $upload_dir['error'] ) ) : + ?>