+</tr>
+
+<?php
+}
+
+/*
+ * displays pages in hierarchical order with paging support
+ */
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $pages
+ * @param unknown_type $pagenum
+ * @param unknown_type $per_page
+ * @return unknown
+ */
+function page_rows($pages, $pagenum = 1, $per_page = 20) {
+ global $wpdb;
+
+ $level = 0;
+
+ if ( ! $pages ) {
+ $pages = get_pages( array('sort_column' => 'menu_order') );
+
+ if ( ! $pages )
+ return false;
+ }
+
+ /*
+ * arrange pages into two parts: top level pages and children_pages
+ * children_pages is two dimensional array, eg.
+ * children_pages[10][] contains all sub-pages whose parent is 10.
+ * It only takes O(N) to arrange this and it takes O(1) for subsequent lookup operations
+ * If searching, ignore hierarchy and treat everything as top level
+ */
+ if ( empty($_GET['s']) ) {
+
+ $top_level_pages = array();
+ $children_pages = array();
+
+ foreach ( $pages as $page ) {
+
+ // catch and repair bad pages
+ if ( $page->post_parent == $page->ID ) {
+ $page->post_parent = 0;
+ $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET post_parent = '0' WHERE ID = %d", $page->ID) );
+ clean_page_cache( $page->ID );
+ }
+
+ if ( 0 == $page->post_parent )
+ $top_level_pages[] = $page;
+ else
+ $children_pages[ $page->post_parent ][] = $page;
+ }
+
+ $pages = &$top_level_pages;
+ }
+
+ $count = 0;
+ $start = ($pagenum - 1) * $per_page;
+ $end = $start + $per_page;
+
+ foreach ( $pages as $page ) {
+ if ( $count >= $end )
+ break;
+
+ if ( $count >= $start )
+ echo "\t" . display_page_row( $page, $level );
+
+ $count++;
+
+ if ( isset($children_pages) )
+ _page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page );
+ }
+
+ // if it is the last pagenum and there are orphaned pages, display them with paging as well
+ if ( isset($children_pages) && $count < $end ){
+ foreach( $children_pages as $orphans ){
+ foreach ( $orphans as $op ) {
+ if ( $count >= $end )
+ break;
+ if ( $count >= $start )
+ echo "\t" . display_page_row( $op, 0 );
+ $count++;
+ }
+ }
+ }
+}
+
+/*
+ * Given a top level page ID, display the nested hierarchy of sub-pages
+ * together with paging support
+ */
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $children_pages
+ * @param unknown_type $count
+ * @param unknown_type $parent
+ * @param unknown_type $level
+ * @param unknown_type $pagenum
+ * @param unknown_type $per_page
+ */
+function _page_rows( &$children_pages, &$count, $parent, $level, $pagenum, $per_page ) {
+
+ if ( ! isset( $children_pages[$parent] ) )
+ return;
+
+ $start = ($pagenum - 1) * $per_page;
+ $end = $start + $per_page;
+
+ foreach ( $children_pages[$parent] as $page ) {
+
+ if ( $count >= $end )
+ break;
+
+ // If the page starts in a subtree, print the parents.
+ if ( $count == $start && $page->post_parent > 0 ) {
+ $my_parents = array();
+ $my_parent = $page->post_parent;
+ while ( $my_parent) {
+ $my_parent = get_post($my_parent);
+ $my_parents[] = $my_parent;
+ if ( !$my_parent->post_parent )
+ break;
+ $my_parent = $my_parent->post_parent;
+ }
+ $num_parents = count($my_parents);
+ while( $my_parent = array_pop($my_parents) ) {
+ echo "\t" . display_page_row( $my_parent, $level - $num_parents );
+ $num_parents--;
+ }
+ }
+
+ if ( $count >= $start )
+ echo "\t" . display_page_row( $page, $level );
+
+ $count++;
+
+ _page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page );
+ }
+
+ unset( $children_pages[$parent] ); //required in order to keep track of orphans
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $user_object
+ * @param unknown_type $style
+ * @param unknown_type $role
+ * @return unknown
+ */
+function user_row( $user_object, $style = '', $role = '' ) {
+ global $wp_roles;
+
+ $current_user = wp_get_current_user();
+
+ if ( !( is_object( $user_object) && is_a( $user_object, 'WP_User' ) ) )
+ $user_object = new WP_User( (int) $user_object );
+ $email = $user_object->user_email;
+ $url = $user_object->user_url;
+ $short_url = str_replace( 'http://', '', $url );
+ $short_url = str_replace( 'www.', '', $short_url );
+ if ('/' == substr( $short_url, -1 ))
+ $short_url = substr( $short_url, 0, -1 );
+ if ( strlen( $short_url ) > 35 )
+ $short_url = substr( $short_url, 0, 32 ).'...';
+ $numposts = get_usernumposts( $user_object->ID );
+ $checkbox = '';
+ // Check if the user for this row is editable
+ if ( current_user_can( 'edit_user', $user_object->ID ) ) {
+ // Set up the user editing link
+ // TODO: make profile/user-edit determination a seperate function
+ if ($current_user->ID == $user_object->ID) {
+ $edit_link = 'profile.php';
+ } else {
+ $edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( esc_url( stripslashes( $_SERVER['REQUEST_URI'] ) ) ), "user-edit.php?user_id=$user_object->ID" ) );
+ }
+ $edit = "<strong><a href=\"$edit_link\">$user_object->user_login</a></strong><br />";
+
+ // Set up the hover actions for this user
+ $actions = array();
+ $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
+ if ( $current_user->ID != $user_object->ID )
+ $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("users.php?action=delete&user=$user_object->ID", 'bulk-users') . "'>" . __('Delete') . "</a>";
+ $actions = apply_filters('user_row_actions', $actions, $user_object);
+ $action_count = count($actions);
+ $i = 0;
+ $edit .= '<div class="row-actions">';
+ foreach ( $actions as $action => $link ) {
+ ++$i;
+ ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
+ $edit .= "<span class='$action'>$link$sep</span>";
+ }
+ $edit .= '</div>';
+
+ // Set up the checkbox (because the user is editable, otherwise its empty)
+ $checkbox = "<input type='checkbox' name='users[]' id='user_{$user_object->ID}' class='$role' value='{$user_object->ID}' />";
+
+ } else {
+ $edit = '<strong>' . $user_object->user_login . '</strong>';
+ }
+ $role_name = isset($wp_roles->role_names[$role]) ? translate_user_role($wp_roles->role_names[$role] ) : __('None');
+ $r = "<tr id='user-$user_object->ID'$style>";
+ $columns = get_column_headers('users');
+ $hidden = get_hidden_columns('users');
+ $avatar = get_avatar( $user_object->ID, 32 );
+ foreach ( $columns as $column_name => $column_display_name ) {
+ $class = "class=\"$column_name column-$column_name\"";
+
+ $style = '';
+ if ( in_array($column_name, $hidden) )
+ $style = ' style="display:none;"';
+
+ $attributes = "$class$style";
+
+ switch ($column_name) {
+ case 'cb':
+ $r .= "<th scope='row' class='check-column'>$checkbox</th>";
+ break;
+ case 'username':
+ $r .= "<td $attributes>$avatar $edit</td>";
+ break;
+ case 'name':
+ $r .= "<td $attributes>$user_object->first_name $user_object->last_name</td>";
+ break;
+ case 'email':
+ $r .= "<td $attributes><a href='mailto:$email' title='" . sprintf( __('e-mail: %s' ), $email ) . "'>$email</a></td>";
+ break;
+ case 'role':
+ $r .= "<td $attributes>$role_name</td>";
+ break;
+ case 'posts':
+ $attributes = 'class="posts column-posts num"' . $style;
+ $r .= "<td $attributes>";
+ if ( $numposts > 0 ) {
+ $r .= "<a href='edit.php?author=$user_object->ID' title='" . __( 'View posts by this author' ) . "' class='edit'>";
+ $r .= $numposts;
+ $r .= '</a>';
+ } else {
+ $r .= 0;
+ }
+ $r .= "</td>";
+ break;
+ default:
+ $r .= "<td $attributes>";
+ $r .= apply_filters('manage_users_custom_column', '', $column_name, $user_object->ID);
+ $r .= "</td>";
+ }
+ }
+ $r .= '</tr>';
+
+ return $r;
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $status
+ * @param unknown_type $s
+ * @param unknown_type $start
+ * @param unknown_type $num
+ * @param unknown_type $post
+ * @param unknown_type $type
+ * @return unknown
+ */
+function _wp_get_comment_list( $status = '', $s = false, $start, $num, $post = 0, $type = '' ) {
+ global $wpdb;
+
+ $start = abs( (int) $start );
+ $num = (int) $num;
+ $post = (int) $post;
+ $count = wp_count_comments();
+ $index = '';
+
+ if ( 'moderated' == $status ) {
+ $approved = "comment_approved = '0'";
+ $total = $count->moderated;
+ } elseif ( 'approved' == $status ) {
+ $approved = "comment_approved = '1'";
+ $total = $count->approved;
+ } elseif ( 'spam' == $status ) {
+ $approved = "comment_approved = 'spam'";
+ $total = $count->spam;
+ } else {
+ $approved = "( comment_approved = '0' OR comment_approved = '1' )";
+ $total = $count->moderated + $count->approved;
+ $index = 'USE INDEX (comment_date_gmt)';
+ }
+
+ if ( $post ) {
+ $total = '';
+ $post = " AND comment_post_ID = '$post'";
+ $orderby = "ORDER BY comment_date_gmt ASC LIMIT $start, $num";
+ } else {
+ $post = '';
+ $orderby = "ORDER BY comment_date_gmt DESC LIMIT $start, $num";
+ }
+
+ if ( 'comment' == $type )
+ $typesql = "AND comment_type = ''";
+ elseif ( 'pingback' == $type )
+ $typesql = "AND comment_type = 'pingback'";
+ elseif ( 'trackback' == $type )
+ $typesql = "AND comment_type = 'trackback'";
+ elseif ( 'pings' == $type )
+ $typesql = "AND ( comment_type = 'pingback' OR comment_type = 'trackback' )";
+ else
+ $typesql = '';
+
+ if ( !empty($type) )
+ $total = '';
+
+ if ( $s ) {
+ $total = '';
+ $s = $wpdb->escape($s);
+ $query = "FROM $wpdb->comments WHERE
+ (comment_author LIKE '%$s%' OR
+ comment_author_email LIKE '%$s%' OR
+ comment_author_url LIKE ('%$s%') OR
+ comment_author_IP LIKE ('%$s%') OR
+ comment_content LIKE ('%$s%') ) AND
+ $approved
+ $typesql";
+ } else {
+ $query = "FROM $wpdb->comments $index WHERE $approved $post $typesql";
+ }
+
+ $comments = $wpdb->get_results("SELECT * $query $orderby");
+ if ( '' === $total )
+ $total = $wpdb->get_var("SELECT COUNT(comment_ID) $query");
+
+ update_comment_cache($comments);
+
+ return array($comments, $total);
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $comment_id
+ * @param unknown_type $mode
+ * @param unknown_type $comment_status
+ * @param unknown_type $checkbox
+ */
+function _wp_comment_row( $comment_id, $mode, $comment_status, $checkbox = true, $from_ajax = false ) {
+ global $comment, $post, $_comment_pending_count;
+ $comment = get_comment( $comment_id );
+ $post = get_post($comment->comment_post_ID);
+ $the_comment_status = wp_get_comment_status($comment->comment_ID);
+ $user_can = current_user_can('edit_post', $post->ID);
+
+ $author_url = get_comment_author_url();
+ if ( 'http://' == $author_url )
+ $author_url = '';
+ $author_url_display = $author_url;
+ $author_url_display = str_replace('http://www.', '', $author_url_display);
+ $author_url_display = str_replace('http://', '', $author_url_display);
+ if ( strlen($author_url_display) > 50 )
+ $author_url_display = substr($author_url_display, 0, 49) . '...';
+
+ $ptime = date('G', strtotime( $comment->comment_date ) );
+ if ( ( abs(time() - $ptime) ) < 86400 )
+ $ptime = sprintf( __('%s ago'), human_time_diff( $ptime ) );
+ else
+ $ptime = mysql2date(__('Y/m/d \a\t g:i A'), $comment->comment_date );
+
+ $delete_url = esc_url( wp_nonce_url( "comment.php?action=deletecomment&p=$post->ID&c=$comment->comment_ID", "delete-comment_$comment->comment_ID" ) );
+ $approve_url = esc_url( wp_nonce_url( "comment.php?action=approvecomment&p=$post->ID&c=$comment->comment_ID", "approve-comment_$comment->comment_ID" ) );
+ $unapprove_url = esc_url( wp_nonce_url( "comment.php?action=unapprovecomment&p=$post->ID&c=$comment->comment_ID", "unapprove-comment_$comment->comment_ID" ) );
+ $spam_url = esc_url( wp_nonce_url( "comment.php?action=deletecomment&dt=spam&p=$post->ID&c=$comment->comment_ID", "delete-comment_$comment->comment_ID" ) );
+
+ echo "<tr id='comment-$comment->comment_ID' class='$the_comment_status'>";
+ $columns = get_column_headers('edit-comments');
+ $hidden = get_hidden_columns('edit-comments');
+ foreach ( $columns as $column_name => $column_display_name ) {
+ $class = "class=\"$column_name column-$column_name\"";
+
+ $style = '';
+ if ( in_array($column_name, $hidden) )
+ $style = ' style="display:none;"';
+
+ $attributes = "$class$style";
+
+ switch ($column_name) {
+ case 'cb':
+ if ( !$checkbox ) break;
+ echo '<th scope="row" class="check-column">';
+ if ( $user_can ) echo "<input type='checkbox' name='delete_comments[]' value='$comment->comment_ID' />";
+ echo '</th>';
+ break;
+ case 'comment':
+ echo "<td $attributes>";
+ echo '<div id="submitted-on">';
+ printf(__('Submitted on <a href="%1$s">%2$s at %3$s</a>'), get_comment_link($comment->comment_ID), get_comment_date(__('Y/m/d')), get_comment_date(__('g:ia')));
+ echo '</div>';
+ comment_text(); ?>
+ <div id="inline-<?php echo $comment->comment_ID; ?>" class="hidden">
+ <textarea class="comment" rows="3" cols="10"><?php echo $comment->comment_content; ?></textarea>
+ <div class="author-email"><?php if ( $user_can ) echo esc_attr( $comment->comment_author_email ); ?></div>
+ <div class="author"><?php if ( $user_can ) echo esc_attr( $comment->comment_author ); ?></div>
+ <div class="author-url"><?php echo esc_attr( $comment->comment_author_url ); ?></div>
+ <div class="comment_status"><?php echo $comment->comment_approved; ?></div>
+ </div>
+ <?php
+ $actions = array();
+
+ if ( $user_can ) {
+ $actions['approve'] = "<a href='$approve_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=approved vim-a' title='" . __( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
+ $actions['unapprove'] = "<a href='$unapprove_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=unapproved vim-u' title='" . __( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
+ if ( $comment_status && 'all' != $comment_status ) { // not looking at all comments
+ if ( 'approved' == $the_comment_status ) {
+ $actions['unapprove'] = "<a href='$unapprove_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&new=unapproved vim-u vim-destructive' title='" . __( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
+ unset($actions['approve']);
+ } else {
+ $actions['approve'] = "<a href='$approve_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&new=approved vim-a vim-destructive' title='" . __( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
+ unset($actions['unapprove']);
+ }
+ }
+ if ( 'spam' != $the_comment_status )
+ $actions['spam'] = "<a href='$spam_url' class='delete:the-comment-list:comment-$comment->comment_ID::spam=1 vim-s vim-destructive' title='" . __( 'Mark this comment as spam' ) . "'>" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . '</a>';
+ $actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID delete vim-d vim-destructive'>" . __('Delete') . '</a>';
+ $actions['edit'] = "<a href='comment.php?action=editcomment&c={$comment->comment_ID}' title='" . __('Edit comment') . "'>". __('Edit') . '</a>';
+ $actions['quickedit'] = '<a onclick="commentReply.open(\''.$comment->comment_ID.'\',\''.$post->ID.'\',\'edit\');return false;" class="vim-q" title="'.__('Quick Edit').'" href="#">' . __('Quick Edit') . '</a>';
+ if ( 'spam' != $the_comment_status )
+ $actions['reply'] = '<a onclick="commentReply.open(\''.$comment->comment_ID.'\',\''.$post->ID.'\');return false;" class="vim-r" title="'.__('Reply to this comment').'" href="#">' . __('Reply') . '</a>';
+
+ $actions = apply_filters( 'comment_row_actions', $actions, $comment );
+
+ $i = 0;
+ echo '<div class="row-actions">';
+ foreach ( $actions as $action => $link ) {
+ ++$i;
+ ( ( ('approve' == $action || 'unapprove' == $action) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | ';
+
+ // Reply and quickedit need a hide-if-no-js span when not added with ajax
+ if ( ('reply' == $action || 'quickedit' == $action) && ! $from_ajax )
+ $action .= ' hide-if-no-js';
+
+ echo "<span class='$action'>$sep$link</span>";
+ }
+ echo '</div>';
+ }
+
+ echo '</td>';
+ break;
+ case 'author':
+ echo "<td $attributes><strong>"; comment_author(); echo '</strong><br />';
+ if ( !empty($author_url) )
+ echo "<a title='$author_url' href='$author_url'>$author_url_display</a><br />";
+ if ( $user_can ) {
+ if ( !empty($comment->comment_author_email) ) {
+ comment_author_email_link();
+ echo '<br />';
+ }
+ echo '<a href="edit-comments.php?s=';
+ comment_author_IP();
+ echo '&mode=detail';
+ if ( 'spam' == $comment_status )
+ echo '&comment_status=spam';
+ echo '">';
+ comment_author_IP();
+ echo '</a>';
+ } //current_user_can
+ echo '</td>';
+ break;
+ case 'date':
+ echo "<td $attributes>" . get_comment_date(__('Y/m/d \a\t g:ia')) . '</td>';
+ break;
+ case 'response':
+ if ( 'single' !== $mode ) {
+ if ( isset( $_comment_pending_count[$post->ID] ) ) {
+ $pending_comments = absint( $_comment_pending_count[$post->ID] );
+ } else {
+ $_comment_pending_count_temp = (array) get_pending_comments_num( array( $post->ID ) );
+ $pending_comments = $_comment_pending_count[$post->ID] = $_comment_pending_count_temp[$post->ID];
+ }
+ if ( $user_can ) {
+ $post_link = "<a href='" . get_edit_post_link($post->ID) . "'>";
+ $post_link .= get_the_title($post->ID) . '</a>';
+ } else {
+ $post_link = get_the_title($post->ID);
+ }
+ echo "<td $attributes>\n";
+ echo '<div class="response-links"><span class="post-com-count-wrapper">';
+ echo $post_link . '<br />';
+ $pending_phrase = sprintf( __('%s pending'), number_format( $pending_comments ) );
+ if ( $pending_comments )
+ echo '<strong>';
+ comments_number("<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link */ _x('0', 'comment count') . '</span></a>', "<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link */ _x('1', 'comment count') . '</span></a>', "<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link: % will be substituted by comment count */ _x('%', 'comment count') . '</span></a>');
+ if ( $pending_comments )
+ echo '</strong>';
+ echo '</span> ';
+ echo "<a href='" . get_permalink( $post->ID ) . "'>#</a>";
+ echo '</div>';
+ if ( 'attachment' == $post->post_type && ( $thumb = wp_get_attachment_image( $post->ID, array(80, 60), true ) ) )
+ echo $thumb;
+ echo '</td>';
+ }
+ break;
+ default:
+ echo "<td $attributes>\n";
+ do_action( 'manage_comments_custom_column', $column_name, $comment->comment_ID );
+ echo "</td>\n";
+ break;
+ }
+ }
+ echo "</tr>\n";
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $position
+ * @param unknown_type $checkbox
+ * @param unknown_type $mode
+ */
+function wp_comment_reply($position = '1', $checkbox = false, $mode = 'single', $table_row = true) {
+ global $current_user;
+
+ // allow plugin to replace the popup content
+ $content = apply_filters( 'wp_comment_reply', '', array('position' => $position, 'checkbox' => $checkbox, 'mode' => $mode) );
+
+ if ( ! empty($content) ) {
+ echo $content;
+ return;
+ }
+
+ $columns = get_column_headers('edit-comments');
+ $hidden = array_intersect( array_keys( $columns ), array_filter( get_hidden_columns('edit-comments') ) );
+ $col_count = count($columns) - count($hidden);
+
+?>
+<form method="get" action="">
+<?php if ( $table_row ) : ?>
+<table style="display:none;"><tbody id="com-reply"><tr id="replyrow"><td colspan="<?php echo $col_count; ?>">
+<?php else : ?>
+<div id="com-reply" style="display:none;"><div id="replyrow">
+<?php endif; ?>
+ <div id="replyhead" style="display:none;"><?php _e('Reply to Comment'); ?></div>
+
+ <div id="edithead" style="display:none;">
+ <div class="inside">
+ <label for="author"><?php _e('Name') ?></label>
+ <input type="text" name="newcomment_author" size="50" value="" tabindex="101" id="author" />
+ </div>
+
+ <div class="inside">
+ <label for="author-email"><?php _e('E-mail') ?></label>
+ <input type="text" name="newcomment_author_email" size="50" value="" tabindex="102" id="author-email" />
+ </div>
+
+ <div class="inside">
+ <label for="author-url"><?php _e('URL') ?></label>
+ <input type="text" id="author-url" name="newcomment_author_url" size="103" value="" tabindex="103" />
+ </div>
+ <div style="clear:both;"></div>
+ </div>
+
+ <div id="replycontainer"><textarea rows="8" cols="40" name="replycontent" tabindex="104" id="replycontent"></textarea></div>
+
+ <p id="replysubmit" class="submit">
+ <a href="#comments-form" class="cancel button-secondary alignleft" tabindex="106"><?php _e('Cancel'); ?></a>
+ <a href="#comments-form" class="save button-primary alignright" tabindex="104">
+ <span id="savebtn" style="display:none;"><?php _e('Update Comment'); ?></span>
+ <span id="replybtn" style="display:none;"><?php _e('Submit Reply'); ?></span></a>
+ <img class="waiting" style="display:none;" src="images/wpspin_light.gif" alt="" />
+ <span class="error" style="display:none;"></span>
+ <br class="clear" />
+ </p>
+
+ <input type="hidden" name="user_ID" id="user_ID" value="<?php echo $current_user->ID; ?>" />
+ <input type="hidden" name="action" id="action" value="" />
+ <input type="hidden" name="comment_ID" id="comment_ID" value="" />
+ <input type="hidden" name="comment_post_ID" id="comment_post_ID" value="" />
+ <input type="hidden" name="status" id="status" value="" />
+ <input type="hidden" name="position" id="position" value="<?php echo $position; ?>" />
+ <input type="hidden" name="checkbox" id="checkbox" value="<?php echo $checkbox ? 1 : 0; ?>" />
+ <input type="hidden" name="mode" id="mode" value="<?php echo esc_attr($mode); ?>" />
+ <?php wp_nonce_field( 'replyto-comment', '_ajax_nonce', false ); ?>
+ <?php wp_comment_form_unfiltered_html_nonce(); ?>
+<?php if ( $table_row ) : ?>
+</td></tr></tbody></table>
+<?php else : ?>
+</div></div>
+<?php endif; ?>
+</form>
+<?php
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $currentcat
+ * @param unknown_type $currentparent
+ * @param unknown_type $parent
+ * @param unknown_type $level
+ * @param unknown_type $categories
+ * @return unknown
+ */
+function wp_dropdown_cats( $currentcat = 0, $currentparent = 0, $parent = 0, $level = 0, $categories = 0 ) {
+ if (!$categories )
+ $categories = get_categories( array('hide_empty' => 0) );
+
+ if ( $categories ) {
+ foreach ( $categories as $category ) {
+ if ( $currentcat != $category->term_id && $parent == $category->parent) {
+ $pad = str_repeat( '– ', $level );
+ $category->name = esc_html( $category->name );
+ echo "\n\t<option value='$category->term_id'";
+ if ( $currentparent == $category->term_id )
+ echo " selected='selected'";
+ echo ">$pad$category->name</option>";
+ wp_dropdown_cats( $currentcat, $currentparent, $category->term_id, $level +1, $categories );
+ }
+ }
+ } else {
+ return false;
+ }
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $meta
+ */
+function list_meta( $meta ) {
+ // Exit if no meta
+ if ( ! $meta ) {
+ echo '
+<table id="list-table" style="display: none;">
+ <thead>
+ <tr>
+ <th class="left">' . __( 'Name' ) . '</th>
+ <th>' . __( 'Value' ) . '</th>
+ </tr>
+ </thead>
+ <tbody id="the-list" class="list:meta">
+ <tr><td></td></tr>
+ </tbody>
+</table>'; //TBODY needed for list-manipulation JS
+ return;
+ }
+ $count = 0;
+?>
+<table id="list-table">
+ <thead>
+ <tr>
+ <th class="left"><?php _e( 'Name' ) ?></th>
+ <th><?php _e( 'Value' ) ?></th>
+ </tr>
+ </thead>
+ <tbody id='the-list' class='list:meta'>
+<?php
+ foreach ( $meta as $entry )
+ echo _list_meta_row( $entry, $count );
+?>
+ </tbody>
+</table>
+<?php
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $entry
+ * @param unknown_type $count
+ * @return unknown
+ */
+function _list_meta_row( $entry, &$count ) {
+ static $update_nonce = false;
+ if ( !$update_nonce )
+ $update_nonce = wp_create_nonce( 'add-meta' );
+
+ $r = '';
+ ++ $count;
+ if ( $count % 2 )
+ $style = 'alternate';
+ else
+ $style = '';
+ if ('_' == $entry['meta_key'] { 0 } )
+ $style .= ' hidden';
+
+ if ( is_serialized( $entry['meta_value'] ) ) {
+ if ( is_serialized_string( $entry['meta_value'] ) ) {
+ // this is a serialized string, so we should display it
+ $entry['meta_value'] = maybe_unserialize( $entry['meta_value'] );
+ } else {
+ // this is a serialized array/object so we should NOT display it
+ --$count;
+ return;
+ }
+ }
+
+ $entry['meta_key'] = esc_attr($entry['meta_key']);
+ $entry['meta_value'] = htmlspecialchars($entry['meta_value']); // using a <textarea />
+ $entry['meta_id'] = (int) $entry['meta_id'];
+
+ $delete_nonce = wp_create_nonce( 'delete-meta_' . $entry['meta_id'] );
+
+ $r .= "\n\t<tr id='meta-{$entry['meta_id']}' class='$style'>";
+ $r .= "\n\t\t<td class='left'><label class='screen-reader-text' for='meta[{$entry['meta_id']}][key]'>" . __( 'Key' ) . "</label><input name='meta[{$entry['meta_id']}][key]' id='meta[{$entry['meta_id']}][key]' tabindex='6' type='text' size='20' value='{$entry['meta_key']}' />";
+
+ $r .= "\n\t\t<div class='submit'><input name='deletemeta[{$entry['meta_id']}]' type='submit' ";
+ $r .= "class='delete:the-list:meta-{$entry['meta_id']}::_ajax_nonce=$delete_nonce deletemeta' tabindex='6' value='". esc_attr__( 'Delete' ) ."' />";
+ $r .= "\n\t\t<input name='updatemeta' type='submit' tabindex='6' value='". esc_attr__( 'Update' ) ."' class='add:the-list:meta-{$entry['meta_id']}::_ajax_nonce=$update_nonce updatemeta' /></div>";
+ $r .= wp_nonce_field( 'change-meta', '_ajax_nonce', false, false );
+ $r .= "</td>";
+
+ $r .= "\n\t\t<td><label class='screen-reader-text' for='meta[{$entry['meta_id']}][value]'>" . __( 'Value' ) . "</label><textarea name='meta[{$entry['meta_id']}][value]' id='meta[{$entry['meta_id']}][value]' tabindex='6' rows='2' cols='30'>{$entry['meta_value']}</textarea></td>\n\t</tr>";
+ return $r;
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ */
+function meta_form() {
+ global $wpdb;
+ $limit = (int) apply_filters( 'postmeta_form_limit', 30 );
+ $keys = $wpdb->get_col( "
+ SELECT meta_key
+ FROM $wpdb->postmeta
+ GROUP BY meta_key
+ HAVING meta_key NOT LIKE '\_%'
+ ORDER BY LOWER(meta_key)
+ LIMIT $limit" );
+ if ( $keys )
+ natcasesort($keys);
+?>
+<p><strong><?php _e( 'Add new custom field:' ) ?></strong></p>
+<table id="newmeta">
+<thead>
+<tr>
+<th class="left"><label for="metakeyselect"><?php _e( 'Name' ) ?></label></th>
+<th><label for="metavalue"><?php _e( 'Value' ) ?></label></th>
+</tr>
+</thead>
+
+<tbody>
+<tr>
+<td id="newmetaleft" class="left">
+<?php if ( $keys ) { ?>
+<select id="metakeyselect" name="metakeyselect" tabindex="7">
+<option value="#NONE#"><?php _e( '- Select -' ); ?></option>
+<?php
+
+ foreach ( $keys as $key ) {
+ $key = esc_attr( $key );
+ echo "\n<option value='" . esc_attr($key) . "'>$key</option>";
+ }
+?>
+</select>
+<input class="hide-if-js" type="text" id="metakeyinput" name="metakeyinput" tabindex="7" value="" />
+<a href="#postcustomstuff" class="hide-if-no-js" onclick="jQuery('#metakeyinput, #metakeyselect, #enternew, #cancelnew').toggle();return false;">
+<span id="enternew"><?php _e('Enter new'); ?></span>
+<span id="cancelnew" class="hidden"><?php _e('Cancel'); ?></span></a>
+<?php } else { ?>
+<input type="text" id="metakeyinput" name="metakeyinput" tabindex="7" value="" />
+<?php } ?>
+</td>
+<td><textarea id="metavalue" name="metavalue" rows="2" cols="25" tabindex="8"></textarea></td>
+</tr>
+
+<tr><td colspan="2" class="submit">
+<input type="submit" id="addmetasub" name="addmeta" class="add:the-list:newmeta" tabindex="9" value="<?php esc_attr_e( 'Add Custom Field' ) ?>" />
+<?php wp_nonce_field( 'add-meta', '_ajax_nonce', false ); ?>
+</td></tr>
+</tbody>
+</table>
+<?php
+
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $edit
+ * @param unknown_type $for_post
+ * @param unknown_type $tab_index
+ * @param unknown_type $multi
+ */
+function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) {
+ global $wp_locale, $post, $comment;
+
+ 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 ) ) ? false : true;
+
+ $tab_index_attribute = '';
+ if ( (int) $tab_index > 0 )
+ $tab_index_attribute = " tabindex=\"$tab_index\"";
+
+ // echo '<label for="timestamp" style="display: block;"><input type="checkbox" class="checkbox" name="edit_date" value="1" id="timestamp"'.$tab_index_attribute.' /> '.__( 'Edit timestamp' ).'</label><br />';
+
+ $time_adj = time() + (get_option( 'gmt_offset' ) * 3600 );
+ $post_date = ($for_post) ? $post->post_date : $comment->comment_date;
+ $jj = ($edit) ? mysql2date( 'd', $post_date, false ) : gmdate( 'd', $time_adj );
+ $mm = ($edit) ? mysql2date( 'm', $post_date, false ) : gmdate( 'm', $time_adj );
+ $aa = ($edit) ? mysql2date( 'Y', $post_date, false ) : gmdate( 'Y', $time_adj );
+ $hh = ($edit) ? mysql2date( 'H', $post_date, false ) : gmdate( 'H', $time_adj );
+ $mn = ($edit) ? mysql2date( 'i', $post_date, false ) : gmdate( 'i', $time_adj );
+ $ss = ($edit) ? mysql2date( 's', $post_date, false ) : gmdate( 's', $time_adj );
+
+ $cur_jj = gmdate( 'd', $time_adj );
+ $cur_mm = gmdate( 'm', $time_adj );
+ $cur_aa = gmdate( 'Y', $time_adj );
+ $cur_hh = gmdate( 'H', $time_adj );
+ $cur_mn = gmdate( 'i', $time_adj );
+
+ $month = "<select " . ( $multi ? '' : 'id="mm" ' ) . "name=\"mm\"$tab_index_attribute>\n";
+ for ( $i = 1; $i < 13; $i = $i +1 ) {
+ $month .= "\t\t\t" . '<option value="' . zeroise($i, 2) . '"';
+ if ( $i == $mm )
+ $month .= ' selected="selected"';
+ $month .= '>' . $wp_locale->get_month_abbrev( $wp_locale->get_month( $i ) ) . "</option>\n";
+ }
+ $month .= '</select>';
+
+ $day = '<input type="text" ' . ( $multi ? '' : 'id="jj" ' ) . 'name="jj" value="' . $jj . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
+ $year = '<input type="text" ' . ( $multi ? '' : 'id="aa" ' ) . 'name="aa" value="' . $aa . '" size="4" maxlength="4"' . $tab_index_attribute . ' autocomplete="off" />';
+ $hour = '<input type="text" ' . ( $multi ? '' : 'id="hh" ' ) . 'name="hh" value="' . $hh . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
+ $minute = '<input type="text" ' . ( $multi ? '' : 'id="mn" ' ) . 'name="mn" value="' . $mn . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
+ /* 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);
+
+ echo '<input type="hidden" id="ss" name="ss" value="' . $ss . '" />';
+
+ if ( $multi ) return;
+
+ echo "\n\n";
+ foreach ( array('mm', 'jj', 'aa', 'hh', 'mn') as $timeunit ) {
+ echo '<input type="hidden" id="hidden_' . $timeunit . '" name="hidden_' . $timeunit . '" value="' . $$timeunit . '" />' . "\n";
+ $cur_timeunit = 'cur_' . $timeunit;
+ echo '<input type="hidden" id="'. $cur_timeunit . '" name="'. $cur_timeunit . '" value="' . $$cur_timeunit . '" />' . "\n";
+ }
+?>
+
+<p>
+<a href="#edit_timestamp" class="save-timestamp hide-if-no-js button"><?php _e('OK'); ?></a>
+<a href="#edit_timestamp" class="cancel-timestamp hide-if-no-js"><?php _e('Cancel'); ?></a>
+</p>
+<?php
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $default
+ */
+function page_template_dropdown( $default = '' ) {
+ $templates = get_page_templates();
+ ksort( $templates );
+ foreach (array_keys( $templates ) as $template )
+ : if ( $default == $templates[$template] )
+ $selected = " selected='selected'";
+ else
+ $selected = '';
+ echo "\n\t<option value='".$templates[$template]."' $selected>$template</option>";
+ endforeach;
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $default
+ * @param unknown_type $parent
+ * @param unknown_type $level
+ * @return unknown
+ */
+function parent_dropdown( $default = 0, $parent = 0, $level = 0 ) {
+ global $wpdb, $post_ID;
+ $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;
+ }
+ }
+ $pad = str_repeat( ' ', $level * 3 );
+ if ( $item->ID == $default)
+ $current = ' selected="selected"';
+ else
+ $current = '';
+
+ echo "\n\t<option class='level-$level' value='$item->ID'$current>$pad " . esc_html($item->post_title) . "</option>";
+ parent_dropdown( $default, $item->ID, $level +1 );
+ }
+ } else {
+ return false;
+ }
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ */
+function browse_happy() {
+ $getit = __( 'WordPress recommends a better browser' );
+ echo '
+ <div id="bh"><a href="http://browsehappy.com/" title="'.$getit.'"><img src="images/browse-happy.gif" alt="Browse Happy" /></a></div>
+';
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $id
+ * @return unknown
+ */
+function the_attachment_links( $id = false ) {
+ $id = (int) $id;
+ $post = & get_post( $id );
+
+ if ( $post->post_type != 'attachment' )
+ return false;
+
+ $icon = get_attachment_icon( $post->ID );
+ $attachment_data = wp_get_attachment_metadata( $id );
+ $thumb = isset( $attachment_data['thumb'] );
+?>
+<form id="the-attachment-links">
+<table>
+ <col />
+ <col class="widefat" />
+ <tr>
+ <th scope="row"><?php _e( 'URL' ) ?></th>
+ <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><?php echo wp_get_attachment_url(); ?></textarea></td>
+ </tr>
+<?php if ( $icon ) : ?>
+ <tr>
+ <th scope="row"><?php $thumb ? _e( 'Thumbnail linked to file' ) : _e( 'Image linked to file' ); ?></th>
+ <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo wp_get_attachment_url(); ?>"><?php echo $icon ?></a></textarea></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php $thumb ? _e( 'Thumbnail linked to page' ) : _e( 'Image linked to page' ); ?></th>
+ <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo get_attachment_link( $post->ID ) ?>" rel="attachment wp-att-<?php echo $post->ID; ?>"><?php echo $icon ?></a></textarea></td>
+ </tr>
+<?php else : ?>
+ <tr>
+ <th scope="row"><?php _e( 'Link to file' ) ?></th>
+ <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo wp_get_attachment_url(); ?>" class="attachmentlink"><?php echo basename( wp_get_attachment_url() ); ?></a></textarea></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e( 'Link to page' ) ?></th>
+ <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo get_attachment_link( $post->ID ) ?>" rel="attachment wp-att-<?php echo $post->ID ?>"><?php the_title(); ?></a></textarea></td>
+ </tr>
+<?php endif; ?>
+</table>
+</form>
+<?php
+}
+
+
+/**
+ * Print out <option> html elements for role selectors based on $wp_roles
+ *
+ * @package WordPress
+ * @subpackage Administration
+ * @since 2.1
+ *
+ * @uses $wp_roles
+ * @param string $default slug for the role that should be already selected
+ */
+function wp_dropdown_roles( $selected = false ) {
+ global $wp_roles;
+ $p = '';
+ $r = '';
+
+ $editable_roles = get_editable_roles();
+
+ foreach( $editable_roles as $role => $details ) {
+ $name = translate_user_role($details['name'] );
+ if ( $selected == $role ) // Make default first in list
+ $p = "\n\t<option selected='selected' value='" . esc_attr($role) . "'>$name</option>";
+ else
+ $r .= "\n\t<option value='" . esc_attr($role) . "'>$name</option>";
+ }
+ echo $p . $r;
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @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 unknown
+ *
+ * @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 unknown
+ *
+ * @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;
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $action
+ */
+function wp_import_upload_form( $action ) {
+ $bytes = apply_filters( 'import_upload_size_limit', wp_max_upload_size() );
+ $size = wp_convert_bytes_to_hr( $bytes );
+ $upload_dir = wp_upload_dir();
+ if ( ! empty( $upload_dir['error'] ) ) :
+ ?><div class="error"><p><?php _e('Before you can upload your import file, you will need to fix the following error:'); ?></p>
+ <p><strong><?php echo $upload_dir['error']; ?></strong></p></div><?php
+ else :
+?>
+<form enctype="multipart/form-data" id="import-upload-form" method="post" action="<?php echo esc_attr($action) ?>">
+<p>
+<?php wp_nonce_field('import-upload'); ?>
+<label for="upload"><?php _e( 'Choose a file from your computer:' ); ?></label> (<?php printf( __('Maximum size: %s' ), $size ); ?>)
+<input type="file" id="upload" name="import" size="25" />
+<input type="hidden" name="action" value="save" />
+<input type="hidden" name="max_file_size" value="<?php echo $bytes; ?>" />
+</p>
+<p class="submit">
+<input type="submit" class="button" value="<?php esc_attr_e( 'Upload file and import' ); ?>" />
+</p>
+</form>
+<?php
+ endif;
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ */
+function wp_remember_old_slug() {
+ global $post;
+ $name = esc_attr($post->post_name); // just in case
+ if ( strlen($name) )
+ echo '<input type="hidden" id="wp-old-slug" name="wp-old-slug" value="' . $name . '" />';
+}
+
+/**
+ * Add a meta box to an edit form.
+ *
+ * @since 2.5.0
+ *
+ * @param string $id String for use in the 'id' attribute of tags.
+ * @param string $title Title of the meta box.
+ * @param string $callback Function that fills the box with the desired content. The function should echo its output.
+ * @param string $page The type of edit page on which to show the box (post, page, link).
+ * @param string $context The context within the page where the boxes should show ('normal', 'advanced').
+ * @param string $priority The priority within the context where the boxes should show ('high', 'low').
+ */
+function add_meta_box($id, $title, $callback, $page, $context = 'advanced', $priority = 'default', $callback_args=null) {
+ global $wp_meta_boxes;
+
+ if ( !isset($wp_meta_boxes) )
+ $wp_meta_boxes = array();
+ if ( !isset($wp_meta_boxes[$page]) )
+ $wp_meta_boxes[$page] = array();
+ if ( !isset($wp_meta_boxes[$page][$context]) )
+ $wp_meta_boxes[$page][$context] = array();
+
+ foreach ( array_keys($wp_meta_boxes[$page]) as $a_context ) {
+ foreach ( array('high', 'core', 'default', 'low') as $a_priority ) {
+ if ( !isset($wp_meta_boxes[$page][$a_context][$a_priority][$id]) )
+ continue;
+
+ // If a core box was previously added or removed by a plugin, don't add.
+ if ( 'core' == $priority ) {
+ // If core box previously deleted, don't add
+ if ( false === $wp_meta_boxes[$page][$a_context][$a_priority][$id] )
+ return;
+ // If box was added with default priority, give it core priority to maintain sort order
+ if ( 'default' == $a_priority ) {
+ $wp_meta_boxes[$page][$a_context]['core'][$id] = $wp_meta_boxes[$page][$a_context]['default'][$id];
+ unset($wp_meta_boxes[$page][$a_context]['default'][$id]);
+ }
+ return;
+ }
+ // If no priority given and id already present, use existing priority
+ if ( empty($priority) ) {
+ $priority = $a_priority;
+ // else if we're adding to the sorted priortiy, we don't know the title or callback. Glab them from the previously added context/priority.
+ } elseif ( 'sorted' == $priority ) {
+ $title = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['title'];
+ $callback = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['callback'];
+ $callback_args = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['args'];
+ }
+ // An id can be in only one priority and one context
+ if ( $priority != $a_priority || $context != $a_context )
+ unset($wp_meta_boxes[$page][$a_context][$a_priority][$id]);
+ }
+ }
+
+ if ( empty($priority) )
+ $priority = 'low';
+
+ if ( !isset($wp_meta_boxes[$page][$context][$priority]) )
+ $wp_meta_boxes[$page][$context][$priority] = array();
+
+ $wp_meta_boxes[$page][$context][$priority][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback, 'args' => $callback_args);
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $page
+ * @param unknown_type $context
+ * @param unknown_type $object
+ * @return int number of meta_boxes
+ */
+function do_meta_boxes($page, $context, $object) {
+ global $wp_meta_boxes;
+ static $already_sorted = false;
+
+ //do_action('do_meta_boxes', $page, $context, $object);
+
+ $hidden = get_hidden_meta_boxes($page);
+
+ echo "<div id='$context-sortables' class='meta-box-sortables'>\n";
+
+ $i = 0;
+ do {
+ // Grab the ones the user has manually sorted. Pull them out of their previous context/priority and into the one the user chose
+ if ( !$already_sorted && $sorted = get_user_option( "meta-box-order_$page", 0, false ) ) {
+ foreach ( $sorted as $box_context => $ids )
+ foreach ( explode(',', $ids) as $id )
+ if ( $id )
+ add_meta_box( $id, null, null, $page, $box_context, 'sorted' );
+ }
+ $already_sorted = true;
+
+ if ( !isset($wp_meta_boxes) || !isset($wp_meta_boxes[$page]) || !isset($wp_meta_boxes[$page][$context]) )
+ break;
+
+ foreach ( array('high', 'sorted', 'core', 'default', 'low') as $priority ) {
+ if ( isset($wp_meta_boxes[$page][$context][$priority]) ) {
+ foreach ( (array) $wp_meta_boxes[$page][$context][$priority] as $box ) {
+ if ( false == $box || ! $box['title'] )
+ continue;
+ $i++;
+ $style = '';
+ if ( in_array($box['id'], $hidden) )
+ $style = 'style="display:none;"';
+ echo '<div id="' . $box['id'] . '" class="postbox ' . postbox_classes($box['id'], $page) . '" ' . $style . '>' . "\n";
+ echo '<div class="handlediv" title="' . __('Click to toggle') . '"><br /></div>';
+ echo "<h3 class='hndle'><span>{$box['title']}</span></h3>\n";
+ echo '<div class="inside">' . "\n";
+ call_user_func($box['callback'], $object, $box);
+ echo "</div>\n";
+ echo "</div>\n";
+ }
+ }
+ }
+ } while(0);
+
+ echo "</div>";
+
+ return $i;
+
+}
+
+/**
+ * Remove a meta box from an edit form.
+ *
+ * @since 2.6.0
+ *
+ * @param string $id String for use in the 'id' attribute of tags.
+ * @param string $page The type of edit page on which to show the box (post, page, link).
+ * @param string $context The context within the page where the boxes should show ('normal', 'advanced').
+ */
+function remove_meta_box($id, $page, $context) {
+ global $wp_meta_boxes;
+
+ if ( !isset($wp_meta_boxes) )
+ $wp_meta_boxes = array();
+ if ( !isset($wp_meta_boxes[$page]) )
+ $wp_meta_boxes[$page] = array();
+ if ( !isset($wp_meta_boxes[$page][$context]) )
+ $wp_meta_boxes[$page][$context] = array();
+
+ foreach ( array('high', 'core', 'default', 'low') as $priority )
+ $wp_meta_boxes[$page][$context][$priority][$id] = false;
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $page
+ */
+function meta_box_prefs($page) {
+ global $wp_meta_boxes;
+
+ if ( empty($wp_meta_boxes[$page]) )
+ return;
+
+ $hidden = get_hidden_meta_boxes($page);
+
+ foreach ( array_keys($wp_meta_boxes[$page]) as $context ) {
+ foreach ( array_keys($wp_meta_boxes[$page][$context]) as $priority ) {
+ foreach ( $wp_meta_boxes[$page][$context][$priority] as $box ) {
+ if ( false == $box || ! $box['title'] )
+ continue;
+ // Submit box cannot be hidden
+ if ( 'submitdiv' == $box['id'] || 'linksubmitdiv' == $box['id'] )
+ continue;
+ $box_id = $box['id'];
+ echo '<label for="' . $box_id . '-hide">';
+ echo '<input class="hide-postbox-tog" name="' . $box_id . '-hide" type="checkbox" id="' . $box_id . '-hide" value="' . $box_id . '"' . (! in_array($box_id, $hidden) ? ' checked="checked"' : '') . ' />';
+ echo "{$box['title']}</label>\n";
+ }
+ }
+ }
+}
+
+function get_hidden_meta_boxes($page) {
+ $hidden = (array) get_user_option( "meta-box-hidden_$page", 0, false );
+
+ // Hide slug boxes by default
+ if ( empty($hidden[0]) ) {
+ if ( 'page' == $page )
+ $hidden = array('pageslugdiv');
+ elseif ( 'post' == $page )
+ $hidden = array('slugdiv');
+ }
+
+ return $hidden;
+}
+
+/**
+ * Add a new section to a settings page.
+ *
+ * @since 2.7.0
+ *
+ * @param string $id String for use in the 'id' attribute of tags.
+ * @param string $title Title of the section.
+ * @param string $callback Function that fills the section with the desired content. The function should echo its output.
+ * @param string $page The type of settings page on which to show the section (general, reading, writing, ...).
+ */
+function add_settings_section($id, $title, $callback, $page) {
+ global $wp_settings_sections;
+
+ if ( !isset($wp_settings_sections) )
+ $wp_settings_sections = array();
+ if ( !isset($wp_settings_sections[$page]) )
+ $wp_settings_sections[$page] = array();
+ if ( !isset($wp_settings_sections[$page][$id]) )
+ $wp_settings_sections[$page][$id] = array();
+
+ $wp_settings_sections[$page][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback);
+}
+
+/**
+ * Add a new field to a settings page.
+ *
+ * @since 2.7.0
+ *
+ * @param string $id String for use in the 'id' attribute of tags.
+ * @param string $title Title of the field.
+ * @param string $callback Function that fills the field with the desired content. The function should echo its output.
+ * @param string $page The type of settings page on which to show the field (general, reading, writing, ...).
+ * @param string $section The section of the settingss page in which to show the box (default, ...).
+ * @param array $args Additional arguments
+ */
+function add_settings_field($id, $title, $callback, $page, $section = 'default', $args = array()) {
+ global $wp_settings_fields;
+
+ if ( !isset($wp_settings_fields) )
+ $wp_settings_fields = array();
+ if ( !isset($wp_settings_fields[$page]) )
+ $wp_settings_fields[$page] = array();
+ if ( !isset($wp_settings_fields[$page][$section]) )
+ $wp_settings_fields[$page][$section] = array();
+
+ $wp_settings_fields[$page][$section][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback, 'args' => $args);
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $page
+ */
+function do_settings_sections($page) {
+ global $wp_settings_sections, $wp_settings_fields;
+
+ if ( !isset($wp_settings_sections) || !isset($wp_settings_sections[$page]) )
+ return;
+
+ foreach ( (array) $wp_settings_sections[$page] as $section ) {
+ echo "<h3>{$section['title']}</h3>\n";
+ 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 '<table class="form-table">';
+ do_settings_fields($page, $section['id']);
+ echo '</table>';
+ }
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $page
+ * @param unknown_type $section
+ */
+function do_settings_fields($page, $section) {
+ global $wp_settings_fields;
+
+ if ( !isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section]) )
+ return;
+
+ foreach ( (array) $wp_settings_fields[$page][$section] as $field ) {
+ echo '<tr valign="top">';
+ if ( !empty($field['args']['label_for']) )
+ echo '<th scope="row"><label for="' . $field['args']['label_for'] . '">' . $field['title'] . '</label></th>';
+ else
+ echo '<th scope="row">' . $field['title'] . '</th>';
+ echo '<td>';
+ call_user_func($field['callback']);
+ echo '</td>';
+ echo '</tr>';
+ }
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $page
+ */
+function manage_columns_prefs($page) {
+ $columns = get_column_headers($page);
+
+ $hidden = get_hidden_columns($page);
+
+ foreach ( $columns as $column => $title ) {
+ // Can't hide these
+ if ( 'cb' == $column || 'title' == $column || 'name' == $column || 'username' == $column || 'media' == $column || 'comment' == $column )
+ continue;
+ if ( empty($title) )
+ continue;
+
+ if ( 'comments' == $column )
+ $title = __('Comments');
+ $id = "$column-hide";
+ echo '<label for="' . $id . '">';
+ echo '<input class="hide-column-tog" name="' . $id . '" type="checkbox" id="' . $id . '" value="' . $column . '"' . (! in_array($column, $hidden) ? ' checked="checked"' : '') . ' />';
+ echo "$title</label>\n";
+ }
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $found_action
+ */
+function find_posts_div($found_action = '') {
+?>
+ <div id="find-posts" class="find-box" style="display:none;">
+ <div id="find-posts-head" class="find-box-head"><?php _e('Find Posts or Pages'); ?></div>
+ <div class="find-box-inside">
+ <div class="find-box-search">
+ <?php if ( $found_action ) { ?>
+ <input type="hidden" name="found_action" value="<?php echo esc_attr($found_action); ?>" />
+ <?php } ?>
+
+ <input type="hidden" name="affected" id="affected" value="" />
+ <?php wp_nonce_field( 'find-posts', '_ajax_nonce', false ); ?>
+ <label class="screen-reader-text" for="find-posts-input"><?php _e( 'Search' ); ?></label>
+ <input type="text" id="find-posts-input" name="ps" value="" />
+ <input type="button" onclick="findPosts.send();" value="<?php esc_attr_e( 'Search' ); ?>" class="button" /><br />
+
+ <input type="radio" name="find-posts-what" id="find-posts-posts" checked="checked" value="posts" />
+ <label for="find-posts-posts"><?php _e( 'Posts' ); ?></label>
+ <input type="radio" name="find-posts-what" id="find-posts-pages" value="pages" />
+ <label for="find-posts-pages"><?php _e( 'Pages' ); ?></label>
+ </div>
+ <div id="find-posts-response"></div>
+ </div>
+ <div class="find-box-buttons">
+ <input type="button" class="button alignleft" onclick="findPosts.close();" value="<?php esc_attr_e('Close'); ?>" />
+ <input id="find-posts-submit" type="submit" class="button-primary alignright" value="<?php esc_attr_e('Select'); ?>" />
+ </div>
+ </div>
+<?php
+}
+
+/**
+ * Display the post password.
+ *
+ * The password is passed through {@link esc_attr()} to ensure that it
+ * is safe for placing in an html attribute.
+ *
+ * @uses attr
+ * @since 2.7.0
+ */
+function the_post_password() {
+ global $post;
+ if ( isset( $post->post_password ) ) echo esc_attr( $post->post_password );
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ */
+function favorite_actions( $screen = null ) {
+ switch ( $screen ) {
+ case 'post-new.php':
+ $default_action = array('edit.php' => array(__('Edit Posts'), 'edit_posts'));
+ break;
+ case 'edit-pages.php':
+ $default_action = array('page-new.php' => array(__('New Page'), 'edit_pages'));
+ break;
+ case 'page-new.php':
+ $default_action = array('edit-pages.php' => array(__('Edit Pages'), 'edit_pages'));
+ break;
+ case 'upload.php':
+ $default_action = array('media-new.php' => array(__('New Media'), 'upload_files'));
+ break;
+ case 'media-new.php':
+ $default_action = array('upload.php' => array(__('Edit Media'), 'upload_files'));
+ break;
+ case 'link-manager.php':
+ $default_action = array('link-add.php' => array(__('New Link'), 'manage_links'));
+ break;
+ case 'link-add.php':
+ $default_action = array('link-manager.php' => array(__('Edit Links'), 'manage_links'));
+ break;
+ case 'users.php':
+ $default_action = array('user-new.php' => array(__('New User'), 'create_users'));
+ break;
+ case 'user-new.php':
+ $default_action = array('users.php' => array(__('Edit Users'), 'edit_users'));
+ break;
+ case 'plugins.php':
+ $default_action = array('plugin-install.php' => array(__('Install Plugins'), 'install_plugins'));
+ break;
+ case 'plugin-install.php':
+ $default_action = array('plugins.php' => array(__('Manage Plugins'), 'activate_plugins'));
+ break;
+ case 'themes.php':
+ $default_action = array('theme-install.php' => array(__('Install Themes'), 'install_themes'));
+ break;
+ case 'theme-install.php':
+ $default_action = array('themes.php' => array(__('Manage Themes'), 'switch_themes'));
+ break;
+ default:
+ $default_action = array('post-new.php' => array(__('New Post'), 'edit_posts'));
+ break;
+ }
+
+ $actions = array(
+ 'post-new.php' => array(__('New Post'), 'edit_posts'),
+ 'edit.php?post_status=draft' => array(__('Drafts'), 'edit_posts'),
+ 'page-new.php' => array(__('New Page'), 'edit_pages'),
+ 'media-new.php' => array(__('Upload'), 'upload_files'),
+ 'edit-comments.php' => array(__('Comments'), 'moderate_comments')
+ );
+
+ $default_key = array_keys($default_action);
+ $default_key = $default_key[0];
+ if ( isset($actions[$default_key]) )
+ unset($actions[$default_key]);
+ $actions = array_merge($default_action, $actions);
+ $actions = apply_filters('favorite_actions', $actions);
+
+ $allowed_actions = array();
+ foreach ( $actions as $action => $data ) {
+ if ( current_user_can($data[1]) )
+ $allowed_actions[$action] = $data[0];
+ }
+
+ if ( empty($allowed_actions) )
+ return;
+
+ $first = array_keys($allowed_actions);
+ $first = $first[0];
+ echo '<div id="favorite-actions">';
+ echo '<div id="favorite-first"><a href="' . $first . '">' . $allowed_actions[$first] . '</a></div><div id="favorite-toggle"><br /></div>';
+ echo '<div id="favorite-inside">';
+
+ array_shift($allowed_actions);
+
+ foreach ( $allowed_actions as $action => $label) {
+ echo "<div class='favorite-action'><a href='$action'>";
+ echo $label;
+ echo "</a></div>\n";
+ }
+ echo "</div></div>\n";
+}
+
+/**
+ * Get the post title.
+ *
+ * The post title is fetched and if it is blank then a default string is
+ * returned.
+ *
+ * @since 2.7.0
+ * @param int $id The post id. If not supplied the global $post is used.
+ *
+ */
+function _draft_or_post_title($post_id = 0)
+{
+ $title = get_the_title($post_id);
+ if ( empty($title) )
+ $title = __('(no title)');
+ return $title;