raw
mp-wp_genesis           1 <?php
mp-wp_genesis 2 /**
mp-wp_genesis 3 * Template WordPress Administration API.
mp-wp_genesis 4 *
mp-wp_genesis 5 * A Big Mess. Also some neat functions that are nicely written.
mp-wp_genesis 6 *
mp-wp_genesis 7 * @package WordPress
mp-wp_genesis 8 * @subpackage Administration
mp-wp_genesis 9 */
mp-wp_genesis 10
mp-wp_genesis 11 // Ugly recursive category stuff.
mp-wp_genesis 12 /**
mp-wp_genesis 13 * {@internal Missing Short Description}}
mp-wp_genesis 14 *
mp-wp_genesis 15 * @since unknown
mp-wp_genesis 16 *
mp-wp_genesis 17 * @param unknown_type $parent
mp-wp_genesis 18 * @param unknown_type $level
mp-wp_genesis 19 * @param unknown_type $categories
mp-wp_genesis 20 * @param unknown_type $page
mp-wp_genesis 21 * @param unknown_type $per_page
mp-wp_genesis 22 */
mp-wp_genesis 23 function cat_rows( $parent = 0, $level = 0, $categories = 0, $page = 1, $per_page = 20 ) {
mp-wp_genesis 24 $count = 0;
mp-wp_genesis 25 _cat_rows($categories, $count, $parent, $level, $page, $per_page);
mp-wp_genesis 26 }
mp-wp_genesis 27
mp-wp_genesis 28 /**
mp-wp_genesis 29 * {@internal Missing Short Description}}
mp-wp_genesis 30 *
mp-wp_genesis 31 * @since unknown
mp-wp_genesis 32 *
mp-wp_genesis 33 * @param unknown_type $categories
mp-wp_genesis 34 * @param unknown_type $count
mp-wp_genesis 35 * @param unknown_type $parent
mp-wp_genesis 36 * @param unknown_type $level
mp-wp_genesis 37 * @param unknown_type $page
mp-wp_genesis 38 * @param unknown_type $per_page
mp-wp_genesis 39 * @return unknown
mp-wp_genesis 40 */
mp-wp_genesis 41 function _cat_rows( $categories, &$count, $parent = 0, $level = 0, $page = 1, $per_page = 20 ) {
mp-wp_genesis 42 if ( empty($categories) ) {
mp-wp_genesis 43 $args = array('hide_empty' => 0);
mp-wp_genesis 44 if ( !empty($_GET['s']) )
mp-wp_genesis 45 $args['search'] = $_GET['s'];
mp-wp_genesis 46 $categories = get_categories( $args );
mp-wp_genesis 47 }
mp-wp_genesis 48
mp-wp_genesis 49 if ( !$categories )
mp-wp_genesis 50 return false;
mp-wp_genesis 51
mp-wp_genesis 52 $children = _get_term_hierarchy('category');
mp-wp_genesis 53
mp-wp_genesis 54 $start = ($page - 1) * $per_page;
mp-wp_genesis 55 $end = $start + $per_page;
mp-wp_genesis 56 $i = -1;
mp-wp_genesis 57 ob_start();
mp-wp_genesis 58 foreach ( $categories as $category ) {
mp-wp_genesis 59 if ( $count >= $end )
mp-wp_genesis 60 break;
mp-wp_genesis 61
mp-wp_genesis 62 $i++;
mp-wp_genesis 63
mp-wp_genesis 64 if ( $category->parent != $parent )
mp-wp_genesis 65 continue;
mp-wp_genesis 66
mp-wp_genesis 67 // If the page starts in a subtree, print the parents.
mp-wp_genesis 68 if ( $count == $start && $category->parent > 0 ) {
mp-wp_genesis 69 $my_parents = array();
mp-wp_genesis 70 while ( $my_parent) {
mp-wp_genesis 71 $my_parent = get_category($my_parent);
mp-wp_genesis 72 $my_parents[] = $my_parent;
mp-wp_genesis 73 if ( !$my_parent->parent )
mp-wp_genesis 74 break;
mp-wp_genesis 75 $my_parent = $my_parent->parent;
mp-wp_genesis 76 }
mp-wp_genesis 77 $num_parents = count($my_parents);
mp-wp_genesis 78 while( $my_parent = array_pop($my_parents) ) {
mp-wp_genesis 79 echo "\t" . _cat_row( $my_parent, $level - $num_parents );
mp-wp_genesis 80 $num_parents--;
mp-wp_genesis 81 }
mp-wp_genesis 82 }
mp-wp_genesis 83
mp-wp_genesis 84 if ( $count >= $start )
mp-wp_genesis 85 echo "\t" . _cat_row( $category, $level );
mp-wp_genesis 86
mp-wp_genesis 87 unset($categories[$i]); // Prune the working set
mp-wp_genesis 88 $count++;
mp-wp_genesis 89
mp-wp_genesis 90 if ( isset($children[$category->term_id]) )
mp-wp_genesis 91 _cat_rows( $categories, $count, $category->term_id, $level + 1, $page, $per_page );
mp-wp_genesis 92
mp-wp_genesis 93 }
mp-wp_genesis 94
mp-wp_genesis 95 $output = ob_get_contents();
mp-wp_genesis 96 ob_end_clean();
mp-wp_genesis 97
mp-wp_genesis 98 echo $output;
mp-wp_genesis 99 }
mp-wp_genesis 100
mp-wp_genesis 101 /**
mp-wp_genesis 102 * {@internal Missing Short Description}}
mp-wp_genesis 103 *
mp-wp_genesis 104 * @since unknown
mp-wp_genesis 105 *
mp-wp_genesis 106 * @param unknown_type $category
mp-wp_genesis 107 * @param unknown_type $level
mp-wp_genesis 108 * @param unknown_type $name_override
mp-wp_genesis 109 * @return unknown
mp-wp_genesis 110 */
mp-wp_genesis 111 function _cat_row( $category, $level, $name_override = false ) {
mp-wp_genesis 112 static $row_class = '';
mp-wp_genesis 113
mp-wp_genesis 114 $category = get_category( $category, OBJECT, 'display' );
mp-wp_genesis 115
mp-wp_genesis 116 $default_cat_id = (int) get_option( 'default_category' );
mp-wp_genesis 117 $pad = str_repeat( '&#8212; ', $level );
mp-wp_genesis 118 $name = ( $name_override ? $name_override : $pad . ' ' . $category->name );
mp-wp_genesis 119 $edit_link = "categories.php?action=edit&amp;cat_ID=$category->term_id";
mp-wp_genesis 120 if ( current_user_can( 'manage_categories' ) ) {
mp-wp_genesis 121 $edit = "<a class='row-title' href='$edit_link' title='" . attribute_escape(sprintf(__('Edit "%s"'), $category->name)) . "'>" . attribute_escape( $name ) . '</a><br />';
mp-wp_genesis 122 $actions = array();
mp-wp_genesis 123 $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
mp-wp_genesis 124 if ( $default_cat_id != $category->term_id )
mp-wp_remove-all-... 125 $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("categories.php?action=delete&amp;cat_ID=$category->term_id", 'delete-category_' . $category->term_id) . "'>" . __('Delete') . "</a>";
mp-wp_genesis 126 $action_count = count($actions);
mp-wp_genesis 127 $i = 0;
mp-wp_genesis 128 $edit .= '<div class="row-actions">';
mp-wp_genesis 129 foreach ( $actions as $action => $link ) {
mp-wp_genesis 130 ++$i;
mp-wp_genesis 131 ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
mp-wp_genesis 132 $edit .= "<span class='$action'>$link$sep</span>";
mp-wp_genesis 133 }
mp-wp_genesis 134 $edit .= '</div>';
mp-wp_genesis 135 } else {
mp-wp_genesis 136 $edit = $name;
mp-wp_genesis 137 }
mp-wp_genesis 138
mp-wp_genesis 139 $row_class = 'alternate' == $row_class ? '' : 'alternate';
mp-wp_genesis 140 $qe_data = get_category_to_edit($category->term_id);
mp-wp_genesis 141
mp-wp_genesis 142 $category->count = number_format_i18n( $category->count );
mp-wp_genesis 143 $posts_count = ( $category->count > 0 ) ? "<a href='edit.php?cat=$category->term_id'>$category->count</a>" : $category->count;
mp-wp_genesis 144 $output = "<tr id='cat-$category->term_id' class='iedit $row_class'>";
mp-wp_genesis 145
mp-wp_genesis 146 $columns = get_column_headers('categories');
mp-wp_genesis 147 $hidden = get_hidden_columns('categories');
mp-wp_genesis 148 foreach ( $columns as $column_name => $column_display_name ) {
mp-wp_genesis 149 $class = "class=\"$column_name column-$column_name\"";
mp-wp_genesis 150
mp-wp_genesis 151 $style = '';
mp-wp_genesis 152 if ( in_array($column_name, $hidden) )
mp-wp_genesis 153 $style = ' style="display:none;"';
mp-wp_genesis 154
mp-wp_genesis 155 $attributes = "$class$style";
mp-wp_genesis 156
mp-wp_genesis 157 switch ($column_name) {
mp-wp_genesis 158 case 'cb':
mp-wp_remove-all-... 159 $output .= "<td scope='row' class='check-column'>";
mp-wp_genesis 160 if ( $default_cat_id != $category->term_id ) {
mp-wp_genesis 161 $output .= "<input type='checkbox' name='delete[]' value='$category->term_id' />";
mp-wp_genesis 162 } else {
mp-wp_genesis 163 $output .= "&nbsp;";
mp-wp_genesis 164 }
mp-wp_remove-all-... 165 $output .= '</td>';
mp-wp_genesis 166 break;
mp-wp_genesis 167 case 'name':
mp-wp_genesis 168 $output .= "<td $attributes>$edit";
mp-wp_genesis 169 $output .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">';
mp-wp_genesis 170 $output .= '<div class="name">' . $qe_data->name . '</div>';
mp-wp_genesis 171 $output .= '<div class="slug">' . $qe_data->slug . '</div>';
mp-wp_genesis 172 $output .= '<div class="cat_parent">' . $qe_data->parent . '</div></div></td>';
mp-wp_genesis 173 break;
mp-wp_genesis 174 case 'description':
mp-wp_genesis 175 $output .= "<td $attributes>$category->description</td>";
mp-wp_genesis 176 break;
mp-wp_genesis 177 case 'slug':
mp-wp_genesis 178 $output .= "<td $attributes>$category->slug</td>";
mp-wp_genesis 179 break;
mp-wp_genesis 180 case 'posts':
mp-wp_genesis 181 $attributes = 'class="posts column-posts num"' . $style;
mp-wp_genesis 182 $output .= "<td $attributes>$posts_count</td>\n";
mp-wp_genesis 183 }
mp-wp_genesis 184 }
mp-wp_genesis 185 $output .= '</tr>';
mp-wp_genesis 186
mp-wp_genesis 187 return $output;
mp-wp_genesis 188 }
mp-wp_genesis 189
mp-wp_genesis 190 /**
mp-wp_genesis 191 * {@internal Missing Short Description}}
mp-wp_genesis 192 *
mp-wp_genesis 193 * @since unknown
mp-wp_genesis 194 *
mp-wp_genesis 195 * @param unknown_type $category
mp-wp_genesis 196 * @param unknown_type $name_override
mp-wp_genesis 197 * @return unknown
mp-wp_genesis 198 */
mp-wp_genesis 199 function link_cat_row( $category, $name_override = false ) {
mp-wp_genesis 200 static $row_class = '';
mp-wp_genesis 201
mp-wp_genesis 202 if ( !$category = get_term( $category, 'link_category', OBJECT, 'display' ) )
mp-wp_genesis 203 return false;
mp-wp_genesis 204 if ( is_wp_error( $category ) )
mp-wp_genesis 205 return $category;
mp-wp_genesis 206
mp-wp_genesis 207 $default_cat_id = (int) get_option( 'default_link_category' );
mp-wp_genesis 208 $name = ( $name_override ? $name_override : $category->name );
mp-wp_genesis 209 $edit_link = "link-category.php?action=edit&amp;cat_ID=$category->term_id";
mp-wp_genesis 210 if ( current_user_can( 'manage_categories' ) ) {
mp-wp_genesis 211 $edit = "<a class='row-title' href='$edit_link' title='" . attribute_escape(sprintf(__('Edit "%s"'), $category->name)) . "'>$name</a><br />";
mp-wp_genesis 212 $actions = array();
mp-wp_genesis 213 $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
mp-wp_genesis 214 if ( $default_cat_id != $category->term_id )
mp-wp_remove-all-... 215 $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("link-category.php?action=delete&amp;cat_ID=$category->term_id", 'delete-link-category_' . $category->term_id) . "'>" . __('Delete') . "</a>";
mp-wp_genesis 216 $action_count = count($actions);
mp-wp_genesis 217 $i = 0;
mp-wp_genesis 218 $edit .= '<div class="row-actions">';
mp-wp_genesis 219 foreach ( $actions as $action => $link ) {
mp-wp_genesis 220 ++$i;
mp-wp_genesis 221 ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
mp-wp_genesis 222 $edit .= "<span class='$action'>$link$sep</span>";
mp-wp_genesis 223 }
mp-wp_genesis 224 $edit .= '</div>';
mp-wp_genesis 225 } else {
mp-wp_genesis 226 $edit = $name;
mp-wp_genesis 227 }
mp-wp_genesis 228
mp-wp_genesis 229 $row_class = 'alternate' == $row_class ? '' : 'alternate';
mp-wp_genesis 230 $qe_data = get_term_to_edit($category->term_id, 'link_category');
mp-wp_genesis 231
mp-wp_genesis 232 $category->count = number_format_i18n( $category->count );
mp-wp_genesis 233 $count = ( $category->count > 0 ) ? "<a href='link-manager.php?cat_id=$category->term_id'>$category->count</a>" : $category->count;
mp-wp_genesis 234 $output = "<tr id='link-cat-$category->term_id' class='iedit $row_class'>";
mp-wp_genesis 235 $columns = get_column_headers('edit-link-categories');
mp-wp_genesis 236 $hidden = get_hidden_columns('edit-link-categories');
mp-wp_genesis 237 foreach ( $columns as $column_name => $column_display_name ) {
mp-wp_genesis 238 $class = "class=\"$column_name column-$column_name\"";
mp-wp_genesis 239
mp-wp_genesis 240 $style = '';
mp-wp_genesis 241 if ( in_array($column_name, $hidden) )
mp-wp_genesis 242 $style = ' style="display:none;"';
mp-wp_genesis 243
mp-wp_genesis 244 $attributes = "$class$style";
mp-wp_genesis 245
mp-wp_genesis 246 switch ($column_name) {
mp-wp_genesis 247 case 'cb':
mp-wp_remove-all-... 248 $output .= "<td scope='row' class='check-column'>";
mp-wp_genesis 249 if ( absint( get_option( 'default_link_category' ) ) != $category->term_id ) {
mp-wp_genesis 250 $output .= "<input type='checkbox' name='delete[]' value='$category->term_id' />";
mp-wp_genesis 251 } else {
mp-wp_genesis 252 $output .= "&nbsp;";
mp-wp_genesis 253 }
mp-wp_remove-all-... 254 $output .= "</td>";
mp-wp_genesis 255 break;
mp-wp_genesis 256 case 'name':
mp-wp_genesis 257 $output .= "<td $attributes>$edit";
mp-wp_genesis 258 $output .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">';
mp-wp_genesis 259 $output .= '<div class="name">' . $qe_data->name . '</div>';
mp-wp_genesis 260 $output .= '<div class="slug">' . $qe_data->slug . '</div>';
mp-wp_genesis 261 $output .= '<div class="cat_parent">' . $qe_data->parent . '</div></div></td>';
mp-wp_genesis 262 break;
mp-wp_genesis 263 case 'description':
mp-wp_genesis 264 $output .= "<td $attributes>$category->description</td>";
mp-wp_genesis 265 break;
mp-wp_genesis 266 case 'slug':
mp-wp_genesis 267 $output .= "<td $attributes>$category->slug</td>";
mp-wp_genesis 268 break;
mp-wp_genesis 269 case 'links':
mp-wp_genesis 270 $attributes = 'class="links column-links num"' . $style;
mp-wp_genesis 271 $output .= "<td $attributes>$count</td>";
mp-wp_genesis 272 }
mp-wp_genesis 273 }
mp-wp_genesis 274 $output .= '</tr>';
mp-wp_genesis 275
mp-wp_genesis 276 return $output;
mp-wp_genesis 277 }
mp-wp_genesis 278
mp-wp_genesis 279 /**
mp-wp_genesis 280 * {@internal Missing Short Description}}
mp-wp_genesis 281 *
mp-wp_genesis 282 * @since unknown
mp-wp_genesis 283 *
mp-wp_genesis 284 * @param unknown_type $checked
mp-wp_genesis 285 * @param unknown_type $current
mp-wp_genesis 286 */
mp-wp_genesis 287 function checked( $checked, $current) {
mp-wp_genesis 288 if ( $checked == $current)
mp-wp_genesis 289 echo ' checked="checked"';
mp-wp_genesis 290 }
mp-wp_genesis 291
mp-wp_genesis 292 /**
mp-wp_genesis 293 * {@internal Missing Short Description}}
mp-wp_genesis 294 *
mp-wp_genesis 295 * @since unknown
mp-wp_genesis 296 *
mp-wp_genesis 297 * @param unknown_type $selected
mp-wp_genesis 298 * @param unknown_type $current
mp-wp_genesis 299 */
mp-wp_genesis 300 function selected( $selected, $current) {
mp-wp_genesis 301 if ( $selected == $current)
mp-wp_genesis 302 echo ' selected="selected"';
mp-wp_genesis 303 }
mp-wp_genesis 304
mp-wp_genesis 305 //
mp-wp_genesis 306 // Category Checklists
mp-wp_genesis 307 //
mp-wp_genesis 308
mp-wp_genesis 309 /**
mp-wp_genesis 310 * {@internal Missing Short Description}}
mp-wp_genesis 311 *
mp-wp_genesis 312 * @since unknown
mp-wp_genesis 313 * @deprecated Use {@link wp_link_category_checklist()}
mp-wp_genesis 314 * @see wp_link_category_checklist()
mp-wp_genesis 315 *
mp-wp_genesis 316 * @param unknown_type $default
mp-wp_genesis 317 * @param unknown_type $parent
mp-wp_genesis 318 * @param unknown_type $popular_ids
mp-wp_genesis 319 */
mp-wp_genesis 320 function dropdown_categories( $default = 0, $parent = 0, $popular_ids = array() ) {
mp-wp_genesis 321 global $post_ID;
mp-wp_genesis 322 wp_category_checklist($post_ID);
mp-wp_genesis 323 }
mp-wp_genesis 324
mp-wp_genesis 325 /**
mp-wp_genesis 326 * {@internal Missing Short Description}}
mp-wp_genesis 327 *
mp-wp_genesis 328 * @since unknown
mp-wp_genesis 329 */
mp-wp_genesis 330 class Walker_Category_Checklist extends Walker {
mp-wp_genesis 331 var $tree_type = 'category';
mp-wp_genesis 332 var $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); //TODO: decouple this
mp-wp_genesis 333
mp-wp_genesis 334 function start_lvl(&$output, $depth, $args) {
mp-wp_genesis 335 $indent = str_repeat("\t", $depth);
mp-wp_genesis 336 $output .= "$indent<ul class='children'>\n";
mp-wp_genesis 337 }
mp-wp_genesis 338
mp-wp_genesis 339 function end_lvl(&$output, $depth, $args) {
mp-wp_genesis 340 $indent = str_repeat("\t", $depth);
mp-wp_genesis 341 $output .= "$indent</ul>\n";
mp-wp_genesis 342 }
mp-wp_genesis 343
mp-wp_genesis 344 function start_el(&$output, $category, $depth, $args) {
mp-wp_genesis 345 extract($args);
mp-wp_genesis 346
mp-wp_genesis 347 $class = in_array( $category->term_id, $popular_cats ) ? ' class="popular-category"' : '';
mp-wp_genesis 348 $output .= "\n<li id='category-$category->term_id'$class>" . '<label class="selectit"><input value="' . $category->term_id . '" type="checkbox" name="post_category[]" id="in-category-' . $category->term_id . '"' . (in_array( $category->term_id, $selected_cats ) ? ' checked="checked"' : "" ) . '/> ' . wp_specialchars( apply_filters('the_category', $category->name )) . '</label>';
mp-wp_genesis 349 }
mp-wp_genesis 350
mp-wp_genesis 351 function end_el(&$output, $category, $depth, $args) {
mp-wp_genesis 352 $output .= "</li>\n";
mp-wp_genesis 353 }
mp-wp_genesis 354 }
mp-wp_genesis 355
mp-wp_genesis 356 /**
mp-wp_genesis 357 * {@internal Missing Short Description}}
mp-wp_genesis 358 *
mp-wp_genesis 359 * @since unknown
mp-wp_genesis 360 *
mp-wp_genesis 361 * @param unknown_type $post_id
mp-wp_genesis 362 * @param unknown_type $descendants_and_self
mp-wp_genesis 363 * @param unknown_type $selected_cats
mp-wp_genesis 364 * @param unknown_type $popular_cats
mp-wp_genesis 365 */
mp-wp_genesis 366 function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $selected_cats = false, $popular_cats = false ) {
mp-wp_genesis 367 $walker = new Walker_Category_Checklist;
mp-wp_genesis 368 $descendants_and_self = (int) $descendants_and_self;
mp-wp_genesis 369
mp-wp_genesis 370 $args = array();
mp-wp_genesis 371
mp-wp_genesis 372 if ( is_array( $selected_cats ) )
mp-wp_genesis 373 $args['selected_cats'] = $selected_cats;
mp-wp_genesis 374 elseif ( $post_id )
mp-wp_genesis 375 $args['selected_cats'] = wp_get_post_categories($post_id);
mp-wp_genesis 376 else
mp-wp_genesis 377 $args['selected_cats'] = array();
mp-wp_genesis 378
mp-wp_genesis 379 if ( is_array( $popular_cats ) )
mp-wp_genesis 380 $args['popular_cats'] = $popular_cats;
mp-wp_genesis 381 else
mp-wp_genesis 382 $args['popular_cats'] = get_terms( 'category', array( 'fields' => 'ids', 'orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false ) );
mp-wp_genesis 383
mp-wp_genesis 384 if ( $descendants_and_self ) {
mp-wp_genesis 385 $categories = get_categories( "child_of=$descendants_and_self&hierarchical=0&hide_empty=0" );
mp-wp_genesis 386 $self = get_category( $descendants_and_self );
mp-wp_genesis 387 array_unshift( $categories, $self );
mp-wp_genesis 388 } else {
mp-wp_genesis 389 $categories = get_categories('get=all');
mp-wp_genesis 390 }
mp-wp_genesis 391
mp-wp_genesis 392 // Post process $categories rather than adding an exclude to the get_terms() query to keep the query the same across all posts (for any query cache)
mp-wp_genesis 393 $checked_categories = array();
mp-wp_genesis 394 for ( $i = 0; isset($categories[$i]); $i++ ) {
mp-wp_genesis 395 if ( in_array($categories[$i]->term_id, $args['selected_cats']) ) {
mp-wp_genesis 396 $checked_categories[] = $categories[$i];
mp-wp_genesis 397 unset($categories[$i]);
mp-wp_genesis 398 }
mp-wp_genesis 399 }
mp-wp_genesis 400
mp-wp_genesis 401 // Put checked cats on top
mp-wp_genesis 402 echo call_user_func_array(array(&$walker, 'walk'), array($checked_categories, 0, $args));
mp-wp_genesis 403 // Then the rest of them
mp-wp_genesis 404 echo call_user_func_array(array(&$walker, 'walk'), array($categories, 0, $args));
mp-wp_genesis 405 }
mp-wp_genesis 406
mp-wp_genesis 407 /**
mp-wp_genesis 408 * {@internal Missing Short Description}}
mp-wp_genesis 409 *
mp-wp_genesis 410 * @since unknown
mp-wp_genesis 411 *
mp-wp_genesis 412 * @param unknown_type $taxonomy
mp-wp_genesis 413 * @param unknown_type $default
mp-wp_genesis 414 * @param unknown_type $number
mp-wp_genesis 415 * @param unknown_type $echo
mp-wp_genesis 416 * @return unknown
mp-wp_genesis 417 */
mp-wp_genesis 418 function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10, $echo = true ) {
mp-wp_genesis 419 global $post_ID;
mp-wp_genesis 420 if ( $post_ID )
mp-wp_genesis 421 $checked_categories = wp_get_post_categories($post_ID);
mp-wp_genesis 422 else
mp-wp_genesis 423 $checked_categories = array();
mp-wp_genesis 424 $categories = get_terms( $taxonomy, array( 'orderby' => 'count', 'order' => 'DESC', 'number' => $number, 'hierarchical' => false ) );
mp-wp_genesis 425
mp-wp_genesis 426 $popular_ids = array();
mp-wp_genesis 427 foreach ( (array) $categories as $category ) {
mp-wp_genesis 428 $popular_ids[] = $category->term_id;
mp-wp_genesis 429 if ( !$echo ) // hack for AJAX use
mp-wp_genesis 430 continue;
mp-wp_genesis 431 $id = "popular-category-$category->term_id";
mp-wp_genesis 432 ?>
mp-wp_genesis 433
mp-wp_genesis 434 <li id="<?php echo $id; ?>" class="popular-category">
mp-wp_genesis 435 <label class="selectit">
mp-wp_genesis 436 <input id="in-<?php echo $id; ?>" type="checkbox" value="<?php echo (int) $category->term_id; ?>" />
mp-wp_genesis 437 <?php echo wp_specialchars( apply_filters( 'the_category', $category->name ) ); ?>
mp-wp_genesis 438 </label>
mp-wp_genesis 439 </li>
mp-wp_genesis 440
mp-wp_genesis 441 <?php
mp-wp_genesis 442 }
mp-wp_genesis 443 return $popular_ids;
mp-wp_genesis 444 }
mp-wp_genesis 445
mp-wp_genesis 446 /**
mp-wp_genesis 447 * {@internal Missing Short Description}}
mp-wp_genesis 448 *
mp-wp_genesis 449 * @since unknown
mp-wp_genesis 450 * @deprecated Use {@link wp_link_category_checklist()}
mp-wp_genesis 451 * @see wp_link_category_checklist()
mp-wp_genesis 452 *
mp-wp_genesis 453 * @param unknown_type $default
mp-wp_genesis 454 */
mp-wp_genesis 455 function dropdown_link_categories( $default = 0 ) {
mp-wp_genesis 456 global $link_id;
mp-wp_genesis 457
mp-wp_genesis 458 wp_link_category_checklist($link_id);
mp-wp_genesis 459 }
mp-wp_genesis 460
mp-wp_genesis 461 /**
mp-wp_genesis 462 * {@internal Missing Short Description}}
mp-wp_genesis 463 *
mp-wp_genesis 464 * @since unknown
mp-wp_genesis 465 *
mp-wp_genesis 466 * @param unknown_type $link_id
mp-wp_genesis 467 */
mp-wp_genesis 468 function wp_link_category_checklist( $link_id = 0 ) {
mp-wp_genesis 469 $default = 1;
mp-wp_genesis 470
mp-wp_genesis 471 if ( $link_id ) {
mp-wp_genesis 472 $checked_categories = wp_get_link_cats($link_id);
mp-wp_genesis 473
mp-wp_genesis 474 if ( count( $checked_categories ) == 0 ) {
mp-wp_genesis 475 // No selected categories, strange
mp-wp_genesis 476 $checked_categories[] = $default;
mp-wp_genesis 477 }
mp-wp_genesis 478 } else {
mp-wp_genesis 479 $checked_categories[] = $default;
mp-wp_genesis 480 }
mp-wp_genesis 481
mp-wp_genesis 482 $categories = get_terms('link_category', 'orderby=count&hide_empty=0');
mp-wp_genesis 483
mp-wp_genesis 484 if ( empty($categories) )
mp-wp_genesis 485 return;
mp-wp_genesis 486
mp-wp_genesis 487 foreach ( $categories as $category ) {
mp-wp_genesis 488 $cat_id = $category->term_id;
mp-wp_genesis 489 $name = wp_specialchars( apply_filters('the_category', $category->name));
mp-wp_genesis 490 $checked = in_array( $cat_id, $checked_categories );
mp-wp_genesis 491 echo '<li id="link-category-', $cat_id, '"><label for="in-link-category-', $cat_id, '" class="selectit"><input value="', $cat_id, '" type="checkbox" name="link_category[]" id="in-link-category-', $cat_id, '"', ($checked ? ' checked="checked"' : "" ), '/> ', $name, "</label></li>";
mp-wp_genesis 492 }
mp-wp_genesis 493 }
mp-wp_genesis 494
mp-wp_genesis 495 // Tag stuff
mp-wp_genesis 496
mp-wp_genesis 497 // Returns a single tag row (see tag_rows below)
mp-wp_genesis 498 // Note: this is also used in admin-ajax.php!
mp-wp_genesis 499 /**
mp-wp_genesis 500 * {@internal Missing Short Description}}
mp-wp_genesis 501 *
mp-wp_genesis 502 * @since unknown
mp-wp_genesis 503 *
mp-wp_genesis 504 * @param unknown_type $tag
mp-wp_genesis 505 * @param unknown_type $class
mp-wp_genesis 506 * @return unknown
mp-wp_genesis 507 */
mp-wp_genesis 508 function _tag_row( $tag, $class = '' ) {
mp-wp_genesis 509 $count = number_format_i18n( $tag->count );
mp-wp_genesis 510 $count = ( $count > 0 ) ? "<a href='edit.php?tag=$tag->slug'>$count</a>" : $count;
mp-wp_genesis 511
mp-wp_genesis 512 $name = apply_filters( 'term_name', $tag->name );
mp-wp_genesis 513 $qe_data = get_term($tag->term_id, 'post_tag', object, 'edit');
mp-wp_genesis 514 $edit_link = "edit-tags.php?action=edit&amp;tag_ID=$tag->term_id";
mp-wp_genesis 515 $out = '';
mp-wp_genesis 516 $out .= '<tr id="tag-' . $tag->term_id . '"' . $class . '>';
mp-wp_genesis 517 $columns = get_column_headers('edit-tags');
mp-wp_genesis 518 $hidden = get_hidden_columns('edit-tags');
mp-wp_genesis 519 foreach ( $columns as $column_name => $column_display_name ) {
mp-wp_genesis 520 $class = "class=\"$column_name column-$column_name\"";
mp-wp_genesis 521
mp-wp_genesis 522 $style = '';
mp-wp_genesis 523 if ( in_array($column_name, $hidden) )
mp-wp_genesis 524 $style = ' style="display:none;"';
mp-wp_genesis 525
mp-wp_genesis 526 $attributes = "$class$style";
mp-wp_genesis 527
mp-wp_genesis 528 switch ($column_name) {
mp-wp_genesis 529 case 'cb':
mp-wp_remove-all-... 530 $out .= '<td scope="row" class="check-column"> <input type="checkbox" name="delete_tags[]" value="' . $tag->term_id . '" /></td>';
mp-wp_genesis 531 break;
mp-wp_genesis 532 case 'name':
mp-wp_genesis 533 $out .= '<td ' . $attributes . '><strong><a class="row-title" href="' . $edit_link . '" title="' . attribute_escape(sprintf(__('Edit "%s"'), $name)) . '">' . $name . '</a></strong><br />';
mp-wp_genesis 534 $actions = array();
mp-wp_genesis 535 $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
mp-wp_remove-all-... 536 $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("edit-tags.php?action=delete&amp;tag_ID=$tag->term_id", 'delete-tag_' . $tag->term_id) . "'>" . __('Delete') . "</a>";
mp-wp_genesis 537 $action_count = count($actions);
mp-wp_genesis 538 $i = 0;
mp-wp_genesis 539 $out .= '<div class="row-actions">';
mp-wp_genesis 540 foreach ( $actions as $action => $link ) {
mp-wp_genesis 541 ++$i;
mp-wp_genesis 542 ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
mp-wp_genesis 543 $out .= "<span class='$action'>$link$sep</span>";
mp-wp_genesis 544 }
mp-wp_genesis 545 $out .= '</div>';
mp-wp_genesis 546 $out .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">';
mp-wp_genesis 547 $out .= '<div class="name">' . $qe_data->name . '</div>';
mp-wp_genesis 548 $out .= '<div class="slug">' . $qe_data->slug . '</div></div></td>';
mp-wp_genesis 549 break;
mp-wp_genesis 550 case 'slug':
mp-wp_genesis 551 $out .= "<td $attributes>$tag->slug</td>";
mp-wp_genesis 552 break;
mp-wp_genesis 553 case 'posts':
mp-wp_genesis 554 $attributes = 'class="posts column-posts num"' . $style;
mp-wp_genesis 555 $out .= "<td $attributes>$count</td>";
mp-wp_genesis 556 break;
mp-wp_genesis 557 }
mp-wp_genesis 558 }
mp-wp_genesis 559
mp-wp_genesis 560 $out .= '</tr>';
mp-wp_genesis 561
mp-wp_genesis 562 return $out;
mp-wp_genesis 563 }
mp-wp_genesis 564
mp-wp_genesis 565 // Outputs appropriate rows for the Nth page of the Tag Management screen,
mp-wp_genesis 566 // assuming M tags displayed at a time on the page
mp-wp_genesis 567 // Returns the number of tags displayed
mp-wp_genesis 568 /**
mp-wp_genesis 569 * {@internal Missing Short Description}}
mp-wp_genesis 570 *
mp-wp_genesis 571 * @since unknown
mp-wp_genesis 572 *
mp-wp_genesis 573 * @param unknown_type $page
mp-wp_genesis 574 * @param unknown_type $pagesize
mp-wp_genesis 575 * @param unknown_type $searchterms
mp-wp_genesis 576 * @return unknown
mp-wp_genesis 577 */
mp-wp_genesis 578 function tag_rows( $page = 1, $pagesize = 20, $searchterms = '' ) {
mp-wp_genesis 579
mp-wp_genesis 580 // Get a page worth of tags
mp-wp_genesis 581 $start = ($page - 1) * $pagesize;
mp-wp_genesis 582
mp-wp_genesis 583 $args = array('offset' => $start, 'number' => $pagesize, 'hide_empty' => 0);
mp-wp_genesis 584
mp-wp_genesis 585 if ( !empty( $searchterms ) ) {
mp-wp_genesis 586 $args['search'] = $searchterms;
mp-wp_genesis 587 }
mp-wp_genesis 588
mp-wp_genesis 589 $tags = get_terms( 'post_tag', $args );
mp-wp_genesis 590
mp-wp_genesis 591 // convert it to table rows
mp-wp_genesis 592 $out = '';
mp-wp_genesis 593 $count = 0;
mp-wp_genesis 594 foreach( $tags as $tag )
mp-wp_genesis 595 $out .= _tag_row( $tag, ++$count % 2 ? ' class="iedit alternate"' : ' class="iedit"' );
mp-wp_genesis 596
mp-wp_genesis 597 // filter and send to screen
mp-wp_genesis 598 echo $out;
mp-wp_genesis 599 return $count;
mp-wp_genesis 600 }
mp-wp_genesis 601
mp-wp_genesis 602 // define the columns to display, the syntax is 'internal name' => 'display name'
mp-wp_genesis 603 /**
mp-wp_genesis 604 * {@internal Missing Short Description}}
mp-wp_genesis 605 *
mp-wp_genesis 606 * @since unknown
mp-wp_genesis 607 *
mp-wp_genesis 608 * @return unknown
mp-wp_genesis 609 */
mp-wp_genesis 610 function wp_manage_posts_columns() {
mp-wp_genesis 611 $posts_columns = array();
mp-wp_remove-all-... 612 $posts_columns['cb'] = '&nbsp;';
mp-wp_genesis 613 $posts_columns['title'] = _c('Post|noun');
mp-wp_genesis 614 $posts_columns['author'] = __('Author');
mp-wp_genesis 615 $posts_columns['categories'] = __('Categories');
mp-wp_genesis 616 $posts_columns['tags'] = __('Tags');
mp-wp_genesis 617 if ( !isset($_GET['post_status']) || !in_array($_GET['post_status'], array('pending', 'draft', 'future')) )
mp-wp_remove-all-... 618 $posts_columns['comments'] = '<div class="vers">Comments</div>';
mp-wp_genesis 619 $posts_columns['date'] = __('Date');
mp-wp_genesis 620 $posts_columns = apply_filters('manage_posts_columns', $posts_columns);
mp-wp_genesis 621
mp-wp_genesis 622 return $posts_columns;
mp-wp_genesis 623 }
mp-wp_genesis 624
mp-wp_genesis 625 // define the columns to display, the syntax is 'internal name' => 'display name'
mp-wp_genesis 626 /**
mp-wp_genesis 627 * {@internal Missing Short Description}}
mp-wp_genesis 628 *
mp-wp_genesis 629 * @since unknown
mp-wp_genesis 630 *
mp-wp_genesis 631 * @return unknown
mp-wp_genesis 632 */
mp-wp_genesis 633 function wp_manage_media_columns() {
mp-wp_genesis 634 $posts_columns = array();
mp-wp_remove-all-... 635 $posts_columns['cb'] = '&nbsp;';
mp-wp_genesis 636 $posts_columns['icon'] = '';
mp-wp_genesis 637 $posts_columns['media'] = _c('File|media column header');
mp-wp_genesis 638 $posts_columns['author'] = __('Author');
mp-wp_remove-all-... 639 $posts_columns['comments'] = '<div class="vers">Comments</div>';
mp-wp_genesis 640 $posts_columns['date'] = _c('Date|media column header');
mp-wp_genesis 641 $posts_columns = apply_filters('manage_media_columns', $posts_columns);
mp-wp_genesis 642
mp-wp_genesis 643 return $posts_columns;
mp-wp_genesis 644 }
mp-wp_genesis 645
mp-wp_genesis 646 /**
mp-wp_genesis 647 * {@internal Missing Short Description}}
mp-wp_genesis 648 *
mp-wp_genesis 649 * @since unknown
mp-wp_genesis 650 *
mp-wp_genesis 651 * @return unknown
mp-wp_genesis 652 */
mp-wp_genesis 653 function wp_manage_pages_columns() {
mp-wp_genesis 654 $posts_columns = array();
mp-wp_remove-all-... 655 $posts_columns['cb'] = '&nbsp;';
mp-wp_genesis 656 $posts_columns['title'] = __('Title');
mp-wp_genesis 657 $posts_columns['author'] = __('Author');
mp-wp_genesis 658 $post_status = 'all';
mp-wp_genesis 659 if ( !empty($_GET['post_status']) )
mp-wp_genesis 660 $post_status = $_GET['post_status'];
mp-wp_genesis 661 if ( !in_array($post_status, array('pending', 'draft', 'future')) )
mp-wp_remove-all-... 662 $posts_columns['comments'] = '<div class="vers">Comments</div>';
mp-wp_genesis 663 $posts_columns['date'] = __('Date');
mp-wp_genesis 664 $posts_columns = apply_filters('manage_pages_columns', $posts_columns);
mp-wp_genesis 665
mp-wp_genesis 666 return $posts_columns;
mp-wp_genesis 667 }
mp-wp_genesis 668
mp-wp_genesis 669 /**
mp-wp_genesis 670 * {@internal Missing Short Description}}
mp-wp_genesis 671 *
mp-wp_genesis 672 * @since unknown
mp-wp_genesis 673 *
mp-wp_genesis 674 * @param unknown_type $page
mp-wp_genesis 675 * @return unknown
mp-wp_genesis 676 */
mp-wp_genesis 677 function get_column_headers($page) {
mp-wp_genesis 678 global $_wp_column_headers;
mp-wp_genesis 679
mp-wp_genesis 680 if ( !isset($_wp_column_headers) )
mp-wp_genesis 681 $_wp_column_headers = array();
mp-wp_genesis 682
mp-wp_genesis 683 // Store in static to avoid running filters on each call
mp-wp_genesis 684 if ( isset($_wp_column_headers[$page]) )
mp-wp_genesis 685 return $_wp_column_headers[$page];
mp-wp_genesis 686
mp-wp_genesis 687 switch ($page) {
mp-wp_genesis 688 case 'edit':
mp-wp_genesis 689 $_wp_column_headers[$page] = wp_manage_posts_columns();
mp-wp_genesis 690 break;
mp-wp_genesis 691 case 'edit-pages':
mp-wp_genesis 692 $_wp_column_headers[$page] = wp_manage_pages_columns();
mp-wp_genesis 693 break;
mp-wp_genesis 694 case 'edit-comments':
mp-wp_genesis 695 $_wp_column_headers[$page] = array(
mp-wp_remove-all-... 696 'cb' => '&nbsp;',
mp-wp_genesis 697 'author' => __('Author'),
mp-wp_genesis 698 'comment' => _c('Comment|noun'),
mp-wp_genesis 699 //'date' => __('Submitted'),
mp-wp_genesis 700 'response' => __('In Response To')
mp-wp_genesis 701 );
mp-wp_genesis 702
mp-wp_genesis 703 break;
mp-wp_genesis 704 case 'link-manager':
mp-wp_genesis 705 $_wp_column_headers[$page] = array(
mp-wp_remove-all-... 706 'cb' => '&nbsp;',
mp-wp_genesis 707 'name' => __('Name'),
mp-wp_genesis 708 'url' => __('URL'),
mp-wp_genesis 709 'categories' => __('Categories'),
mp-wp_genesis 710 'rel' => __('rel'),
mp-wp_genesis 711 'visible' => __('Visible')
mp-wp_genesis 712 );
mp-wp_genesis 713
mp-wp_genesis 714 break;
mp-wp_genesis 715 case 'upload':
mp-wp_genesis 716 $_wp_column_headers[$page] = wp_manage_media_columns();
mp-wp_genesis 717 break;
mp-wp_genesis 718 case 'categories':
mp-wp_genesis 719 $_wp_column_headers[$page] = array(
mp-wp_remove-all-... 720 'cb' => '&nbsp;',
mp-wp_genesis 721 'name' => __('Name'),
mp-wp_genesis 722 'description' => __('Description'),
mp-wp_genesis 723 'slug' => __('Slug'),
mp-wp_genesis 724 'posts' => __('Posts')
mp-wp_genesis 725 );
mp-wp_genesis 726
mp-wp_genesis 727 break;
mp-wp_genesis 728 case 'edit-link-categories':
mp-wp_genesis 729 $_wp_column_headers[$page] = array(
mp-wp_remove-all-... 730 'cb' => '&nbsp;',
mp-wp_genesis 731 'name' => __('Name'),
mp-wp_genesis 732 'description' => __('Description'),
mp-wp_genesis 733 'slug' => __('Slug'),
mp-wp_genesis 734 'links' => __('Links')
mp-wp_genesis 735 );
mp-wp_genesis 736
mp-wp_genesis 737 break;
mp-wp_genesis 738 case 'edit-tags':
mp-wp_genesis 739 $_wp_column_headers[$page] = array(
mp-wp_remove-all-... 740 'cb' => '&nbsp;',
mp-wp_genesis 741 'name' => __('Name'),
mp-wp_genesis 742 'slug' => __('Slug'),
mp-wp_genesis 743 'posts' => __('Posts')
mp-wp_genesis 744 );
mp-wp_genesis 745
mp-wp_genesis 746 break;
mp-wp_genesis 747 case 'users':
mp-wp_genesis 748 $_wp_column_headers[$page] = array(
mp-wp_remove-all-... 749 'cb' => '&nbsp;',
mp-wp_genesis 750 'username' => __('Username'),
mp-wp_genesis 751 'name' => __('Name'),
mp-wp_genesis 752 'email' => __('E-mail'),
mp-wp_genesis 753 'role' => __('Role'),
mp-wp_genesis 754 'posts' => __('Posts')
mp-wp_genesis 755 );
mp-wp_genesis 756 break;
mp-wp_genesis 757 default :
mp-wp_genesis 758 $_wp_column_headers[$page] = array();
mp-wp_genesis 759 }
mp-wp_genesis 760
mp-wp_genesis 761 $_wp_column_headers[$page] = apply_filters('manage_' . $page . '_columns', $_wp_column_headers[$page]);
mp-wp_genesis 762 return $_wp_column_headers[$page];
mp-wp_genesis 763 }
mp-wp_genesis 764
mp-wp_genesis 765 /**
mp-wp_genesis 766 * {@internal Missing Short Description}}
mp-wp_genesis 767 *
mp-wp_genesis 768 * @since unknown
mp-wp_genesis 769 *
mp-wp_genesis 770 * @param unknown_type $type
mp-wp_genesis 771 * @param unknown_type $id
mp-wp_genesis 772 */
mp-wp_genesis 773 function print_column_headers( $type, $id = true ) {
mp-wp_genesis 774 $type = str_replace('.php', '', $type);
mp-wp_genesis 775 $columns = get_column_headers( $type );
mp-wp_genesis 776 $hidden = get_hidden_columns($type);
mp-wp_genesis 777 $styles = array();
mp-wp_genesis 778 // $styles['tag']['posts'] = 'width: 90px;';
mp-wp_genesis 779 // $styles['link-category']['links'] = 'width: 90px;';
mp-wp_genesis 780 // $styles['category']['posts'] = 'width: 90px;';
mp-wp_genesis 781 // $styles['link']['visible'] = 'text-align: center;';
mp-wp_genesis 782
mp-wp_genesis 783 foreach ( $columns as $column_key => $column_display_name ) {
mp-wp_genesis 784 $class = ' class="manage-column';
mp-wp_genesis 785
mp-wp_genesis 786 $class .= " column-$column_key";
mp-wp_genesis 787
mp-wp_genesis 788 if ( 'cb' == $column_key )
mp-wp_genesis 789 $class .= ' check-column';
mp-wp_genesis 790 elseif ( in_array($column_key, array('posts', 'comments', 'links')) )
mp-wp_genesis 791 $class .= ' num';
mp-wp_genesis 792
mp-wp_genesis 793 $class .= '"';
mp-wp_genesis 794
mp-wp_genesis 795 $style = '';
mp-wp_genesis 796 if ( in_array($column_key, $hidden) )
mp-wp_genesis 797 $style = 'display:none;';
mp-wp_genesis 798
mp-wp_genesis 799 if ( isset($styles[$type]) && isset($styles[$type][$column_key]) )
mp-wp_genesis 800 $style .= ' ' . $styles[$type][$column_key];
mp-wp_genesis 801 $style = ' style="' . $style . '"';
mp-wp_genesis 802 ?>
mp-wp_genesis 803 <th scope="col" <?php echo $id ? "id=\"$column_key\"" : ""; echo $class; echo $style; ?>><?php echo $column_display_name; ?></th>
mp-wp_genesis 804 <?php }
mp-wp_genesis 805 }
mp-wp_genesis 806
mp-wp_genesis 807 /**
mp-wp_genesis 808 * Register column headers for a particular screen. The header names will be listed in the Screen Options.
mp-wp_genesis 809 *
mp-wp_genesis 810 * @since 2.7.0
mp-wp_genesis 811 *
mp-wp_genesis 812 * @param string $screen The handle for the screen to add help to. This is usually the hook name returned by the add_*_page() functions.
mp-wp_genesis 813 * @param array $columns An array of columns with column IDs as the keys and translated column names as the values
mp-wp_genesis 814 * @see get_column_headers(), print_column_headers(), get_hidden_columns()
mp-wp_genesis 815 */
mp-wp_genesis 816 function register_column_headers($screen, $columns) {
mp-wp_genesis 817 global $_wp_column_headers;
mp-wp_genesis 818
mp-wp_genesis 819 if ( !isset($_wp_column_headers) )
mp-wp_genesis 820 $_wp_column_headers = array();
mp-wp_genesis 821
mp-wp_genesis 822 $_wp_column_headers[$screen] = $columns;
mp-wp_genesis 823 }
mp-wp_genesis 824
mp-wp_genesis 825 /**
mp-wp_genesis 826 * {@internal Missing Short Description}}
mp-wp_genesis 827 *
mp-wp_genesis 828 * @since unknown
mp-wp_genesis 829 *
mp-wp_genesis 830 * @param unknown_type $page
mp-wp_genesis 831 */
mp-wp_genesis 832 function get_hidden_columns($page) {
mp-wp_genesis 833 $page = str_replace('.php', '', $page);
mp-wp_genesis 834 return (array) get_user_option( 'manage-' . $page . '-columns-hidden', 0, false );
mp-wp_genesis 835 }
mp-wp_genesis 836
mp-wp_genesis 837
mp-wp_genesis 838 // adds hidden fields with the data for use in the inline editor for posts and pages
mp-wp_genesis 839 /**
mp-wp_genesis 840 * {@internal Missing Short Description}}
mp-wp_genesis 841 *
mp-wp_genesis 842 * @since unknown
mp-wp_genesis 843 *
mp-wp_genesis 844 * @param unknown_type $post
mp-wp_genesis 845 */
mp-wp_genesis 846 function get_inline_data($post) {
mp-wp_genesis 847
mp-wp_genesis 848 if ( ! current_user_can('edit_' . $post->post_type, $post->ID) )
mp-wp_genesis 849 return;
mp-wp_genesis 850
mp-wp_genesis 851 $title = attribute_escape($post->post_title);
mp-wp_genesis 852
mp-wp_genesis 853 echo '
mp-wp_genesis 854 <div class="hidden" id="inline_' . $post->ID . '">
mp-wp_genesis 855 <div class="post_title">' . $title . '</div>
mp-wp_genesis 856 <div class="post_name">' . $post->post_name . '</div>
mp-wp_genesis 857 <div class="post_author">' . $post->post_author . '</div>
mp-wp_genesis 858 <div class="comment_status">' . $post->comment_status . '</div>
mp-wp_genesis 859 <div class="ping_status">' . $post->ping_status . '</div>
mp-wp_genesis 860 <div class="_status">' . $post->post_status . '</div>
mp-wp_genesis 861 <div class="jj">' . mysql2date( 'd', $post->post_date ) . '</div>
mp-wp_genesis 862 <div class="mm">' . mysql2date( 'm', $post->post_date ) . '</div>
mp-wp_genesis 863 <div class="aa">' . mysql2date( 'Y', $post->post_date ) . '</div>
mp-wp_genesis 864 <div class="hh">' . mysql2date( 'H', $post->post_date ) . '</div>
mp-wp_genesis 865 <div class="mn">' . mysql2date( 'i', $post->post_date ) . '</div>
mp-wp_genesis 866 <div class="ss">' . mysql2date( 's', $post->post_date ) . '</div>
mp-wp_genesis 867 <div class="post_password">' . wp_specialchars($post->post_password, 1) . '</div>';
mp-wp_genesis 868
mp-wp_genesis 869 if( $post->post_type == 'page' )
mp-wp_genesis 870 echo '
mp-wp_genesis 871 <div class="post_parent">' . $post->post_parent . '</div>
mp-wp_genesis 872 <div class="page_template">' . wp_specialchars(get_post_meta( $post->ID, '_wp_page_template', true ), 1) . '</div>
mp-wp_genesis 873 <div class="menu_order">' . $post->menu_order . '</div>';
mp-wp_genesis 874
mp-wp_genesis 875 if( $post->post_type == 'post' )
mp-wp_genesis 876 echo '
mp-wp_genesis 877 <div class="tags_input">' . wp_specialchars( str_replace( ',', ', ', get_tags_to_edit($post->ID) ), 1) . '</div>
mp-wp_genesis 878 <div class="post_category">' . implode( ',', wp_get_post_categories( $post->ID ) ) . '</div>
mp-wp_genesis 879 <div class="sticky">' . (is_sticky($post->ID) ? 'sticky' : '') . '</div>';
mp-wp_genesis 880
mp-wp_genesis 881 echo '</div>';
mp-wp_genesis 882 }
mp-wp_genesis 883
mp-wp_genesis 884 /**
mp-wp_genesis 885 * {@internal Missing Short Description}}
mp-wp_genesis 886 *
mp-wp_genesis 887 * @since unknown
mp-wp_genesis 888 *
mp-wp_genesis 889 * @param unknown_type $posts
mp-wp_genesis 890 */
mp-wp_genesis 891 function post_rows( $posts = array() ) {
mp-wp_genesis 892 global $wp_query, $post, $mode;
mp-wp_genesis 893
mp-wp_genesis 894 add_filter('the_title','wp_specialchars');
mp-wp_genesis 895
mp-wp_genesis 896 // Create array of post IDs.
mp-wp_genesis 897 $post_ids = array();
mp-wp_genesis 898
mp-wp_genesis 899 if ( empty($posts) )
mp-wp_genesis 900 $posts = &$wp_query->posts;
mp-wp_genesis 901
mp-wp_genesis 902 foreach ( $posts as $a_post )
mp-wp_genesis 903 $post_ids[] = $a_post->ID;
mp-wp_genesis 904
mp-wp_genesis 905 $comment_pending_count = get_pending_comments_num($post_ids);
mp-wp_genesis 906 if ( empty($comment_pending_count) )
mp-wp_genesis 907 $comment_pending_count = array();
mp-wp_genesis 908
mp-wp_genesis 909 foreach ( $posts as $post ) {
mp-wp_genesis 910 if ( empty($comment_pending_count[$post->ID]) )
mp-wp_genesis 911 $comment_pending_count[$post->ID] = 0;
mp-wp_genesis 912
mp-wp_genesis 913 _post_row($post, $comment_pending_count[$post->ID], $mode);
mp-wp_genesis 914 }
mp-wp_genesis 915 }
mp-wp_genesis 916
mp-wp_genesis 917 /**
mp-wp_genesis 918 * {@internal Missing Short Description}}
mp-wp_genesis 919 *
mp-wp_genesis 920 * @since unknown
mp-wp_genesis 921 *
mp-wp_genesis 922 * @param unknown_type $a_post
mp-wp_genesis 923 * @param unknown_type $pending_comments
mp-wp_genesis 924 * @param unknown_type $mode
mp-wp_genesis 925 */
mp-wp_genesis 926 function _post_row($a_post, $pending_comments, $mode) {
mp-wp_genesis 927 global $post;
mp-wp_genesis 928 static $rowclass;
mp-wp_genesis 929
mp-wp_genesis 930 $global_post = $post;
mp-wp_genesis 931 $post = $a_post;
mp-wp_genesis 932 setup_postdata($post);
mp-wp_genesis 933
mp-wp_genesis 934 $rowclass = 'alternate' == $rowclass ? '' : 'alternate';
mp-wp_genesis 935 global $current_user;
mp-wp_genesis 936 $post_owner = ( $current_user->ID == $post->post_author ? 'self' : 'other' );
mp-wp_genesis 937 $edit_link = get_edit_post_link( $post->ID );
mp-wp_genesis 938 $title = _draft_or_post_title();
mp-wp_genesis 939 ?>
mp-wp_genesis 940 <tr id='post-<?php echo $post->ID; ?>' class='<?php echo trim( $rowclass . ' author-' . $post_owner . ' status-' . $post->post_status ); ?> iedit' valign="top">
mp-wp_genesis 941 <?php
mp-wp_genesis 942 $posts_columns = get_column_headers('edit');
mp-wp_genesis 943 $hidden = get_hidden_columns('edit');
mp-wp_genesis 944 foreach ( $posts_columns as $column_name=>$column_display_name ) {
mp-wp_genesis 945 $class = "class=\"$column_name column-$column_name\"";
mp-wp_genesis 946
mp-wp_genesis 947 $style = '';
mp-wp_genesis 948 if ( in_array($column_name, $hidden) )
mp-wp_genesis 949 $style = ' style="display:none;"';
mp-wp_genesis 950
mp-wp_genesis 951 $attributes = "$class$style";
mp-wp_genesis 952
mp-wp_genesis 953 switch ($column_name) {
mp-wp_genesis 954
mp-wp_genesis 955 case 'cb':
mp-wp_genesis 956 ?>
mp-wp_remove-all-... 957 <td scope="row" class="check-column"><?php if ( current_user_can( 'edit_post', $post->ID ) ) { ?><input type="checkbox" name="post[]" value="<?php the_ID(); ?>" /><?php } ?></td>
mp-wp_genesis 958 <?php
mp-wp_genesis 959 break;
mp-wp_genesis 960
mp-wp_genesis 961 case 'date':
mp-wp_genesis 962 if ( '0000-00-00 00:00:00' == $post->post_date && 'date' == $column_name ) {
mp-wp_genesis 963 $t_time = $h_time = __('Unpublished');
mp-wp_genesis 964 } else {
mp-wp_genesis 965 $t_time = get_the_time(__('Y/m/d g:i:s A'));
mp-wp_genesis 966 $m_time = $post->post_date;
mp-wp_genesis 967 $time = get_post_time('G', true, $post);
mp-wp_genesis 968
mp-wp_genesis 969 $time_diff = time() - $time;
mp-wp_genesis 970
mp-wp_genesis 971 if ( ( 'future' == $post->post_status) ) {
mp-wp_genesis 972 if ( $time_diff <= 0 ) {
mp-wp_genesis 973 $h_time = sprintf( __('%s from now'), human_time_diff( $time ) );
mp-wp_genesis 974 } else {
mp-wp_genesis 975 $h_time = $t_time;
mp-wp_genesis 976 $missed = true;
mp-wp_genesis 977 }
mp-wp_genesis 978 } else {
mp-wp_genesis 979
mp-wp_genesis 980 if ( $time_diff > 0 && $time_diff < 24*60*60 )
mp-wp_genesis 981 $h_time = sprintf( __('%s ago'), human_time_diff( $time ) );
mp-wp_genesis 982 else
mp-wp_genesis 983 $h_time = mysql2date(__('Y/m/d'), $m_time);
mp-wp_genesis 984 }
mp-wp_genesis 985 }
mp-wp_genesis 986
mp-wp_genesis 987 echo '<td ' . $attributes . '>';
mp-wp_genesis 988 if ( 'excerpt' == $mode )
mp-wp_genesis 989 echo apply_filters('post_date_column_time', $t_time, $post, $column_name, $mode);
mp-wp_genesis 990 else
mp-wp_genesis 991 echo '<abbr title="' . $t_time . '">' . apply_filters('post_date_column_time', $h_time, $post, $column_name, $mode) . '</abbr>';
mp-wp_genesis 992 echo '<br />';
mp-wp_genesis 993 if ( 'publish' == $post->post_status ) {
mp-wp_genesis 994 _e('Published');
mp-wp_genesis 995 } elseif ( 'future' == $post->post_status ) {
mp-wp_genesis 996 if ( isset($missed) )
mp-wp_genesis 997 echo '<strong class="attention">' . __('Missed schedule') . '</strong>';
mp-wp_genesis 998 else
mp-wp_genesis 999 _e('Scheduled');
mp-wp_genesis 1000 } else {
mp-wp_genesis 1001 _e('Last Modified');
mp-wp_genesis 1002 }
mp-wp_genesis 1003 echo '</td>';
mp-wp_genesis 1004 break;
mp-wp_genesis 1005
mp-wp_genesis 1006 case 'title':
mp-wp_genesis 1007 $attributes = 'class="post-title column-title"' . $style;
mp-wp_genesis 1008 ?>
mp-wp_genesis 1009 <td <?php echo $attributes ?>><strong><?php if ( current_user_can( 'edit_post', $post->ID ) ) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo attribute_escape(sprintf(__('Edit "%s"'), $title)); ?>"><?php echo $title ?></a><?php } else { echo $title; }; _post_states($post); ?></strong>
mp-wp_genesis 1010 <?php
mp-wp_genesis 1011 if ( 'excerpt' == $mode )
mp-wp_genesis 1012 the_excerpt();
mp-wp_genesis 1013
mp-wp_genesis 1014 $actions = array();
mp-wp_genesis 1015 if ( current_user_can('edit_post', $post->ID) ) {
mp-wp_genesis 1016 $actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '" title="' . attribute_escape(__('Edit this post')) . '">' . __('Edit') . '</a>';
mp-wp_genesis 1017 }
mp-wp_genesis 1018 if ( in_array($post->post_status, array('pending', 'draft')) ) {
mp-wp_genesis 1019 if ( current_user_can('edit_post', $post->ID) )
mp-wp_genesis 1020 $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . attribute_escape(sprintf(__('Preview "%s"'), $title)) . '" rel="permalink">' . __('Preview') . '</a>';
mp-wp_genesis 1021 } else {
mp-wp_genesis 1022 $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . attribute_escape(sprintf(__('View "%s"'), $title)) . '" rel="permalink">' . __('View') . '</a>';
mp-wp_genesis 1023 }
mp-wp_genesis 1024 $action_count = count($actions);
mp-wp_genesis 1025 $i = 0;
mp-wp_genesis 1026 echo '<div class="row-actions">';
mp-wp_genesis 1027 foreach ( $actions as $action => $link ) {
mp-wp_genesis 1028 ++$i;
mp-wp_genesis 1029 ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
mp-wp_genesis 1030 echo "<span class='$action'>$link$sep</span>";
mp-wp_genesis 1031 }
mp-wp_genesis 1032 echo '</div>';
mp-wp_genesis 1033
mp-wp_genesis 1034 get_inline_data($post);
mp-wp_genesis 1035 ?>
mp-wp_genesis 1036 </td>
mp-wp_genesis 1037 <?php
mp-wp_genesis 1038 break;
mp-wp_genesis 1039
mp-wp_genesis 1040 case 'categories':
mp-wp_genesis 1041 ?>
mp-wp_genesis 1042 <td <?php echo $attributes ?>><?php
mp-wp_genesis 1043 $categories = get_the_category();
mp-wp_genesis 1044 if ( !empty( $categories ) ) {
mp-wp_genesis 1045 $out = array();
mp-wp_genesis 1046 foreach ( $categories as $c )
mp-wp_genesis 1047 $out[] = "<a href='edit.php?category_name=$c->slug'> " . wp_specialchars(sanitize_term_field('name', $c->name, $c->term_id, 'category', 'display')) . "</a>";
mp-wp_genesis 1048 echo join( ', ', $out );
mp-wp_genesis 1049 } else {
mp-wp_genesis 1050 _e('Uncategorized');
mp-wp_genesis 1051 }
mp-wp_genesis 1052 ?></td>
mp-wp_genesis 1053 <?php
mp-wp_genesis 1054 break;
mp-wp_genesis 1055
mp-wp_genesis 1056 case 'tags':
mp-wp_genesis 1057 ?>
mp-wp_genesis 1058 <td <?php echo $attributes ?>><?php
mp-wp_genesis 1059 $tags = get_the_tags($post->ID);
mp-wp_genesis 1060 if ( !empty( $tags ) ) {
mp-wp_genesis 1061 $out = array();
mp-wp_genesis 1062 foreach ( $tags as $c )
mp-wp_genesis 1063 $out[] = "<a href='edit.php?tag=$c->slug'> " . wp_specialchars(sanitize_term_field('name', $c->name, $c->term_id, 'post_tag', 'display')) . "</a>";
mp-wp_genesis 1064 echo join( ', ', $out );
mp-wp_genesis 1065 } else {
mp-wp_genesis 1066 _e('No Tags');
mp-wp_genesis 1067 }
mp-wp_genesis 1068 ?></td>
mp-wp_genesis 1069 <?php
mp-wp_genesis 1070 break;
mp-wp_genesis 1071
mp-wp_genesis 1072 case 'comments':
mp-wp_genesis 1073 ?>
mp-wp_genesis 1074 <td <?php echo $attributes ?>><div class="post-com-count-wrapper">
mp-wp_genesis 1075 <?php
mp-wp_genesis 1076 $pending_phrase = sprintf( __('%s pending'), number_format( $pending_comments ) );
mp-wp_genesis 1077 if ( $pending_comments )
mp-wp_genesis 1078 echo '<strong>';
mp-wp_genesis 1079 comments_number("<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('0') . '</span></a>', "<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('1') . '</span></a>', "<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('%') . '</span></a>');
mp-wp_genesis 1080 if ( $pending_comments )
mp-wp_genesis 1081 echo '</strong>';
mp-wp_genesis 1082 ?>
mp-wp_genesis 1083 </div></td>
mp-wp_genesis 1084 <?php
mp-wp_genesis 1085 break;
mp-wp_genesis 1086
mp-wp_genesis 1087 case 'author':
mp-wp_genesis 1088 ?>
mp-wp_genesis 1089 <td <?php echo $attributes ?>><a href="edit.php?author=<?php the_author_ID(); ?>"><?php the_author() ?></a></td>
mp-wp_genesis 1090 <?php
mp-wp_genesis 1091 break;
mp-wp_genesis 1092
mp-wp_genesis 1093 case 'control_view':
mp-wp_genesis 1094 ?>
mp-wp_genesis 1095 <td><a href="<?php the_permalink(); ?>" rel="permalink" class="view"><?php _e('View'); ?></a></td>
mp-wp_genesis 1096 <?php
mp-wp_genesis 1097 break;
mp-wp_genesis 1098
mp-wp_genesis 1099 case 'control_edit':
mp-wp_genesis 1100 ?>
mp-wp_genesis 1101 <td><?php if ( current_user_can('edit_post', $post->ID) ) { echo "<a href='$edit_link' class='edit'>" . __('Edit') . "</a>"; } ?></td>
mp-wp_genesis 1102 <?php
mp-wp_genesis 1103 break;
mp-wp_genesis 1104
mp-wp_genesis 1105 case 'control_delete':
mp-wp_genesis 1106 ?>
mp-wp_genesis 1107 <td><?php if ( current_user_can('delete_post', $post->ID) ) { echo "<a href='" . wp_nonce_url("post.php?action=delete&amp;post=$id", 'delete-post_' . $post->ID) . "' class='delete'>" . __('Delete') . "</a>"; } ?></td>
mp-wp_genesis 1108 <?php
mp-wp_genesis 1109 break;
mp-wp_genesis 1110
mp-wp_genesis 1111 default:
mp-wp_genesis 1112 ?>
mp-wp_genesis 1113 <td <?php echo $attributes ?>><?php do_action('manage_posts_custom_column', $column_name, $post->ID); ?></td>
mp-wp_genesis 1114 <?php
mp-wp_genesis 1115 break;
mp-wp_genesis 1116 }
mp-wp_genesis 1117 }
mp-wp_genesis 1118 ?>
mp-wp_genesis 1119 </tr>
mp-wp_genesis 1120 <?php
mp-wp_genesis 1121 $post = $global_post;
mp-wp_genesis 1122 }
mp-wp_genesis 1123
mp-wp_genesis 1124 /*
mp-wp_genesis 1125 * display one row if the page doesn't have any children
mp-wp_genesis 1126 * otherwise, display the row and its children in subsequent rows
mp-wp_genesis 1127 */
mp-wp_genesis 1128 /**
mp-wp_genesis 1129 * {@internal Missing Short Description}}
mp-wp_genesis 1130 *
mp-wp_genesis 1131 * @since unknown
mp-wp_genesis 1132 *
mp-wp_genesis 1133 * @param unknown_type $page
mp-wp_genesis 1134 * @param unknown_type $level
mp-wp_genesis 1135 */
mp-wp_genesis 1136 function display_page_row( $page, $level = 0 ) {
mp-wp_genesis 1137 global $post;
mp-wp_genesis 1138 static $rowclass;
mp-wp_genesis 1139
mp-wp_genesis 1140 $post = $page;
mp-wp_genesis 1141 setup_postdata($page);
mp-wp_genesis 1142
mp-wp_genesis 1143 $page->post_title = wp_specialchars( $page->post_title );
mp-wp_genesis 1144 $pad = str_repeat( '&#8212; ', $level );
mp-wp_genesis 1145 $id = (int) $page->ID;
mp-wp_genesis 1146 $rowclass = 'alternate' == $rowclass ? '' : 'alternate';
mp-wp_genesis 1147 $posts_columns = get_column_headers('edit-pages');
mp-wp_genesis 1148 $hidden = get_hidden_columns('edit-pages');
mp-wp_genesis 1149 $title = _draft_or_post_title();
mp-wp_genesis 1150 ?>
mp-wp_genesis 1151 <tr id="page-<?php echo $id; ?>" class="<?php echo $rowclass; ?> iedit">
mp-wp_genesis 1152 <?php
mp-wp_genesis 1153
mp-wp_genesis 1154 foreach ($posts_columns as $column_name=>$column_display_name) {
mp-wp_genesis 1155 $class = "class=\"$column_name column-$column_name\"";
mp-wp_genesis 1156
mp-wp_genesis 1157 $style = '';
mp-wp_genesis 1158 if ( in_array($column_name, $hidden) )
mp-wp_genesis 1159 $style = ' style="display:none;"';
mp-wp_genesis 1160
mp-wp_genesis 1161 $attributes = "$class$style";
mp-wp_genesis 1162
mp-wp_genesis 1163 switch ($column_name) {
mp-wp_genesis 1164
mp-wp_genesis 1165 case 'cb':
mp-wp_genesis 1166 ?>
mp-wp_remove-all-... 1167 <td scope="row" class="check-column"><input type="checkbox" name="post[]" value="<?php the_ID(); ?>" /></td>
mp-wp_genesis 1168 <?php
mp-wp_genesis 1169 break;
mp-wp_genesis 1170 case 'date':
mp-wp_genesis 1171 if ( '0000-00-00 00:00:00' == $page->post_date && 'date' == $column_name ) {
mp-wp_genesis 1172 $t_time = $h_time = __('Unpublished');
mp-wp_genesis 1173 } else {
mp-wp_genesis 1174 $t_time = get_the_time(__('Y/m/d g:i:s A'));
mp-wp_genesis 1175 $m_time = $page->post_date;
mp-wp_genesis 1176 $time = get_post_time('G', true);
mp-wp_genesis 1177
mp-wp_genesis 1178 if ( ( abs(time() - $time) ) < 86400 ) {
mp-wp_genesis 1179 if ( ( 'future' == $page->post_status) )
mp-wp_genesis 1180 $h_time = sprintf( __('%s from now'), human_time_diff( $time ) );
mp-wp_genesis 1181 else
mp-wp_genesis 1182 $h_time = sprintf( __('%s ago'), human_time_diff( $time ) );
mp-wp_genesis 1183 } else {
mp-wp_genesis 1184 $h_time = mysql2date(__('Y/m/d'), $m_time);
mp-wp_genesis 1185 }
mp-wp_genesis 1186 }
mp-wp_genesis 1187 echo '<td ' . $attributes . '>';
mp-wp_genesis 1188 echo '<abbr title="' . $t_time . '">' . apply_filters('post_date_column_time', $h_time, $page, $column_name, '') . '</abbr>';
mp-wp_genesis 1189 echo '<br />';
mp-wp_genesis 1190 if ( 'publish' == $page->post_status || 'future' == $page->post_status )
mp-wp_genesis 1191 _e('Published');
mp-wp_genesis 1192 else
mp-wp_genesis 1193 _e('Last Modified');
mp-wp_genesis 1194 echo '</td>';
mp-wp_genesis 1195 break;
mp-wp_genesis 1196 case 'title':
mp-wp_genesis 1197 $attributes = 'class="post-title page-title column-title"' . $style;
mp-wp_genesis 1198 $edit_link = get_edit_post_link( $page->ID );
mp-wp_genesis 1199 ?>
mp-wp_genesis 1200 <td <?php echo $attributes ?>><strong><?php if ( current_user_can( 'edit_post', $page->ID ) ) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo attribute_escape(sprintf(__('Edit "%s"'), $title)); ?>"><?php echo $pad; echo $title ?></a><?php } else { echo $pad; echo $title; }; _post_states($page); ?></strong>
mp-wp_genesis 1201 <?php
mp-wp_genesis 1202 $actions = array();
mp-wp_genesis 1203 if ( current_user_can('edit_page', $page->ID) ) {
mp-wp_genesis 1204 $actions['edit'] = '<a href="' . $edit_link . '" title="' . attribute_escape(__('Edit this page')) . '">' . __('Edit') . '</a>';
mp-wp_remove-all-... 1205 $actions['delete'] = "<a class='submitdelete' title='" . attribute_escape(__('Delete this page')) . "' href='" . wp_nonce_url("page.php?action=delete&amp;post=$page->ID", 'delete-page_' . $page->ID) . "'>" . __('Delete') . "</a>";
mp-wp_genesis 1206 }
mp-wp_genesis 1207 if ( in_array($post->post_status, array('pending', 'draft')) ) {
mp-wp_genesis 1208 if ( current_user_can('edit_page', $page->ID) )
mp-wp_genesis 1209 $actions['view'] = '<a href="' . get_permalink($page->ID) . '" title="' . attribute_escape(sprintf(__('Preview "%s"'), $title)) . '" rel="permalink">' . __('Preview') . '</a>';
mp-wp_genesis 1210 } else {
mp-wp_genesis 1211 $actions['view'] = '<a href="' . get_permalink($page->ID) . '" title="' . attribute_escape(sprintf(__('View "%s"'), $title)) . '" rel="permalink">' . __('View') . '</a>';
mp-wp_genesis 1212 }
mp-wp_genesis 1213 $action_count = count($actions);
mp-wp_genesis 1214
mp-wp_genesis 1215 $i = 0;
mp-wp_genesis 1216 echo '<div class="row-actions">';
mp-wp_genesis 1217 foreach ( $actions as $action => $link ) {
mp-wp_genesis 1218 ++$i;
mp-wp_genesis 1219 ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
mp-wp_genesis 1220 echo "<span class='$action'>$link$sep</span>";
mp-wp_genesis 1221 }
mp-wp_genesis 1222 echo '</div>';
mp-wp_genesis 1223
mp-wp_genesis 1224 get_inline_data($post);
mp-wp_genesis 1225 echo '</td>';
mp-wp_genesis 1226 break;
mp-wp_genesis 1227
mp-wp_genesis 1228 case 'comments':
mp-wp_genesis 1229 ?>
mp-wp_genesis 1230 <td <?php echo $attributes ?>><div class="post-com-count-wrapper">
mp-wp_genesis 1231 <?php
mp-wp_genesis 1232 $left = get_pending_comments_num( $page->ID );
mp-wp_genesis 1233 $pending_phrase = sprintf( __('%s pending'), number_format( $left ) );
mp-wp_genesis 1234 if ( $left )
mp-wp_genesis 1235 echo '<strong>';
mp-wp_genesis 1236 comments_number("<a href='edit-comments.php?p=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('0') . '</span></a>', "<a href='edit-comments.php?p=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('1') . '</span></a>', "<a href='edit-comments.php?p=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('%') . '</span></a>');
mp-wp_genesis 1237 if ( $left )
mp-wp_genesis 1238 echo '</strong>';
mp-wp_genesis 1239 ?>
mp-wp_genesis 1240 </div></td>
mp-wp_genesis 1241 <?php
mp-wp_genesis 1242 break;
mp-wp_genesis 1243
mp-wp_genesis 1244 case 'author':
mp-wp_genesis 1245 ?>
mp-wp_genesis 1246 <td <?php echo $attributes ?>><a href="edit-pages.php?author=<?php the_author_ID(); ?>"><?php the_author() ?></a></td>
mp-wp_genesis 1247 <?php
mp-wp_genesis 1248 break;
mp-wp_genesis 1249
mp-wp_genesis 1250 default:
mp-wp_genesis 1251 ?>
mp-wp_genesis 1252 <td <?php echo $attributes ?>><?php do_action('manage_pages_custom_column', $column_name, $id); ?></td>
mp-wp_genesis 1253 <?php
mp-wp_genesis 1254 break;
mp-wp_genesis 1255 }
mp-wp_genesis 1256 }
mp-wp_genesis 1257 ?>
mp-wp_genesis 1258
mp-wp_genesis 1259 </tr>
mp-wp_genesis 1260
mp-wp_genesis 1261 <?php
mp-wp_genesis 1262 }
mp-wp_genesis 1263
mp-wp_genesis 1264 /*
mp-wp_genesis 1265 * displays pages in hierarchical order with paging support
mp-wp_genesis 1266 */
mp-wp_genesis 1267 /**
mp-wp_genesis 1268 * {@internal Missing Short Description}}
mp-wp_genesis 1269 *
mp-wp_genesis 1270 * @since unknown
mp-wp_genesis 1271 *
mp-wp_genesis 1272 * @param unknown_type $pages
mp-wp_genesis 1273 * @param unknown_type $pagenum
mp-wp_genesis 1274 * @param unknown_type $per_page
mp-wp_genesis 1275 * @return unknown
mp-wp_genesis 1276 */
mp-wp_genesis 1277 function page_rows($pages, $pagenum = 1, $per_page = 20) {
mp-wp_genesis 1278 global $wpdb;
mp-wp_genesis 1279
mp-wp_genesis 1280 $level = 0;
mp-wp_genesis 1281
mp-wp_genesis 1282 if ( ! $pages ) {
mp-wp_genesis 1283 $pages = get_pages( array('sort_column' => 'menu_order') );
mp-wp_genesis 1284
mp-wp_genesis 1285 if ( ! $pages )
mp-wp_genesis 1286 return false;
mp-wp_genesis 1287 }
mp-wp_genesis 1288
mp-wp_genesis 1289 /*
mp-wp_genesis 1290 * arrange pages into two parts: top level pages and children_pages
mp-wp_genesis 1291 * children_pages is two dimensional array, eg.
mp-wp_genesis 1292 * children_pages[10][] contains all sub-pages whose parent is 10.
mp-wp_genesis 1293 * It only takes O(N) to arrange this and it takes O(1) for subsequent lookup operations
mp-wp_genesis 1294 * If searching, ignore hierarchy and treat everything as top level
mp-wp_genesis 1295 */
mp-wp_genesis 1296 if ( empty($_GET['s']) ) {
mp-wp_genesis 1297
mp-wp_genesis 1298 $top_level_pages = array();
mp-wp_genesis 1299 $children_pages = array();
mp-wp_genesis 1300
mp-wp_genesis 1301 foreach ( $pages as $page ) {
mp-wp_genesis 1302
mp-wp_genesis 1303 // catch and repair bad pages
mp-wp_genesis 1304 if ( $page->post_parent == $page->ID ) {
mp-wp_genesis 1305 $page->post_parent = 0;
mp-wp_genesis 1306 $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET post_parent = '0' WHERE ID = %d", $page->ID) );
mp-wp_genesis 1307 clean_page_cache( $page->ID );
mp-wp_genesis 1308 }
mp-wp_genesis 1309
mp-wp_genesis 1310 if ( 0 == $page->post_parent )
mp-wp_genesis 1311 $top_level_pages[] = $page;
mp-wp_genesis 1312 else
mp-wp_genesis 1313 $children_pages[ $page->post_parent ][] = $page;
mp-wp_genesis 1314 }
mp-wp_genesis 1315
mp-wp_genesis 1316 $pages = &$top_level_pages;
mp-wp_genesis 1317 }
mp-wp_genesis 1318
mp-wp_genesis 1319 $count = 0;
mp-wp_genesis 1320 $start = ($pagenum - 1) * $per_page;
mp-wp_genesis 1321 $end = $start + $per_page;
mp-wp_genesis 1322
mp-wp_genesis 1323 foreach ( $pages as $page ) {
mp-wp_genesis 1324 if ( $count >= $end )
mp-wp_genesis 1325 break;
mp-wp_genesis 1326
mp-wp_genesis 1327 if ( $count >= $start )
mp-wp_genesis 1328 echo "\t" . display_page_row( $page, $level );
mp-wp_genesis 1329
mp-wp_genesis 1330 $count++;
mp-wp_genesis 1331
mp-wp_genesis 1332 if ( isset($children_pages) )
mp-wp_genesis 1333 _page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page );
mp-wp_genesis 1334 }
mp-wp_genesis 1335
mp-wp_genesis 1336 // if it is the last pagenum and there are orphaned pages, display them with paging as well
mp-wp_genesis 1337 if ( isset($children_pages) && $count < $end ){
mp-wp_genesis 1338 foreach( $children_pages as $orphans ){
mp-wp_genesis 1339 foreach ( $orphans as $op ) {
mp-wp_genesis 1340 if ( $count >= $end )
mp-wp_genesis 1341 break;
mp-wp_genesis 1342 if ( $count >= $start )
mp-wp_genesis 1343 echo "\t" . display_page_row( $op, 0 );
mp-wp_genesis 1344 $count++;
mp-wp_genesis 1345 }
mp-wp_genesis 1346 }
mp-wp_genesis 1347 }
mp-wp_genesis 1348 }
mp-wp_genesis 1349
mp-wp_genesis 1350 /*
mp-wp_genesis 1351 * Given a top level page ID, display the nested hierarchy of sub-pages
mp-wp_genesis 1352 * together with paging support
mp-wp_genesis 1353 */
mp-wp_genesis 1354 /**
mp-wp_genesis 1355 * {@internal Missing Short Description}}
mp-wp_genesis 1356 *
mp-wp_genesis 1357 * @since unknown
mp-wp_genesis 1358 *
mp-wp_genesis 1359 * @param unknown_type $children_pages
mp-wp_genesis 1360 * @param unknown_type $count
mp-wp_genesis 1361 * @param unknown_type $parent
mp-wp_genesis 1362 * @param unknown_type $level
mp-wp_genesis 1363 * @param unknown_type $pagenum
mp-wp_genesis 1364 * @param unknown_type $per_page
mp-wp_genesis 1365 */
mp-wp_genesis 1366 function _page_rows( &$children_pages, &$count, $parent, $level, $pagenum, $per_page ) {
mp-wp_genesis 1367
mp-wp_genesis 1368 if ( ! isset( $children_pages[$parent] ) )
mp-wp_genesis 1369 return;
mp-wp_genesis 1370
mp-wp_genesis 1371 $start = ($pagenum - 1) * $per_page;
mp-wp_genesis 1372 $end = $start + $per_page;
mp-wp_genesis 1373
mp-wp_genesis 1374 foreach ( $children_pages[$parent] as $page ) {
mp-wp_genesis 1375
mp-wp_genesis 1376 if ( $count >= $end )
mp-wp_genesis 1377 break;
mp-wp_genesis 1378
mp-wp_genesis 1379 // If the page starts in a subtree, print the parents.
mp-wp_genesis 1380 if ( $count == $start && $page->post_parent > 0 ) {
mp-wp_genesis 1381 $my_parents = array();
mp-wp_genesis 1382 $my_parent = $page->post_parent;
mp-wp_genesis 1383 while ( $my_parent) {
mp-wp_genesis 1384 $my_parent = get_post($my_parent);
mp-wp_genesis 1385 $my_parents[] = $my_parent;
mp-wp_genesis 1386 if ( !$my_parent->post_parent )
mp-wp_genesis 1387 break;
mp-wp_genesis 1388 $my_parent = $my_parent->post_parent;
mp-wp_genesis 1389 }
mp-wp_genesis 1390 $num_parents = count($my_parents);
mp-wp_genesis 1391 while( $my_parent = array_pop($my_parents) ) {
mp-wp_genesis 1392 echo "\t" . display_page_row( $my_parent, $level - $num_parents );
mp-wp_genesis 1393 $num_parents--;
mp-wp_genesis 1394 }
mp-wp_genesis 1395 }
mp-wp_genesis 1396
mp-wp_genesis 1397 if ( $count >= $start )
mp-wp_genesis 1398 echo "\t" . display_page_row( $page, $level );
mp-wp_genesis 1399
mp-wp_genesis 1400 $count++;
mp-wp_genesis 1401
mp-wp_genesis 1402 _page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page );
mp-wp_genesis 1403 }
mp-wp_genesis 1404
mp-wp_genesis 1405 unset( $children_pages[$parent] ); //required in order to keep track of orphans
mp-wp_genesis 1406 }
mp-wp_genesis 1407
mp-wp_genesis 1408 /**
mp-wp_genesis 1409 * {@internal Missing Short Description}}
mp-wp_genesis 1410 *
mp-wp_genesis 1411 * @since unknown
mp-wp_genesis 1412 *
mp-wp_genesis 1413 * @param unknown_type $user_object
mp-wp_genesis 1414 * @param unknown_type $style
mp-wp_genesis 1415 * @param unknown_type $role
mp-wp_genesis 1416 * @return unknown
mp-wp_genesis 1417 */
mp-wp_genesis 1418 function user_row( $user_object, $style = '', $role = '' ) {
mp-wp_genesis 1419 global $wp_roles;
mp-wp_genesis 1420
mp-wp_genesis 1421 $current_user = wp_get_current_user();
mp-wp_genesis 1422
mp-wp_genesis 1423 if ( !( is_object( $user_object) && is_a( $user_object, 'WP_User' ) ) )
mp-wp_genesis 1424 $user_object = new WP_User( (int) $user_object );
mp-wp_genesis 1425 $email = $user_object->user_email;
mp-wp_genesis 1426 $url = $user_object->user_url;
mp-wp_genesis 1427 $short_url = str_replace( 'http://', '', $url );
mp-wp_genesis 1428 $short_url = str_replace( 'www.', '', $short_url );
mp-wp_genesis 1429 if ('/' == substr( $short_url, -1 ))
mp-wp_genesis 1430 $short_url = substr( $short_url, 0, -1 );
mp-wp_genesis 1431 if ( strlen( $short_url ) > 35 )
mp-wp_genesis 1432 $short_url = substr( $short_url, 0, 32 ).'...';
mp-wp_genesis 1433 $numposts = get_usernumposts( $user_object->ID );
mp-wp_genesis 1434 if ( current_user_can( 'edit_user', $user_object->ID ) ) {
mp-wp_genesis 1435 if ($current_user->ID == $user_object->ID) {
mp-wp_genesis 1436 $edit_link = 'profile.php';
mp-wp_genesis 1437 } else {
mp-wp_genesis 1438 $edit_link = clean_url( add_query_arg( 'wp_http_referer', urlencode( clean_url( stripslashes( $_SERVER['REQUEST_URI'] ) ) ), "user-edit.php?user_id=$user_object->ID" ) );
mp-wp_genesis 1439 }
mp-wp_genesis 1440 $edit = "<strong><a href=\"$edit_link\">$user_object->user_login</a></strong><br />";
mp-wp_genesis 1441 $actions = array();
mp-wp_genesis 1442 $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
mp-wp_genesis 1443 if ( $current_user->ID != $user_object->ID )
mp-wp_genesis 1444 $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("users.php?action=delete&amp;user=$user_object->ID", 'bulk-users') . "'>" . __('Delete') . "</a>";
mp-wp_genesis 1445 $action_count = count($actions);
mp-wp_genesis 1446 $i = 0;
mp-wp_genesis 1447 $edit .= '<div class="row-actions">';
mp-wp_genesis 1448 foreach ( $actions as $action => $link ) {
mp-wp_genesis 1449 ++$i;
mp-wp_genesis 1450 ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
mp-wp_genesis 1451 $edit .= "<span class='$action'>$link$sep</span>";
mp-wp_genesis 1452 }
mp-wp_genesis 1453 $edit .= '</div>';
mp-wp_genesis 1454 } else {
mp-wp_genesis 1455 $edit = '<strong>' . $user_object->user_login . '</strong>';
mp-wp_genesis 1456 }
mp-wp_genesis 1457 $role_name = isset($wp_roles->role_names[$role]) ? translate_with_context($wp_roles->role_names[$role]) : __('None');
mp-wp_genesis 1458 $r = "<tr id='user-$user_object->ID'$style>";
mp-wp_genesis 1459 $columns = get_column_headers('users');
mp-wp_genesis 1460 $hidden = get_hidden_columns('users');
mp-wp_genesis 1461 $avatar = get_avatar( $user_object->user_email, 32 );
mp-wp_genesis 1462 foreach ( $columns as $column_name => $column_display_name ) {
mp-wp_genesis 1463 $class = "class=\"$column_name column-$column_name\"";
mp-wp_genesis 1464
mp-wp_genesis 1465 $style = '';
mp-wp_genesis 1466 if ( in_array($column_name, $hidden) )
mp-wp_genesis 1467 $style = ' style="display:none;"';
mp-wp_genesis 1468
mp-wp_genesis 1469 $attributes = "$class$style";
mp-wp_genesis 1470
mp-wp_genesis 1471 switch ($column_name) {
mp-wp_genesis 1472 case 'cb':
mp-wp_remove-all-... 1473 $r .= "<td scope='row' class='check-column'><input type='checkbox' name='users[]' id='user_{$user_object->ID}' class='$role' value='{$user_object->ID}' /></td>";
mp-wp_genesis 1474 break;
mp-wp_genesis 1475 case 'username':
mp-wp_genesis 1476 $r .= "<td $attributes>$avatar $edit</td>";
mp-wp_genesis 1477 break;
mp-wp_genesis 1478 case 'name':
mp-wp_genesis 1479 $r .= "<td $attributes>$user_object->first_name $user_object->last_name</td>";
mp-wp_genesis 1480 break;
mp-wp_genesis 1481 case 'email':
mp-wp_genesis 1482 $r .= "<td $attributes><a href='mailto:$email' title='" . sprintf( __('e-mail: %s' ), $email ) . "'>$email</a></td>";
mp-wp_genesis 1483 break;
mp-wp_genesis 1484 case 'role':
mp-wp_genesis 1485 $r .= "<td $attributes>$role_name</td>";
mp-wp_genesis 1486 break;
mp-wp_genesis 1487 case 'posts':
mp-wp_genesis 1488 $attributes = 'class="posts column-posts num"' . $style;
mp-wp_genesis 1489 $r .= "<td $attributes>";
mp-wp_genesis 1490 if ( $numposts > 0 ) {
mp-wp_genesis 1491 $r .= "<a href='edit.php?author=$user_object->ID' title='" . __( 'View posts by this author' ) . "' class='edit'>";
mp-wp_genesis 1492 $r .= $numposts;
mp-wp_genesis 1493 $r .= '</a>';
mp-wp_genesis 1494 } else {
mp-wp_genesis 1495 $r .= 0;
mp-wp_genesis 1496 }
mp-wp_genesis 1497 $r .= "</td>";
mp-wp_genesis 1498 }
mp-wp_genesis 1499 }
mp-wp_genesis 1500 $r .= '</tr>';
mp-wp_genesis 1501
mp-wp_genesis 1502 return $r;
mp-wp_genesis 1503 }
mp-wp_genesis 1504
mp-wp_genesis 1505 /**
mp-wp_genesis 1506 * {@internal Missing Short Description}}
mp-wp_genesis 1507 *
mp-wp_genesis 1508 * @since unknown
mp-wp_genesis 1509 *
mp-wp_genesis 1510 * @param unknown_type $status
mp-wp_genesis 1511 * @param unknown_type $s
mp-wp_genesis 1512 * @param unknown_type $start
mp-wp_genesis 1513 * @param unknown_type $num
mp-wp_genesis 1514 * @param unknown_type $post
mp-wp_genesis 1515 * @param unknown_type $type
mp-wp_genesis 1516 * @return unknown
mp-wp_genesis 1517 */
mp-wp_genesis 1518 function _wp_get_comment_list( $status = '', $s = false, $start, $num, $post = 0, $type = '' ) {
mp-wp_genesis 1519 global $wpdb;
mp-wp_genesis 1520
mp-wp_genesis 1521 $start = abs( (int) $start );
mp-wp_genesis 1522 $num = (int) $num;
mp-wp_genesis 1523 $post = (int) $post;
mp-wp_genesis 1524
mp-wp_genesis 1525 if ( 'moderated' == $status )
mp-wp_genesis 1526 $approved = "comment_approved = '0'";
mp-wp_genesis 1527 elseif ( 'approved' == $status )
mp-wp_genesis 1528 $approved = "comment_approved = '1'";
mp-wp_genesis 1529 elseif ( 'spam' == $status )
mp-wp_genesis 1530 $approved = "comment_approved = 'spam'";
mp-wp_genesis 1531 else
mp-wp_genesis 1532 $approved = "( comment_approved = '0' OR comment_approved = '1' )";
mp-wp_genesis 1533
mp-wp_genesis 1534 if ( $post ) {
mp-wp_genesis 1535 $post = " AND comment_post_ID = '$post'";
mp-wp_genesis 1536 $orderby = "ORDER BY comment_date_gmt ASC LIMIT $start, $num";
mp-wp_genesis 1537 } else {
mp-wp_genesis 1538 $post = '';
mp-wp_genesis 1539 $orderby = "ORDER BY comment_date_gmt DESC LIMIT $start, $num";
mp-wp_genesis 1540 }
mp-wp_genesis 1541
mp-wp_genesis 1542 if ( 'comment' == $type )
mp-wp_genesis 1543 $typesql = "AND comment_type = ''";
mp-wp_genesis 1544 elseif ( 'pingback' == $type )
mp-wp_genesis 1545 $typesql = "AND comment_type = 'pingback'";
mp-wp_genesis 1546 elseif ( 'trackback' == $type )
mp-wp_genesis 1547 $typesql = "AND comment_type = 'trackback'";
mp-wp_genesis 1548 elseif ( 'pings' == $type )
mp-wp_genesis 1549 $typesql = "AND ( comment_type = 'pingback' OR comment_type = 'trackback' )";
mp-wp_genesis 1550 else
mp-wp_genesis 1551 $typesql = '';
mp-wp_genesis 1552
mp-wp_genesis 1553 if ( $s ) {
mp-wp_genesis 1554 $s = $wpdb->escape($s);
mp-wp_genesis 1555 $comments = $wpdb->get_results("SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->comments WHERE
mp-wp_genesis 1556 (comment_author LIKE '%$s%' OR
mp-wp_genesis 1557 comment_author_email LIKE '%$s%' OR
mp-wp_genesis 1558 comment_author_url LIKE ('%$s%') OR
mp-wp_genesis 1559 comment_author_IP LIKE ('%$s%') OR
mp-wp_genesis 1560 comment_content LIKE ('%$s%') ) AND
mp-wp_genesis 1561 $approved
mp-wp_genesis 1562 $typesql
mp-wp_genesis 1563 $orderby");
mp-wp_genesis 1564 } else {
mp-wp_genesis 1565 $comments = $wpdb->get_results( "SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->comments WHERE $approved $post $typesql $orderby" );
mp-wp_genesis 1566 }
mp-wp_genesis 1567
mp-wp_genesis 1568 update_comment_cache($comments);
mp-wp_genesis 1569
mp-wp_genesis 1570 $total = $wpdb->get_var( "SELECT FOUND_ROWS()" );
mp-wp_genesis 1571
mp-wp_genesis 1572 return array($comments, $total);
mp-wp_genesis 1573 }
mp-wp_genesis 1574
mp-wp_genesis 1575 /**
mp-wp_genesis 1576 * {@internal Missing Short Description}}
mp-wp_genesis 1577 *
mp-wp_genesis 1578 * @since unknown
mp-wp_genesis 1579 *
mp-wp_genesis 1580 * @param unknown_type $comment_id
mp-wp_genesis 1581 * @param unknown_type $mode
mp-wp_genesis 1582 * @param unknown_type $comment_status
mp-wp_genesis 1583 * @param unknown_type $checkbox
mp-wp_genesis 1584 */
mp-wp_genesis 1585 function _wp_comment_row( $comment_id, $mode, $comment_status, $checkbox = true, $from_ajax = false ) {
mp-wp_genesis 1586 global $comment, $post, $_comment_pending_count;
mp-wp_genesis 1587 $comment = get_comment( $comment_id );
mp-wp_genesis 1588 $post = get_post($comment->comment_post_ID);
mp-wp_genesis 1589 $the_comment_status = wp_get_comment_status($comment->comment_ID);
mp-wp_genesis 1590
mp-wp_genesis 1591 $author_url = get_comment_author_url();
mp-wp_genesis 1592 if ( 'http://' == $author_url )
mp-wp_genesis 1593 $author_url = '';
mp-wp_genesis 1594 $author_url_display = $author_url;
mp-wp_genesis 1595 $author_url_display = str_replace('http://www.', '', $author_url_display);
mp-wp_genesis 1596 $author_url_display = str_replace('http://', '', $author_url_display);
mp-wp_genesis 1597 if ( strlen($author_url_display) > 50 )
mp-wp_genesis 1598 $author_url_display = substr($author_url_display, 0, 49) . '...';
mp-wp_genesis 1599
mp-wp_genesis 1600 $ptime = date('G', strtotime( $comment->comment_date ) );
mp-wp_genesis 1601 if ( ( abs(time() - $ptime) ) < 86400 )
mp-wp_genesis 1602 $ptime = sprintf( __('%s ago'), human_time_diff( $ptime ) );
mp-wp_genesis 1603 else
mp-wp_genesis 1604 $ptime = mysql2date(__('Y/m/d \a\t g:i A'), $comment->comment_date );
mp-wp_genesis 1605
mp-wp_genesis 1606 $delete_url = clean_url( wp_nonce_url( "comment.php?action=deletecomment&p=$post->ID&c=$comment->comment_ID", "delete-comment_$comment->comment_ID" ) );
mp-wp_genesis 1607 $approve_url = clean_url( wp_nonce_url( "comment.php?action=approvecomment&p=$post->ID&c=$comment->comment_ID", "approve-comment_$comment->comment_ID" ) );
mp-wp_genesis 1608 $unapprove_url = clean_url( wp_nonce_url( "comment.php?action=unapprovecomment&p=$post->ID&c=$comment->comment_ID", "unapprove-comment_$comment->comment_ID" ) );
mp-wp_genesis 1609 $spam_url = clean_url( wp_nonce_url( "comment.php?action=deletecomment&dt=spam&p=$post->ID&c=$comment->comment_ID", "delete-comment_$comment->comment_ID" ) );
mp-wp_genesis 1610
mp-wp_genesis 1611 echo "<tr id='comment-$comment->comment_ID' class='$the_comment_status'>";
mp-wp_genesis 1612 $columns = get_column_headers('edit-comments');
mp-wp_genesis 1613 $hidden = get_hidden_columns('edit-comments');
mp-wp_genesis 1614 foreach ( $columns as $column_name => $column_display_name ) {
mp-wp_genesis 1615 $class = "class=\"$column_name column-$column_name\"";
mp-wp_genesis 1616
mp-wp_genesis 1617 $style = '';
mp-wp_genesis 1618 if ( in_array($column_name, $hidden) )
mp-wp_genesis 1619 $style = ' style="display:none;"';
mp-wp_genesis 1620
mp-wp_genesis 1621 $attributes = "$class$style";
mp-wp_genesis 1622
mp-wp_genesis 1623 switch ($column_name) {
mp-wp_genesis 1624 case 'cb':
mp-wp_genesis 1625 if ( !$checkbox ) break;
mp-wp_remove-all-... 1626 echo '<td scope="row" class="check-column">';
mp-wp_genesis 1627 if ( current_user_can('edit_post', $post->ID) ) echo "<input type='checkbox' name='delete_comments[]' value='$comment->comment_ID' />";
mp-wp_remove-all-... 1628 echo '</td>';
mp-wp_genesis 1629 break;
mp-wp_genesis 1630 case 'comment':
mp-wp_genesis 1631 echo "<td $attributes>";
mp-wp_genesis 1632 echo '<div id="submitted-on">';
mp-wp_genesis 1633 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')));
mp-wp_genesis 1634 echo '</div>';
mp-wp_genesis 1635 comment_text(); ?>
mp-wp_genesis 1636 <div id="inline-<?php echo $comment->comment_ID; ?>" class="hidden">
mp-wp_genesis 1637 <textarea class="comment" rows="3" cols="10"><?php echo $comment->comment_content; ?></textarea>
mp-wp_genesis 1638 <div class="author-email"><?php echo attribute_escape( $comment->comment_author_email ); ?></div>
mp-wp_genesis 1639 <div class="author"><?php echo attribute_escape( $comment->comment_author ); ?></div>
mp-wp_genesis 1640 <div class="author-url"><?php echo attribute_escape( $comment->comment_author_url ); ?></div>
mp-wp_genesis 1641 <div class="comment_status"><?php echo $comment->comment_approved; ?></div>
mp-wp_genesis 1642 </div>
mp-wp_genesis 1643 <?php
mp-wp_genesis 1644 $actions = array();
mp-wp_genesis 1645
mp-wp_genesis 1646 if ( current_user_can('edit_post', $post->ID) ) {
mp-wp_genesis 1647 $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>';
mp-wp_genesis 1648 $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>';
mp-wp_genesis 1649 if ( $comment_status ) { // not looking at all comments
mp-wp_genesis 1650 if ( 'approved' == $the_comment_status ) {
mp-wp_genesis 1651 $actions['unapprove'] = "<a href='$unapprove_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&amp;new=unapproved vim-u vim-destructive' title='" . __( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
mp-wp_genesis 1652 unset($actions['approve']);
mp-wp_genesis 1653 } else {
mp-wp_genesis 1654 $actions['approve'] = "<a href='$approve_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&amp;new=approved vim-a vim-destructive' title='" . __( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
mp-wp_genesis 1655 unset($actions['unapprove']);
mp-wp_genesis 1656 }
mp-wp_genesis 1657 }
mp-wp_genesis 1658 if ( 'spam' != $the_comment_status )
mp-wp_genesis 1659 $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' ) . "'>" . _c( 'Spam|verb' ) . '</a>';
mp-wp_genesis 1660 $actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID delete vim-d vim-destructive'>" . __('Delete') . '</a>';
mp-wp_genesis 1661 $actions['edit'] = "<a href='comment.php?action=editcomment&amp;c={$comment->comment_ID}' title='" . __('Edit comment') . "'>". __('Edit') . '</a>';
mp-wp_genesis 1662
mp-wp_genesis 1663 $actions = apply_filters( 'comment_row_actions', $actions, $comment );
mp-wp_genesis 1664
mp-wp_genesis 1665 $i = 0;
mp-wp_genesis 1666 echo '<div class="row-actions">';
mp-wp_genesis 1667 foreach ( $actions as $action => $link ) {
mp-wp_genesis 1668 ++$i;
mp-wp_genesis 1669 ( ( ('approve' == $action || 'unapprove' == $action) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | ';
mp-wp_genesis 1670
mp-wp_genesis 1671 echo "<span class='$action'>$sep$link</span>";
mp-wp_genesis 1672 }
mp-wp_genesis 1673 echo '</div>';
mp-wp_genesis 1674 }
mp-wp_genesis 1675
mp-wp_genesis 1676 echo '</td>';
mp-wp_genesis 1677 break;
mp-wp_genesis 1678 case 'author':
mp-wp_genesis 1679 echo "<td $attributes><strong>"; comment_author(); echo '</strong><br />';
mp-wp_genesis 1680 if ( !empty($author_url) )
mp-wp_genesis 1681 echo "<a title='$author_url' href='$author_url'>$author_url_display</a><br />";
mp-wp_genesis 1682 if ( current_user_can( 'edit_post', $post->ID ) ) {
mp-wp_genesis 1683 if ( !empty($comment->comment_author_email) ) {
mp-wp_genesis 1684 comment_author_email_link();
mp-wp_genesis 1685 echo '<br />';
mp-wp_genesis 1686 }
mp-wp_genesis 1687 echo '<a href="edit-comments.php?s=';
mp-wp_genesis 1688 comment_author_IP();
mp-wp_genesis 1689 echo '&amp;mode=detail';
mp-wp_genesis 1690 if ( 'spam' == $comment_status )
mp-wp_genesis 1691 echo '&amp;comment_status=spam';
mp-wp_genesis 1692 echo '">';
mp-wp_genesis 1693 comment_author_IP();
mp-wp_genesis 1694 echo '</a>';
mp-wp_genesis 1695 } //current_user_can
mp-wp_genesis 1696 echo '</td>';
mp-wp_genesis 1697 break;
mp-wp_genesis 1698 case 'date':
mp-wp_genesis 1699 echo "<td $attributes>" . get_comment_date(__('Y/m/d \a\t g:ia')) . '</td>';
mp-wp_genesis 1700 break;
mp-wp_genesis 1701 case 'response':
mp-wp_genesis 1702 if ( 'single' !== $mode ) {
mp-wp_genesis 1703 if ( isset( $_comment_pending_count[$post->ID] ) ) {
mp-wp_genesis 1704 $pending_comments = absint( $_comment_pending_count[$post->ID] );
mp-wp_genesis 1705 } else {
mp-wp_genesis 1706 $_comment_pending_count_temp = (array) get_pending_comments_num( array( $post->ID ) );
mp-wp_genesis 1707 $pending_comments = $_comment_pending_count[$post->ID] = $_comment_pending_count_temp[$post->ID];
mp-wp_genesis 1708 }
mp-wp_genesis 1709 if ( current_user_can( 'edit_post', $post->ID ) ) {
mp-wp_genesis 1710 $post_link = "<a href='" . get_edit_post_link($post->ID) . "'>";
mp-wp_genesis 1711 $post_link .= get_the_title($post->ID) . '</a>';
mp-wp_genesis 1712 } else {
mp-wp_genesis 1713 $post_link = get_the_title($post->ID);
mp-wp_genesis 1714 }
mp-wp_genesis 1715 echo "<td $attributes>\n";
mp-wp_genesis 1716 echo $post_link;
mp-wp_genesis 1717
mp-wp_genesis 1718 echo '<div class="response-links"><span class="post-com-count-wrapper">';
mp-wp_genesis 1719 $pending_phrase = sprintf( __('%s pending'), number_format( $pending_comments ) );
mp-wp_genesis 1720 if ( $pending_comments )
mp-wp_genesis 1721 echo '<strong>';
mp-wp_genesis 1722 comments_number("<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('0') . '</span></a>', "<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('1') . '</span></a>', "<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('%') . '</span></a>');
mp-wp_genesis 1723 if ( $pending_comments )
mp-wp_genesis 1724 echo '</strong>';
mp-wp_genesis 1725 echo '</span> ';
mp-wp_genesis 1726 echo "<a href='" . get_permalink( $post->ID ) . "'>#</a>";
mp-wp_genesis 1727 echo '</div></td>';
mp-wp_genesis 1728 }
mp-wp_genesis 1729 }
mp-wp_genesis 1730 }
mp-wp_genesis 1731 echo "</tr>\n";
mp-wp_genesis 1732 }
mp-wp_genesis 1733
mp-wp_genesis 1734 /**
mp-wp_genesis 1735 * {@internal Missing Short Description}}
mp-wp_genesis 1736 *
mp-wp_genesis 1737 * @since unknown
mp-wp_genesis 1738 *
mp-wp_genesis 1739 * @param unknown_type $position
mp-wp_genesis 1740 * @param unknown_type $checkbox
mp-wp_genesis 1741 * @param unknown_type $mode
mp-wp_genesis 1742 */
mp-wp_genesis 1743 function wp_comment_reply($position = '1', $checkbox = false, $mode = 'single', $table_row = true) {
mp-wp_genesis 1744 global $current_user;
mp-wp_genesis 1745
mp-wp_genesis 1746 // allow plugin to replace the popup content
mp-wp_genesis 1747 $content = apply_filters( 'wp_comment_reply', '', array('position' => $position, 'checkbox' => $checkbox, 'mode' => $mode) );
mp-wp_genesis 1748
mp-wp_genesis 1749 if ( ! empty($content) ) {
mp-wp_genesis 1750 echo $content;
mp-wp_genesis 1751 return;
mp-wp_genesis 1752 }
mp-wp_genesis 1753
mp-wp_genesis 1754 $columns = get_column_headers('edit-comments');
mp-wp_genesis 1755 $hidden = array_intersect( array_keys( $columns ), array_filter( get_hidden_columns('edit-comments') ) );
mp-wp_genesis 1756 $col_count = count($columns) - count($hidden);
mp-wp_genesis 1757
mp-wp_genesis 1758 ?>
mp-wp_genesis 1759 <form method="get" action="">
mp-wp_genesis 1760 <?php if ( $table_row ) : ?>
mp-wp_genesis 1761 <table style="display:none;"><tbody id="com-reply"><tr id="replyrow"><td colspan="<?php echo $col_count; ?>">
mp-wp_genesis 1762 <?php else : ?>
mp-wp_genesis 1763 <div id="com-reply" style="display:none;"><div id="replyrow">
mp-wp_genesis 1764 <?php endif; ?>
mp-wp_genesis 1765 <div id="replyhead" style="display:none;"><?php _e('Reply to Comment'); ?></div>
mp-wp_genesis 1766
mp-wp_genesis 1767 <div id="edithead" style="display:none;">
mp-wp_genesis 1768 <div class="inside">
mp-wp_genesis 1769 <label for="author"><?php _e('Name') ?></label>
mp-wp_genesis 1770 <input type="text" name="newcomment_author" size="50" value="" tabindex="101" id="author" />
mp-wp_genesis 1771 </div>
mp-wp_genesis 1772
mp-wp_genesis 1773 <div class="inside">
mp-wp_genesis 1774 <label for="author-email"><?php _e('E-mail') ?></label>
mp-wp_genesis 1775 <input type="text" name="newcomment_author_email" size="50" value="" tabindex="102" id="author-email" />
mp-wp_genesis 1776 </div>
mp-wp_genesis 1777
mp-wp_genesis 1778 <div class="inside">
mp-wp_genesis 1779 <label for="author-url"><?php _e('URL') ?></label>
mp-wp_genesis 1780 <input type="text" id="author-url" name="newcomment_author_url" size="103" value="" tabindex="103" />
mp-wp_genesis 1781 </div>
mp-wp_genesis 1782 <div style="clear:both;"></div>
mp-wp_genesis 1783 </div>
mp-wp_genesis 1784
mp-wp_genesis 1785 <div id="replycontainer"><textarea rows="8" cols="40" name="replycontent" tabindex="104" id="replycontent"></textarea></div>
mp-wp_genesis 1786
mp-wp_genesis 1787 <p id="replysubmit" class="submit">
mp-wp_genesis 1788 <a href="#comments-form" class="cancel button-secondary alignleft" tabindex="106"><?php _e('Cancel'); ?></a>
mp-wp_genesis 1789 <a href="#comments-form" class="save button-primary alignright" tabindex="104">
mp-wp_genesis 1790 <span id="savebtn" style="display:none;"><?php _e('Update Comment'); ?></span>
mp-wp_genesis 1791 <span id="replybtn" style="display:none;"><?php _e('Submit Reply'); ?></span></a>
mp-wp_remove-all-... 1792 <span class="waiting" style="display:none;">loading...</span>
mp-wp_genesis 1793 <span class="error" style="display:none;"></span>
mp-wp_genesis 1794 <br class="clear" />
mp-wp_genesis 1795 </p>
mp-wp_genesis 1796
mp-wp_genesis 1797 <input type="hidden" name="user_ID" id="user_ID" value="<?php echo $current_user->ID; ?>" />
mp-wp_genesis 1798 <input type="hidden" name="action" id="action" value="" />
mp-wp_genesis 1799 <input type="hidden" name="comment_ID" id="comment_ID" value="" />
mp-wp_genesis 1800 <input type="hidden" name="comment_post_ID" id="comment_post_ID" value="" />
mp-wp_genesis 1801 <input type="hidden" name="status" id="status" value="" />
mp-wp_genesis 1802 <input type="hidden" name="position" id="position" value="<?php echo $position; ?>" />
mp-wp_genesis 1803 <input type="hidden" name="checkbox" id="checkbox" value="<?php echo $checkbox ? 1 : 0; ?>" />
mp-wp_genesis 1804 <input type="hidden" name="mode" id="mode" value="<?php echo $mode; ?>" />
mp-wp_genesis 1805 <?php wp_nonce_field( 'replyto-comment', '_ajax_nonce', false ); ?>
mp-wp_genesis 1806 <?php wp_comment_form_unfiltered_html_nonce(); ?>
mp-wp_genesis 1807 <?php if ( $table_row ) : ?>
mp-wp_genesis 1808 </td></tr></tbody></table>
mp-wp_genesis 1809 <?php else : ?>
mp-wp_genesis 1810 </div></div>
mp-wp_genesis 1811 <?php endif; ?>
mp-wp_genesis 1812 </form>
mp-wp_genesis 1813 <?php
mp-wp_genesis 1814 }
mp-wp_genesis 1815
mp-wp_genesis 1816 /**
mp-wp_genesis 1817 * {@internal Missing Short Description}}
mp-wp_genesis 1818 *
mp-wp_genesis 1819 * @since unknown
mp-wp_genesis 1820 *
mp-wp_genesis 1821 * @param unknown_type $currentcat
mp-wp_genesis 1822 * @param unknown_type $currentparent
mp-wp_genesis 1823 * @param unknown_type $parent
mp-wp_genesis 1824 * @param unknown_type $level
mp-wp_genesis 1825 * @param unknown_type $categories
mp-wp_genesis 1826 * @return unknown
mp-wp_genesis 1827 */
mp-wp_genesis 1828 function wp_dropdown_cats( $currentcat = 0, $currentparent = 0, $parent = 0, $level = 0, $categories = 0 ) {
mp-wp_genesis 1829 if (!$categories )
mp-wp_genesis 1830 $categories = get_categories( array('hide_empty' => 0) );
mp-wp_genesis 1831
mp-wp_genesis 1832 if ( $categories ) {
mp-wp_genesis 1833 foreach ( $categories as $category ) {
mp-wp_genesis 1834 if ( $currentcat != $category->term_id && $parent == $category->parent) {
mp-wp_genesis 1835 $pad = str_repeat( '&#8211; ', $level );
mp-wp_genesis 1836 $category->name = wp_specialchars( $category->name );
mp-wp_genesis 1837 echo "\n\t<option value='$category->term_id'";
mp-wp_genesis 1838 if ( $currentparent == $category->term_id )
mp-wp_genesis 1839 echo " selected='selected'";
mp-wp_genesis 1840 echo ">$pad$category->name</option>";
mp-wp_genesis 1841 wp_dropdown_cats( $currentcat, $currentparent, $category->term_id, $level +1, $categories );
mp-wp_genesis 1842 }
mp-wp_genesis 1843 }
mp-wp_genesis 1844 } else {
mp-wp_genesis 1845 return false;
mp-wp_genesis 1846 }
mp-wp_genesis 1847 }
mp-wp_genesis 1848
mp-wp_genesis 1849 /**
mp-wp_genesis 1850 * {@internal Missing Short Description}}
mp-wp_genesis 1851 *
mp-wp_genesis 1852 * @since unknown
mp-wp_genesis 1853 *
mp-wp_genesis 1854 * @param unknown_type $meta
mp-wp_genesis 1855 */
mp-wp_genesis 1856 function list_meta( $meta ) {
mp-wp_genesis 1857 // Exit if no meta
mp-wp_genesis 1858 if ( ! $meta ) {
mp-wp_genesis 1859 echo '
mp-wp_genesis 1860 <table id="list-table" style="display: none;">
mp-wp_genesis 1861 <thead>
mp-wp_genesis 1862 <tr>
mp-wp_genesis 1863 <th class="left">' . __( 'Name' ) . '</th>
mp-wp_genesis 1864 <th>' . __( 'Value' ) . '</th>
mp-wp_genesis 1865 </tr>
mp-wp_genesis 1866 </thead>
mp-wp_genesis 1867 <tbody id="the-list" class="list:meta">
mp-wp_genesis 1868 <tr><td></td></tr>
mp-wp_genesis 1869 </tbody>
mp-wp_genesis 1870 </table>'; //TBODY needed for list-manipulation JS
mp-wp_genesis 1871 return;
mp-wp_genesis 1872 }
mp-wp_genesis 1873 $count = 0;
mp-wp_genesis 1874 ?>
mp-wp_genesis 1875 <table id="list-table">
mp-wp_genesis 1876 <thead>
mp-wp_genesis 1877 <tr>
mp-wp_genesis 1878 <th class="left"><?php _e( 'Name' ) ?></th>
mp-wp_genesis 1879 <th><?php _e( 'Value' ) ?></th>
mp-wp_genesis 1880 </tr>
mp-wp_genesis 1881 </thead>
mp-wp_genesis 1882 <tbody id='the-list' class='list:meta'>
mp-wp_genesis 1883 <?php
mp-wp_genesis 1884 foreach ( $meta as $entry )
mp-wp_genesis 1885 echo _list_meta_row( $entry, $count );
mp-wp_genesis 1886 ?>
mp-wp_genesis 1887 </tbody>
mp-wp_genesis 1888 </table>
mp-wp_genesis 1889 <?php
mp-wp_genesis 1890 }
mp-wp_genesis 1891
mp-wp_genesis 1892 /**
mp-wp_genesis 1893 * {@internal Missing Short Description}}
mp-wp_genesis 1894 *
mp-wp_genesis 1895 * @since unknown
mp-wp_genesis 1896 *
mp-wp_genesis 1897 * @param unknown_type $entry
mp-wp_genesis 1898 * @param unknown_type $count
mp-wp_genesis 1899 * @return unknown
mp-wp_genesis 1900 */
mp-wp_genesis 1901 function _list_meta_row( $entry, &$count ) {
mp-wp_genesis 1902 static $update_nonce = false;
mp-wp_genesis 1903 if ( !$update_nonce )
mp-wp_genesis 1904 $update_nonce = wp_create_nonce( 'add-meta' );
mp-wp_genesis 1905
mp-wp_genesis 1906 $r = '';
mp-wp_genesis 1907 ++ $count;
mp-wp_genesis 1908 if ( $count % 2 )
mp-wp_genesis 1909 $style = 'alternate';
mp-wp_genesis 1910 else
mp-wp_genesis 1911 $style = '';
mp-wp_genesis 1912 if ('_' == $entry['meta_key'] { 0 } )
mp-wp_genesis 1913 $style .= ' hidden';
mp-wp_genesis 1914
mp-wp_genesis 1915 if ( is_serialized( $entry['meta_value'] ) ) {
mp-wp_genesis 1916 if ( is_serialized_string( $entry['meta_value'] ) ) {
mp-wp_genesis 1917 // this is a serialized string, so we should display it
mp-wp_genesis 1918 $entry['meta_value'] = maybe_unserialize( $entry['meta_value'] );
mp-wp_genesis 1919 } else {
mp-wp_genesis 1920 // this is a serialized array/object so we should NOT display it
mp-wp_genesis 1921 --$count;
mp-wp_genesis 1922 return;
mp-wp_genesis 1923 }
mp-wp_genesis 1924 }
mp-wp_genesis 1925
mp-wp_genesis 1926 $entry['meta_key'] = attribute_escape($entry['meta_key']);
mp-wp_genesis 1927 $entry['meta_value'] = htmlspecialchars($entry['meta_value']); // using a <textarea />
mp-wp_genesis 1928 $entry['meta_id'] = (int) $entry['meta_id'];
mp-wp_genesis 1929
mp-wp_genesis 1930 $delete_nonce = wp_create_nonce( 'delete-meta_' . $entry['meta_id'] );
mp-wp_genesis 1931
mp-wp_genesis 1932 $r .= "\n\t<tr id='meta-{$entry['meta_id']}' class='$style'>";
mp-wp_genesis 1933 $r .= "\n\t\t<td class='left'><label class='hidden' 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']}' />";
mp-wp_genesis 1934
mp-wp_genesis 1935 $r .= "\n\t\t<div class='submit'><input name='deletemeta[{$entry['meta_id']}]' type='submit' ";
mp-wp_genesis 1936 $r .= "class='delete:the-list:meta-{$entry['meta_id']}::_ajax_nonce=$delete_nonce deletemeta' tabindex='6' value='".attribute_escape(__( 'Delete' ))."' />";
mp-wp_genesis 1937 $r .= "\n\t\t<input name='updatemeta' type='submit' tabindex='6' value='".attribute_escape(__( 'Update' ))."' class='add:the-list:meta-{$entry['meta_id']}::_ajax_nonce=$update_nonce updatemeta' /></div>";
mp-wp_genesis 1938 $r .= wp_nonce_field( 'change-meta', '_ajax_nonce', false, false );
mp-wp_genesis 1939 $r .= "</td>";
mp-wp_genesis 1940
mp-wp_genesis 1941 $r .= "\n\t\t<td><label class='hidden' 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>";
mp-wp_genesis 1942 return $r;
mp-wp_genesis 1943 }
mp-wp_genesis 1944
mp-wp_genesis 1945 /**
mp-wp_genesis 1946 * {@internal Missing Short Description}}
mp-wp_genesis 1947 *
mp-wp_genesis 1948 * @since unknown
mp-wp_genesis 1949 */
mp-wp_genesis 1950 function meta_form() {
mp-wp_genesis 1951 global $wpdb;
mp-wp_genesis 1952 $limit = (int) apply_filters( 'postmeta_form_limit', 30 );
mp-wp_genesis 1953 $keys = $wpdb->get_col( "
mp-wp_genesis 1954 SELECT meta_key
mp-wp_genesis 1955 FROM $wpdb->postmeta
mp-wp_genesis 1956 WHERE meta_key NOT LIKE '\_%'
mp-wp_genesis 1957 GROUP BY meta_key
mp-wp_genesis 1958 ORDER BY meta_id DESC
mp-wp_genesis 1959 LIMIT $limit" );
mp-wp_genesis 1960 if ( $keys )
mp-wp_genesis 1961 natcasesort($keys);
mp-wp_genesis 1962 ?>
mp-wp_genesis 1963 <p><strong><?php _e( 'Add new custom field:' ) ?></strong></p>
mp-wp_genesis 1964 <table id="newmeta">
mp-wp_genesis 1965 <thead>
mp-wp_genesis 1966 <tr>
mp-wp_genesis 1967 <th class="left"><label for="metakeyselect"><?php _e( 'Name' ) ?></label></th>
mp-wp_genesis 1968 <th><label for="metavalue"><?php _e( 'Value' ) ?></label></th>
mp-wp_genesis 1969 </tr>
mp-wp_genesis 1970 </thead>
mp-wp_genesis 1971
mp-wp_genesis 1972 <tbody>
mp-wp_genesis 1973 <tr>
mp-wp_genesis 1974 <td id="newmetaleft" class="left">
mp-wp_genesis 1975 <?php if ( $keys ) { ?>
mp-wp_genesis 1976 <select id="metakeyselect" name="metakeyselect" tabindex="7">
mp-wp_genesis 1977 <option value="#NONE#"><?php _e( '- Select -' ); ?></option>
mp-wp_genesis 1978 <?php
mp-wp_genesis 1979
mp-wp_genesis 1980 foreach ( $keys as $key ) {
mp-wp_genesis 1981 $key = attribute_escape( $key );
mp-wp_genesis 1982 echo "\n<option value='$key'>$key</option>";
mp-wp_genesis 1983 }
mp-wp_genesis 1984 ?>
mp-wp_genesis 1985 </select>
mp-wp_remove-all-... 1986 <input type="text" id="metakeyinput" name="metakeyinput" tabindex="7" value="" />
mp-wp_genesis 1987 <span id="enternew"><?php _e('Enter new'); ?></span>
mp-wp_genesis 1988 <span id="cancelnew" class="hidden"><?php _e('Cancel'); ?></span></a>
mp-wp_genesis 1989 <?php } else { ?>
mp-wp_genesis 1990 <input type="text" id="metakeyinput" name="metakeyinput" tabindex="7" value="" />
mp-wp_genesis 1991 <?php } ?>
mp-wp_genesis 1992 </td>
mp-wp_genesis 1993 <td><textarea id="metavalue" name="metavalue" rows="2" cols="25" tabindex="8"></textarea></td>
mp-wp_genesis 1994 </tr>
mp-wp_genesis 1995
mp-wp_genesis 1996 <tr><td colspan="2" class="submit">
mp-wp_genesis 1997 <input type="submit" id="addmetasub" name="addmeta" class="add:the-list:newmeta" tabindex="9" value="<?php _e( 'Add Custom Field' ) ?>" />
mp-wp_genesis 1998 <?php wp_nonce_field( 'add-meta', '_ajax_nonce', false ); ?>
mp-wp_genesis 1999 </td></tr>
mp-wp_genesis 2000 </tbody>
mp-wp_genesis 2001 </table>
mp-wp_genesis 2002 <?php
mp-wp_genesis 2003
mp-wp_genesis 2004 }
mp-wp_genesis 2005
mp-wp_genesis 2006 /**
mp-wp_genesis 2007 * {@internal Missing Short Description}}
mp-wp_genesis 2008 *
mp-wp_genesis 2009 * @since unknown
mp-wp_genesis 2010 *
mp-wp_genesis 2011 * @param unknown_type $edit
mp-wp_genesis 2012 * @param unknown_type $for_post
mp-wp_genesis 2013 * @param unknown_type $tab_index
mp-wp_genesis 2014 * @param unknown_type $multi
mp-wp_genesis 2015 */
mp-wp_genesis 2016 function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) {
mp-wp_genesis 2017 global $wp_locale, $post, $comment;
mp-wp_genesis 2018
mp-wp_genesis 2019 if ( $for_post )
mp-wp_genesis 2020 $edit = ( in_array($post->post_status, array('draft', 'pending') ) && (!$post->post_date || '0000-00-00 00:00:00' == $post->post_date ) ) ? false : true;
mp-wp_genesis 2021
mp-wp_genesis 2022 $tab_index_attribute = '';
mp-wp_genesis 2023 if ( (int) $tab_index > 0 )
mp-wp_genesis 2024 $tab_index_attribute = " tabindex=\"$tab_index\"";
mp-wp_genesis 2025
mp-wp_genesis 2026 // 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 />';
mp-wp_genesis 2027
mp-wp_genesis 2028 $time_adj = time() + (get_option( 'gmt_offset' ) * 3600 );
mp-wp_genesis 2029 $post_date = ($for_post) ? $post->post_date : $comment->comment_date;
mp-wp_genesis 2030 $jj = ($edit) ? mysql2date( 'd', $post_date ) : gmdate( 'd', $time_adj );
mp-wp_genesis 2031 $mm = ($edit) ? mysql2date( 'm', $post_date ) : gmdate( 'm', $time_adj );
mp-wp_genesis 2032 $aa = ($edit) ? mysql2date( 'Y', $post_date ) : gmdate( 'Y', $time_adj );
mp-wp_genesis 2033 $hh = ($edit) ? mysql2date( 'H', $post_date ) : gmdate( 'H', $time_adj );
mp-wp_genesis 2034 $mn = ($edit) ? mysql2date( 'i', $post_date ) : gmdate( 'i', $time_adj );
mp-wp_genesis 2035 $ss = ($edit) ? mysql2date( 's', $post_date ) : gmdate( 's', $time_adj );
mp-wp_genesis 2036
mp-wp_genesis 2037 $cur_jj = gmdate( 'd', $time_adj );
mp-wp_genesis 2038 $cur_mm = gmdate( 'm', $time_adj );
mp-wp_genesis 2039 $cur_aa = gmdate( 'Y', $time_adj );
mp-wp_genesis 2040 $cur_hh = gmdate( 'H', $time_adj );
mp-wp_genesis 2041 $cur_mn = gmdate( 'i', $time_adj );
mp-wp_genesis 2042
mp-wp_genesis 2043 $month = "<select " . ( $multi ? '' : 'id="mm" ' ) . "name=\"mm\"$tab_index_attribute>\n";
mp-wp_genesis 2044 for ( $i = 1; $i < 13; $i = $i +1 ) {
mp-wp_genesis 2045 $month .= "\t\t\t" . '<option value="' . zeroise($i, 2) . '"';
mp-wp_genesis 2046 if ( $i == $mm )
mp-wp_genesis 2047 $month .= ' selected="selected"';
mp-wp_genesis 2048 $month .= '>' . $wp_locale->get_month_abbrev( $wp_locale->get_month( $i ) ) . "</option>\n";
mp-wp_genesis 2049 }
mp-wp_genesis 2050 $month .= '</select>';
mp-wp_genesis 2051
mp-wp_genesis 2052 $day = '<input type="text" ' . ( $multi ? '' : 'id="jj" ' ) . 'name="jj" value="' . $jj . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
mp-wp_genesis 2053 $year = '<input type="text" ' . ( $multi ? '' : 'id="aa" ' ) . 'name="aa" value="' . $aa . '" size="4" maxlength="5"' . $tab_index_attribute . ' autocomplete="off" />';
mp-wp_genesis 2054 $hour = '<input type="text" ' . ( $multi ? '' : 'id="hh" ' ) . 'name="hh" value="' . $hh . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
mp-wp_genesis 2055 $minute = '<input type="text" ' . ( $multi ? '' : 'id="mn" ' ) . 'name="mn" value="' . $mn . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
mp-wp_genesis 2056 printf(_c('%1$s%2$s, %3$s @ %4$s : %5$s|1: month input, 2: day input, 3: year input, 4: hour input, 5: minute input'), $month, $day, $year, $hour, $minute);
mp-wp_genesis 2057
mp-wp_genesis 2058 echo '<input type="hidden" id="ss" name="ss" value="' . $ss . '" />';
mp-wp_genesis 2059
mp-wp_genesis 2060 if ( $multi ) return;
mp-wp_genesis 2061
mp-wp_genesis 2062 echo "\n\n";
mp-wp_genesis 2063 foreach ( array('mm', 'jj', 'aa', 'hh', 'mn') as $timeunit ) {
mp-wp_genesis 2064 echo '<input type="hidden" id="hidden_' . $timeunit . '" name="hidden_' . $timeunit . '" value="' . $$timeunit . '" />' . "\n";
mp-wp_genesis 2065 $cur_timeunit = 'cur_' . $timeunit;
mp-wp_genesis 2066 echo '<input type="hidden" id="'. $cur_timeunit . '" name="'. $cur_timeunit . '" value="' . $$cur_timeunit . '" />' . "\n";
mp-wp_genesis 2067 }
mp-wp_genesis 2068 ?>
mp-wp_genesis 2069
mp-wp_genesis 2070 <input type="hidden" id="ss" name="ss" value="<?php echo $ss ?>" size="2" maxlength="2" />
mp-wp_genesis 2071 <?php
mp-wp_genesis 2072 }
mp-wp_genesis 2073
mp-wp_genesis 2074 /**
mp-wp_genesis 2075 * {@internal Missing Short Description}}
mp-wp_genesis 2076 *
mp-wp_genesis 2077 * @since unknown
mp-wp_genesis 2078 *
mp-wp_genesis 2079 * @param unknown_type $default
mp-wp_genesis 2080 */
mp-wp_genesis 2081 function page_template_dropdown( $default = '' ) {
mp-wp_genesis 2082 $templates = get_page_templates();
mp-wp_genesis 2083 ksort( $templates );
mp-wp_genesis 2084 foreach (array_keys( $templates ) as $template )
mp-wp_genesis 2085 : if ( $default == $templates[$template] )
mp-wp_genesis 2086 $selected = " selected='selected'";
mp-wp_genesis 2087 else
mp-wp_genesis 2088 $selected = '';
mp-wp_genesis 2089 echo "\n\t<option value='".$templates[$template]."' $selected>$template</option>";
mp-wp_genesis 2090 endforeach;
mp-wp_genesis 2091 }
mp-wp_genesis 2092
mp-wp_genesis 2093 /**
mp-wp_genesis 2094 * {@internal Missing Short Description}}
mp-wp_genesis 2095 *
mp-wp_genesis 2096 * @since unknown
mp-wp_genesis 2097 *
mp-wp_genesis 2098 * @param unknown_type $default
mp-wp_genesis 2099 * @param unknown_type $parent
mp-wp_genesis 2100 * @param unknown_type $level
mp-wp_genesis 2101 * @return unknown
mp-wp_genesis 2102 */
mp-wp_genesis 2103 function parent_dropdown( $default = 0, $parent = 0, $level = 0 ) {
mp-wp_genesis 2104 global $wpdb, $post_ID;
mp-wp_genesis 2105 $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) );
mp-wp_genesis 2106
mp-wp_genesis 2107 if ( $items ) {
mp-wp_genesis 2108 foreach ( $items as $item ) {
mp-wp_genesis 2109 // A page cannot be its own parent.
mp-wp_genesis 2110 if (!empty ( $post_ID ) ) {
mp-wp_genesis 2111 if ( $item->ID == $post_ID ) {
mp-wp_genesis 2112 continue;
mp-wp_genesis 2113 }
mp-wp_genesis 2114 }
mp-wp_genesis 2115 $pad = str_repeat( '&nbsp;', $level * 3 );
mp-wp_genesis 2116 if ( $item->ID == $default)
mp-wp_genesis 2117 $current = ' selected="selected"';
mp-wp_genesis 2118 else
mp-wp_genesis 2119 $current = '';
mp-wp_genesis 2120
mp-wp_genesis 2121 echo "\n\t<option class='level-$level' value='$item->ID'$current>$pad " . wp_specialchars($item->post_title) . "</option>";
mp-wp_genesis 2122 parent_dropdown( $default, $item->ID, $level +1 );
mp-wp_genesis 2123 }
mp-wp_genesis 2124 } else {
mp-wp_genesis 2125 return false;
mp-wp_genesis 2126 }
mp-wp_genesis 2127 }
mp-wp_genesis 2128
mp-wp_genesis 2129 /**
mp-wp_genesis 2130 * {@internal Missing Short Description}}
mp-wp_genesis 2131 *
mp-wp_genesis 2132 * @since unknown
mp-wp_genesis 2133 *
mp-wp_genesis 2134 * @param unknown_type $id
mp-wp_genesis 2135 * @return unknown
mp-wp_genesis 2136 */
mp-wp_genesis 2137 function the_attachment_links( $id = false ) {
mp-wp_genesis 2138 $id = (int) $id;
mp-wp_genesis 2139 $post = & get_post( $id );
mp-wp_genesis 2140
mp-wp_genesis 2141 if ( $post->post_type != 'attachment' )
mp-wp_genesis 2142 return false;
mp-wp_genesis 2143
mp-wp_genesis 2144 $icon = get_attachment_icon( $post->ID );
mp-wp_genesis 2145 $attachment_data = wp_get_attachment_metadata( $id );
mp-wp_genesis 2146 $thumb = isset( $attachment_data['thumb'] );
mp-wp_genesis 2147 ?>
mp-wp_genesis 2148 <form id="the-attachment-links">
mp-wp_genesis 2149 <table>
mp-wp_genesis 2150 <col />
mp-wp_genesis 2151 <col class="widefat" />
mp-wp_genesis 2152 <tr>
mp-wp_genesis 2153 <th scope="row"><?php _e( 'URL' ) ?></th>
mp-wp_genesis 2154 <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><?php echo wp_get_attachment_url(); ?></textarea></td>
mp-wp_genesis 2155 </tr>
mp-wp_genesis 2156 <?php if ( $icon ) : ?>
mp-wp_genesis 2157 <tr>
mp-wp_genesis 2158 <th scope="row"><?php $thumb ? _e( 'Thumbnail linked to file' ) : _e( 'Image linked to file' ); ?></th>
mp-wp_genesis 2159 <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>
mp-wp_genesis 2160 </tr>
mp-wp_genesis 2161 <tr>
mp-wp_genesis 2162 <th scope="row"><?php $thumb ? _e( 'Thumbnail linked to page' ) : _e( 'Image linked to page' ); ?></th>
mp-wp_genesis 2163 <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>
mp-wp_genesis 2164 </tr>
mp-wp_genesis 2165 <?php else : ?>
mp-wp_genesis 2166 <tr>
mp-wp_genesis 2167 <th scope="row"><?php _e( 'Link to file' ) ?></th>
mp-wp_genesis 2168 <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>
mp-wp_genesis 2169 </tr>
mp-wp_genesis 2170 <tr>
mp-wp_genesis 2171 <th scope="row"><?php _e( 'Link to page' ) ?></th>
mp-wp_genesis 2172 <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>
mp-wp_genesis 2173 </tr>
mp-wp_genesis 2174 <?php endif; ?>
mp-wp_genesis 2175 </table>
mp-wp_genesis 2176 </form>
mp-wp_genesis 2177 <?php
mp-wp_genesis 2178 }
mp-wp_genesis 2179
mp-wp_genesis 2180 /**
mp-wp_genesis 2181 * {@internal Missing Short Description}}
mp-wp_genesis 2182 *
mp-wp_genesis 2183 * @since unknown
mp-wp_genesis 2184 *
mp-wp_genesis 2185 * @param unknown_type $default
mp-wp_genesis 2186 */
mp-wp_genesis 2187 function wp_dropdown_roles( $default = false ) {
mp-wp_genesis 2188 global $wp_roles;
mp-wp_genesis 2189 $p = '';
mp-wp_genesis 2190 $r = '';
mp-wp_genesis 2191 foreach( $wp_roles->role_names as $role => $name ) {
mp-wp_genesis 2192 $name = translate_with_context($name);
mp-wp_genesis 2193 if ( $default == $role ) // Make default first in list
mp-wp_genesis 2194 $p = "\n\t<option selected='selected' value='$role'>$name</option>";
mp-wp_genesis 2195 else
mp-wp_genesis 2196 $r .= "\n\t<option value='$role'>$name</option>";
mp-wp_genesis 2197 }
mp-wp_genesis 2198 echo $p . $r;
mp-wp_genesis 2199 }
mp-wp_genesis 2200
mp-wp_genesis 2201 /**
mp-wp_genesis 2202 * {@internal Missing Short Description}}
mp-wp_genesis 2203 *
mp-wp_genesis 2204 * @since unknown
mp-wp_genesis 2205 *
mp-wp_genesis 2206 * @param unknown_type $size
mp-wp_genesis 2207 * @return unknown
mp-wp_genesis 2208 */
mp-wp_genesis 2209 function wp_convert_hr_to_bytes( $size ) {
mp-wp_genesis 2210 $size = strtolower($size);
mp-wp_genesis 2211 $bytes = (int) $size;
mp-wp_genesis 2212 if ( strpos($size, 'k') !== false )
mp-wp_genesis 2213 $bytes = intval($size) * 1024;
mp-wp_genesis 2214 elseif ( strpos($size, 'm') !== false )
mp-wp_genesis 2215 $bytes = intval($size) * 1024 * 1024;
mp-wp_genesis 2216 elseif ( strpos($size, 'g') !== false )
mp-wp_genesis 2217 $bytes = intval($size) * 1024 * 1024 * 1024;
mp-wp_genesis 2218 return $bytes;
mp-wp_genesis 2219 }
mp-wp_genesis 2220
mp-wp_genesis 2221 /**
mp-wp_genesis 2222 * {@internal Missing Short Description}}
mp-wp_genesis 2223 *
mp-wp_genesis 2224 * @since unknown
mp-wp_genesis 2225 *
mp-wp_genesis 2226 * @param unknown_type $bytes
mp-wp_genesis 2227 * @return unknown
mp-wp_genesis 2228 */
mp-wp_genesis 2229 function wp_convert_bytes_to_hr( $bytes ) {
mp-wp_genesis 2230 $units = array( 0 => 'B', 1 => 'kB', 2 => 'MB', 3 => 'GB' );
mp-wp_genesis 2231 $log = log( $bytes, 1024 );
mp-wp_genesis 2232 $power = (int) $log;
mp-wp_genesis 2233 $size = pow(1024, $log - $power);
mp-wp_genesis 2234 return $size . $units[$power];
mp-wp_genesis 2235 }
mp-wp_genesis 2236
mp-wp_genesis 2237 /**
mp-wp_genesis 2238 * {@internal Missing Short Description}}
mp-wp_genesis 2239 *
mp-wp_genesis 2240 * @since unknown
mp-wp_genesis 2241 *
mp-wp_genesis 2242 * @return unknown
mp-wp_genesis 2243 */
mp-wp_genesis 2244 function wp_max_upload_size() {
mp-wp_genesis 2245 $u_bytes = wp_convert_hr_to_bytes( ini_get( 'upload_max_filesize' ) );
mp-wp_genesis 2246 $p_bytes = wp_convert_hr_to_bytes( ini_get( 'post_max_size' ) );
mp-wp_genesis 2247 $bytes = apply_filters( 'upload_size_limit', min($u_bytes, $p_bytes), $u_bytes, $p_bytes );
mp-wp_genesis 2248 return $bytes;
mp-wp_genesis 2249 }
mp-wp_genesis 2250
mp-wp_genesis 2251 /**
mp-wp_genesis 2252 * {@internal Missing Short Description}}
mp-wp_genesis 2253 *
mp-wp_genesis 2254 * @since unknown
mp-wp_genesis 2255 *
mp-wp_genesis 2256 * @param unknown_type $action
mp-wp_genesis 2257 */
mp-wp_genesis 2258 function wp_import_upload_form( $action ) {
mp-wp_genesis 2259 $bytes = apply_filters( 'import_upload_size_limit', wp_max_upload_size() );
mp-wp_genesis 2260 $size = wp_convert_bytes_to_hr( $bytes );
mp-wp_genesis 2261 ?>
mp-wp_genesis 2262 <form enctype="multipart/form-data" id="import-upload-form" method="post" action="<?php echo attribute_escape($action) ?>">
mp-wp_genesis 2263 <p>
mp-wp_genesis 2264 <?php wp_nonce_field('import-upload'); ?>
mp-wp_genesis 2265 <label for="upload"><?php _e( 'Choose a file from your computer:' ); ?></label> (<?php printf( __('Maximum size: %s' ), $size ); ?>)
mp-wp_genesis 2266 <input type="file" id="upload" name="import" size="25" />
mp-wp_genesis 2267 <input type="hidden" name="action" value="save" />
mp-wp_genesis 2268 <input type="hidden" name="max_file_size" value="<?php echo $bytes; ?>" />
mp-wp_genesis 2269 </p>
mp-wp_genesis 2270 <p class="submit">
mp-wp_genesis 2271 <input type="submit" class="button" value="<?php _e( 'Upload file and import' ); ?>" />
mp-wp_genesis 2272 </p>
mp-wp_genesis 2273 </form>
mp-wp_genesis 2274 <?php
mp-wp_genesis 2275 }
mp-wp_genesis 2276
mp-wp_genesis 2277 /**
mp-wp_genesis 2278 * {@internal Missing Short Description}}
mp-wp_genesis 2279 *
mp-wp_genesis 2280 * @since unknown
mp-wp_genesis 2281 */
mp-wp_genesis 2282 function wp_remember_old_slug() {
mp-wp_genesis 2283 global $post;
mp-wp_genesis 2284 $name = attribute_escape($post->post_name); // just in case
mp-wp_genesis 2285 if ( strlen($name) )
mp-wp_genesis 2286 echo '<input type="hidden" id="wp-old-slug" name="wp-old-slug" value="' . $name . '" />';
mp-wp_genesis 2287 }
mp-wp_genesis 2288
mp-wp_genesis 2289 /**
mp-wp_genesis 2290 * Add a meta box to an edit form.
mp-wp_genesis 2291 *
mp-wp_genesis 2292 * @since 2.5.0
mp-wp_genesis 2293 *
mp-wp_genesis 2294 * @param string $id String for use in the 'id' attribute of tags.
mp-wp_genesis 2295 * @param string $title Title of the meta box.
mp-wp_genesis 2296 * @param string $callback Function that fills the box with the desired content. The function should echo its output.
mp-wp_genesis 2297 * @param string $page The type of edit page on which to show the box (post, page, link).
mp-wp_genesis 2298 * @param string $context The context within the page where the boxes should show ('normal', 'advanced').
mp-wp_genesis 2299 * @param string $priority The priority within the context where the boxes should show ('high', 'low').
mp-wp_genesis 2300 */
mp-wp_genesis 2301 function add_meta_box($id, $title, $callback, $page, $context = 'advanced', $priority = 'default') {
mp-wp_genesis 2302 global $wp_meta_boxes;
mp-wp_genesis 2303
mp-wp_genesis 2304 if ( !isset($wp_meta_boxes) )
mp-wp_genesis 2305 $wp_meta_boxes = array();
mp-wp_genesis 2306 if ( !isset($wp_meta_boxes[$page]) )
mp-wp_genesis 2307 $wp_meta_boxes[$page] = array();
mp-wp_genesis 2308 if ( !isset($wp_meta_boxes[$page][$context]) )
mp-wp_genesis 2309 $wp_meta_boxes[$page][$context] = array();
mp-wp_genesis 2310
mp-wp_genesis 2311 foreach ( array_keys($wp_meta_boxes[$page]) as $a_context ) {
mp-wp_genesis 2312 foreach ( array('high', 'core', 'default', 'low') as $a_priority ) {
mp-wp_genesis 2313 if ( !isset($wp_meta_boxes[$page][$a_context][$a_priority][$id]) )
mp-wp_genesis 2314 continue;
mp-wp_genesis 2315
mp-wp_genesis 2316 // If a core box was previously added or removed by a plugin, don't add.
mp-wp_genesis 2317 if ( 'core' == $priority ) {
mp-wp_genesis 2318 // If core box previously deleted, don't add
mp-wp_genesis 2319 if ( false === $wp_meta_boxes[$page][$a_context][$a_priority][$id] )
mp-wp_genesis 2320 return;
mp-wp_genesis 2321 // If box was added with default priority, give it core priority to maintain sort order
mp-wp_genesis 2322 if ( 'default' == $a_priority ) {
mp-wp_genesis 2323 $wp_meta_boxes[$page][$a_context]['core'][$id] = $wp_meta_boxes[$page][$a_context]['default'][$id];
mp-wp_genesis 2324 unset($wp_meta_boxes[$page][$a_context]['default'][$id]);
mp-wp_genesis 2325 }
mp-wp_genesis 2326 return;
mp-wp_genesis 2327 }
mp-wp_genesis 2328 // If no priority given and id already present, use existing priority
mp-wp_genesis 2329 if ( empty($priority) ) {
mp-wp_genesis 2330 $priority = $a_priority;
mp-wp_genesis 2331 // 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.
mp-wp_genesis 2332 } elseif ( 'sorted' == $priority ) {
mp-wp_genesis 2333 $title = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['title'];
mp-wp_genesis 2334 $callback = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['callback'];
mp-wp_genesis 2335 }
mp-wp_genesis 2336 // An id can be in only one priority and one context
mp-wp_genesis 2337 if ( $priority != $a_priority || $context != $a_context )
mp-wp_genesis 2338 unset($wp_meta_boxes[$page][$a_context][$a_priority][$id]);
mp-wp_genesis 2339 }
mp-wp_genesis 2340 }
mp-wp_genesis 2341
mp-wp_genesis 2342 if ( empty($priority) )
mp-wp_genesis 2343 $priority = 'low';
mp-wp_genesis 2344
mp-wp_genesis 2345 if ( !isset($wp_meta_boxes[$page][$context][$priority]) )
mp-wp_genesis 2346 $wp_meta_boxes[$page][$context][$priority] = array();
mp-wp_genesis 2347
mp-wp_genesis 2348 $wp_meta_boxes[$page][$context][$priority][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback);
mp-wp_genesis 2349 }
mp-wp_genesis 2350
mp-wp_genesis 2351 /**
mp-wp_genesis 2352 * {@internal Missing Short Description}}
mp-wp_genesis 2353 *
mp-wp_genesis 2354 * @since unknown
mp-wp_genesis 2355 *
mp-wp_genesis 2356 * @param unknown_type $page
mp-wp_genesis 2357 * @param unknown_type $context
mp-wp_genesis 2358 * @param unknown_type $object
mp-wp_genesis 2359 * @return int number of meta_boxes
mp-wp_genesis 2360 */
mp-wp_genesis 2361 function do_meta_boxes($page, $context, $object) {
mp-wp_genesis 2362 global $wp_meta_boxes;
mp-wp_genesis 2363 static $already_sorted = false;
mp-wp_genesis 2364
mp-wp_genesis 2365 //do_action('do_meta_boxes', $page, $context, $object);
mp-wp_genesis 2366
mp-wp_genesis 2367 $hidden = get_hidden_meta_boxes($page);
mp-wp_genesis 2368
mp-wp_genesis 2369 echo "<div id='$context-sortables' class='meta-box-sortables'>\n";
mp-wp_genesis 2370
mp-wp_genesis 2371 $i = 0;
mp-wp_genesis 2372 do {
mp-wp_genesis 2373 // Grab the ones the user has manually sorted. Pull them out of their previous context/priority and into the one the user chose
mp-wp_genesis 2374 if ( !$already_sorted && $sorted = get_user_option( "meta-box-order_$page", 0, false ) ) {
mp-wp_genesis 2375 foreach ( $sorted as $box_context => $ids )
mp-wp_genesis 2376 foreach ( explode(',', $ids) as $id )
mp-wp_genesis 2377 if ( $id )
mp-wp_genesis 2378 add_meta_box( $id, null, null, $page, $box_context, 'sorted' );
mp-wp_genesis 2379 }
mp-wp_genesis 2380 $already_sorted = true;
mp-wp_genesis 2381
mp-wp_genesis 2382 if ( !isset($wp_meta_boxes) || !isset($wp_meta_boxes[$page]) || !isset($wp_meta_boxes[$page][$context]) )
mp-wp_genesis 2383 break;
mp-wp_genesis 2384
mp-wp_genesis 2385 foreach ( array('high', 'sorted', 'core', 'default', 'low') as $priority ) {
mp-wp_genesis 2386 if ( isset($wp_meta_boxes[$page][$context][$priority]) ) {
mp-wp_genesis 2387 foreach ( (array) $wp_meta_boxes[$page][$context][$priority] as $box ) {
mp-wp_genesis 2388 if ( false == $box || ! $box['title'] )
mp-wp_genesis 2389 continue;
mp-wp_genesis 2390 $i++;
mp-wp_genesis 2391 $style = '';
mp-wp_genesis 2392 if ( in_array($box['id'], $hidden) )
mp-wp_genesis 2393 $style = 'style="display:none;"';
mp-wp_genesis 2394 echo '<div id="' . $box['id'] . '" class="postbox ' . postbox_classes($box['id'], $page) . '" ' . $style . '>' . "\n";
mp-wp_genesis 2395 echo "<h3 class='hndle'><span>{$box['title']}</span></h3>\n";
mp-wp_genesis 2396 echo '<div class="inside">' . "\n";
mp-wp_genesis 2397 call_user_func($box['callback'], $object, $box);
mp-wp_genesis 2398 echo "</div>\n";
mp-wp_genesis 2399 echo "</div>\n";
mp-wp_genesis 2400 }
mp-wp_genesis 2401 }
mp-wp_genesis 2402 }
mp-wp_genesis 2403 } while(0);
mp-wp_genesis 2404
mp-wp_genesis 2405 echo "</div>";
mp-wp_genesis 2406
mp-wp_genesis 2407 return $i;
mp-wp_genesis 2408
mp-wp_genesis 2409 }
mp-wp_genesis 2410
mp-wp_genesis 2411 /**
mp-wp_genesis 2412 * Remove a meta box from an edit form.
mp-wp_genesis 2413 *
mp-wp_genesis 2414 * @since 2.6.0
mp-wp_genesis 2415 *
mp-wp_genesis 2416 * @param string $id String for use in the 'id' attribute of tags.
mp-wp_genesis 2417 * @param string $page The type of edit page on which to show the box (post, page, link).
mp-wp_genesis 2418 * @param string $context The context within the page where the boxes should show ('normal', 'advanced').
mp-wp_genesis 2419 */
mp-wp_genesis 2420 function remove_meta_box($id, $page, $context) {
mp-wp_genesis 2421 global $wp_meta_boxes;
mp-wp_genesis 2422
mp-wp_genesis 2423 if ( !isset($wp_meta_boxes) )
mp-wp_genesis 2424 $wp_meta_boxes = array();
mp-wp_genesis 2425 if ( !isset($wp_meta_boxes[$page]) )
mp-wp_genesis 2426 $wp_meta_boxes[$page] = array();
mp-wp_genesis 2427 if ( !isset($wp_meta_boxes[$page][$context]) )
mp-wp_genesis 2428 $wp_meta_boxes[$page][$context] = array();
mp-wp_genesis 2429
mp-wp_genesis 2430 foreach ( array('high', 'core', 'default', 'low') as $priority )
mp-wp_genesis 2431 $wp_meta_boxes[$page][$context][$priority][$id] = false;
mp-wp_genesis 2432 }
mp-wp_genesis 2433
mp-wp_genesis 2434 /**
mp-wp_genesis 2435 * {@internal Missing Short Description}}
mp-wp_genesis 2436 *
mp-wp_genesis 2437 * @since unknown
mp-wp_genesis 2438 *
mp-wp_genesis 2439 * @param unknown_type $page
mp-wp_genesis 2440 */
mp-wp_genesis 2441 function meta_box_prefs($page) {
mp-wp_genesis 2442 global $wp_meta_boxes;
mp-wp_genesis 2443
mp-wp_genesis 2444 if ( empty($wp_meta_boxes[$page]) )
mp-wp_genesis 2445 return;
mp-wp_genesis 2446
mp-wp_genesis 2447 $hidden = get_hidden_meta_boxes($page);
mp-wp_genesis 2448
mp-wp_genesis 2449 foreach ( array_keys($wp_meta_boxes[$page]) as $context ) {
mp-wp_genesis 2450 foreach ( array_keys($wp_meta_boxes[$page][$context]) as $priority ) {
mp-wp_genesis 2451 foreach ( $wp_meta_boxes[$page][$context][$priority] as $box ) {
mp-wp_genesis 2452 if ( false == $box || ! $box['title'] )
mp-wp_genesis 2453 continue;
mp-wp_genesis 2454 // Submit box cannot be hidden
mp-wp_genesis 2455 if ( 'submitdiv' == $box['id'] || 'linksubmitdiv' == $box['id'] )
mp-wp_genesis 2456 continue;
mp-wp_genesis 2457 $box_id = $box['id'];
mp-wp_genesis 2458 echo '<label for="' . $box_id . '-hide">';
mp-wp_genesis 2459 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"' : '') . ' />';
mp-wp_genesis 2460 echo "{$box['title']}</label>\n";
mp-wp_genesis 2461 }
mp-wp_genesis 2462 }
mp-wp_genesis 2463 }
mp-wp_genesis 2464 }
mp-wp_genesis 2465
mp-wp_genesis 2466 function get_hidden_meta_boxes($page) {
mp-wp_genesis 2467 $hidden = (array) get_user_option( "meta-box-hidden_$page", 0, false );
mp-wp_genesis 2468
mp-wp_genesis 2469 // Hide slug boxes by default
mp-wp_genesis 2470 if ( empty($hidden[0]) ) {
mp-wp_genesis 2471 if ( 'page' == $page )
mp-wp_genesis 2472 $hidden = array('pageslugdiv');
mp-wp_genesis 2473 elseif ( 'post' == $page )
mp-wp_genesis 2474 $hidden = array('slugdiv');
mp-wp_genesis 2475 }
mp-wp_genesis 2476
mp-wp_genesis 2477 return $hidden;
mp-wp_genesis 2478 }
mp-wp_genesis 2479
mp-wp_genesis 2480 /**
mp-wp_genesis 2481 * Add a new section to a settings page.
mp-wp_genesis 2482 *
mp-wp_genesis 2483 * @since 2.7.0
mp-wp_genesis 2484 *
mp-wp_genesis 2485 * @param string $id String for use in the 'id' attribute of tags.
mp-wp_genesis 2486 * @param string $title Title of the section.
mp-wp_genesis 2487 * @param string $callback Function that fills the section with the desired content. The function should echo its output.
mp-wp_genesis 2488 * @param string $page The type of settings page on which to show the section (general, reading, writing, ...).
mp-wp_genesis 2489 */
mp-wp_genesis 2490 function add_settings_section($id, $title, $callback, $page) {
mp-wp_genesis 2491 global $wp_settings_sections;
mp-wp_genesis 2492
mp-wp_genesis 2493 if ( !isset($wp_settings_sections) )
mp-wp_genesis 2494 $wp_settings_sections = array();
mp-wp_genesis 2495 if ( !isset($wp_settings_sections[$page]) )
mp-wp_genesis 2496 $wp_settings_sections[$page] = array();
mp-wp_genesis 2497 if ( !isset($wp_settings_sections[$page][$id]) )
mp-wp_genesis 2498 $wp_settings_sections[$page][$id] = array();
mp-wp_genesis 2499
mp-wp_genesis 2500 $wp_settings_sections[$page][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback);
mp-wp_genesis 2501 }
mp-wp_genesis 2502
mp-wp_genesis 2503 /**
mp-wp_genesis 2504 * Add a new field to a settings page.
mp-wp_genesis 2505 *
mp-wp_genesis 2506 * @since 2.7.0
mp-wp_genesis 2507 *
mp-wp_genesis 2508 * @param string $id String for use in the 'id' attribute of tags.
mp-wp_genesis 2509 * @param string $title Title of the field.
mp-wp_genesis 2510 * @param string $callback Function that fills the field with the desired content. The function should echo its output.
mp-wp_genesis 2511 * @param string $page The type of settings page on which to show the field (general, reading, writing, ...).
mp-wp_genesis 2512 * @param string $section The section of the settingss page in which to show the box (default, ...).
mp-wp_genesis 2513 * @param array $args Additional arguments
mp-wp_genesis 2514 */
mp-wp_genesis 2515 function add_settings_field($id, $title, $callback, $page, $section = 'default', $args = array()) {
mp-wp_genesis 2516 global $wp_settings_fields;
mp-wp_genesis 2517
mp-wp_genesis 2518 if ( !isset($wp_settings_fields) )
mp-wp_genesis 2519 $wp_settings_fields = array();
mp-wp_genesis 2520 if ( !isset($wp_settings_fields[$page]) )
mp-wp_genesis 2521 $wp_settings_fields[$page] = array();
mp-wp_genesis 2522 if ( !isset($wp_settings_fields[$page][$section]) )
mp-wp_genesis 2523 $wp_settings_fields[$page][$section] = array();
mp-wp_genesis 2524
mp-wp_genesis 2525 $wp_settings_fields[$page][$section][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback, 'args' => $args);
mp-wp_genesis 2526 }
mp-wp_genesis 2527
mp-wp_genesis 2528 /**
mp-wp_genesis 2529 * {@internal Missing Short Description}}
mp-wp_genesis 2530 *
mp-wp_genesis 2531 * @since unknown
mp-wp_genesis 2532 *
mp-wp_genesis 2533 * @param unknown_type $page
mp-wp_genesis 2534 */
mp-wp_genesis 2535 function do_settings_sections($page) {
mp-wp_genesis 2536 global $wp_settings_sections, $wp_settings_fields;
mp-wp_genesis 2537
mp-wp_genesis 2538 if ( !isset($wp_settings_sections) || !isset($wp_settings_sections[$page]) )
mp-wp_genesis 2539 return;
mp-wp_genesis 2540
mp-wp_genesis 2541 foreach ( (array) $wp_settings_sections[$page] as $section ) {
mp-wp_genesis 2542 echo "<h3>{$section['title']}</h3>\n";
mp-wp_genesis 2543 call_user_func($section['callback'], $section);
mp-wp_genesis 2544 if ( !isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section['id']]) )
mp-wp_genesis 2545 continue;
mp-wp_genesis 2546 echo '<table class="form-table">';
mp-wp_genesis 2547 do_settings_fields($page, $section['id']);
mp-wp_genesis 2548 echo '</table>';
mp-wp_genesis 2549 }
mp-wp_genesis 2550 }
mp-wp_genesis 2551
mp-wp_genesis 2552 /**
mp-wp_genesis 2553 * {@internal Missing Short Description}}
mp-wp_genesis 2554 *
mp-wp_genesis 2555 * @since unknown
mp-wp_genesis 2556 *
mp-wp_genesis 2557 * @param unknown_type $page
mp-wp_genesis 2558 * @param unknown_type $section
mp-wp_genesis 2559 */
mp-wp_genesis 2560 function do_settings_fields($page, $section) {
mp-wp_genesis 2561 global $wp_settings_fields;
mp-wp_genesis 2562
mp-wp_genesis 2563 if ( !isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section]) )
mp-wp_genesis 2564 return;
mp-wp_genesis 2565
mp-wp_genesis 2566 foreach ( (array) $wp_settings_fields[$page][$section] as $field ) {
mp-wp_genesis 2567 echo '<tr valign="top">';
mp-wp_genesis 2568 if ( !empty($field['args']['label_for']) )
mp-wp_genesis 2569 echo '<th scope="row"><label for="' . $field['args']['label_for'] . '">' . $field['title'] . '</label></th>';
mp-wp_genesis 2570 else
mp-wp_genesis 2571 echo '<th scope="row">' . $field['title'] . '</th>';
mp-wp_genesis 2572 echo '<td>';
mp-wp_genesis 2573 call_user_func($field['callback']);
mp-wp_genesis 2574 echo '</td>';
mp-wp_genesis 2575 echo '</tr>';
mp-wp_genesis 2576 }
mp-wp_genesis 2577 }
mp-wp_genesis 2578
mp-wp_genesis 2579 /**
mp-wp_genesis 2580 * {@internal Missing Short Description}}
mp-wp_genesis 2581 *
mp-wp_genesis 2582 * @since unknown
mp-wp_genesis 2583 *
mp-wp_genesis 2584 * @param unknown_type $page
mp-wp_genesis 2585 */
mp-wp_genesis 2586 function manage_columns_prefs($page) {
mp-wp_genesis 2587 $columns = get_column_headers($page);
mp-wp_genesis 2588
mp-wp_genesis 2589 $hidden = get_hidden_columns($page);
mp-wp_genesis 2590
mp-wp_genesis 2591 foreach ( $columns as $column => $title ) {
mp-wp_genesis 2592 // Can't hide these
mp-wp_genesis 2593 if ( 'cb' == $column || 'title' == $column || 'name' == $column || 'username' == $column || 'media' == $column || 'comment' == $column )
mp-wp_genesis 2594 continue;
mp-wp_genesis 2595 if ( empty($title) )
mp-wp_genesis 2596 continue;
mp-wp_genesis 2597
mp-wp_genesis 2598 if ( 'comments' == $column )
mp-wp_genesis 2599 $title = __('Comments');
mp-wp_genesis 2600 $id = "$column-hide";
mp-wp_genesis 2601 echo '<label for="' . $id . '">';
mp-wp_genesis 2602 echo '<input class="hide-column-tog" name="' . $id . '" type="checkbox" id="' . $id . '" value="' . $column . '"' . (! in_array($column, $hidden) ? ' checked="checked"' : '') . ' />';
mp-wp_genesis 2603 echo "$title</label>\n";
mp-wp_genesis 2604 }
mp-wp_genesis 2605 }
mp-wp_genesis 2606
mp-wp_genesis 2607 /**
mp-wp_genesis 2608 * Display the post password.
mp-wp_genesis 2609 *
mp-wp_genesis 2610 * The password is passed through {@link attribute_escape()} to ensure that it
mp-wp_genesis 2611 * is safe for placing in an html attribute.
mp-wp_genesis 2612 *
mp-wp_genesis 2613 * @uses attribute_escape
mp-wp_genesis 2614 * @since 2.7.0
mp-wp_genesis 2615 */
mp-wp_genesis 2616 function the_post_password() {
mp-wp_genesis 2617 global $post;
mp-wp_genesis 2618 if ( isset( $post->post_password ) ) echo attribute_escape( $post->post_password );
mp-wp_genesis 2619 }
mp-wp_genesis 2620
mp-wp_genesis 2621
mp-wp_genesis 2622 /**
mp-wp_genesis 2623 * Get the post title.
mp-wp_genesis 2624 *
mp-wp_genesis 2625 * The post title is fetched and if it is blank then a default string is
mp-wp_genesis 2626 * returned.
mp-wp_genesis 2627 *
mp-wp_genesis 2628 * @since 2.7.0
mp-wp_genesis 2629 * @param int $id The post id. If not supplied the global $post is used.
mp-wp_genesis 2630 *
mp-wp_genesis 2631 */
mp-wp_genesis 2632 function _draft_or_post_title($post_id = 0)
mp-wp_genesis 2633 {
mp-wp_genesis 2634 $title = get_the_title($post_id);
mp-wp_genesis 2635 if ( empty($title) )
mp-wp_genesis 2636 $title = __('(no title)');
mp-wp_genesis 2637 return $title;
mp-wp_genesis 2638 }
mp-wp_genesis 2639
mp-wp_genesis 2640 /**
mp-wp_genesis 2641 * Display the search query.
mp-wp_genesis 2642 *
mp-wp_genesis 2643 * A simple wrapper to display the "s" parameter in a GET URI. This function
mp-wp_genesis 2644 * should only be used when {@link the_search_query()} cannot.
mp-wp_genesis 2645 *
mp-wp_genesis 2646 * @uses attribute_escape
mp-wp_genesis 2647 * @since 2.7.0
mp-wp_genesis 2648 *
mp-wp_genesis 2649 */
mp-wp_genesis 2650 function _admin_search_query() {
mp-wp_genesis 2651 echo isset($_GET['s']) ? attribute_escape( stripslashes( $_GET['s'] ) ) : '';
mp-wp_genesis 2652 }
mp-wp_genesis 2653
mp-wp_genesis 2654 function _post_states($post) {
mp-wp_genesis 2655 $post_states = array();
mp-wp_genesis 2656 if ( isset($_GET['post_status']) )
mp-wp_genesis 2657 $post_status = $_GET['post_status'];
mp-wp_genesis 2658 else
mp-wp_genesis 2659 $post_status = '';
mp-wp_genesis 2660
mp-wp_genesis 2661 if ( !empty($post->post_password) )
mp-wp_genesis 2662 $post_states[] = __('Password protected');
mp-wp_genesis 2663 if ( 'private' == $post->post_status && 'private' != $post_status )
mp-wp_genesis 2664 $post_states[] = __('Private');
mp-wp_genesis 2665 if ( 'draft' == $post->post_status && 'draft' != $post_status )
mp-wp_genesis 2666 $post_states[] = __('Draft');
mp-wp_genesis 2667 if ( 'pending' == $post->post_status && 'pending' != $post_status )
mp-wp_genesis 2668 $post_states[] = __('Pending');
mp-wp_genesis 2669
mp-wp_genesis 2670 if ( ! empty($post_states) ) {
mp-wp_genesis 2671 $state_count = count($post_states);
mp-wp_genesis 2672 $i = 0;
mp-wp_genesis 2673 echo ' - ';
mp-wp_genesis 2674 foreach ( $post_states as $state ) {
mp-wp_genesis 2675 ++$i;
mp-wp_genesis 2676 ( $i == $state_count ) ? $sep = '' : $sep = ', ';
mp-wp_genesis 2677 echo "<span class='post-state'>$state$sep</span>";
mp-wp_genesis 2678 }
mp-wp_genesis 2679 }
mp-wp_genesis 2680 }
mp-wp_genesis 2681
mp-wp_genesis 2682 function screen_icon($name = '') {
mp-wp_genesis 2683 global $parent_file, $hook_suffix;
mp-wp_genesis 2684
mp-wp_genesis 2685 if ( empty($name) ) {
mp-wp_genesis 2686 if ( isset($parent_file) && !empty($parent_file) )
mp-wp_genesis 2687 $name = substr($parent_file, 0, -4);
mp-wp_genesis 2688 else
mp-wp_genesis 2689 $name = str_replace(array('.php', '-new', '-add'), '', $hook_suffix);
mp-wp_genesis 2690 }
mp-wp_genesis 2691 unset($hook_suffix);
mp-wp_genesis 2692 }
mp-wp_genesis 2693
mp-wp_genesis 2694 ?>