0); if ( !empty($_GET['s']) ) $args['search'] = $_GET['s']; $categories = get_categories( $args ); } if ( !$categories ) return false; $children = _get_term_hierarchy('category'); $start = ($page - 1) * $per_page; $end = $start + $per_page; $i = -1; ob_start(); foreach ( $categories as $category ) { if ( $count >= $end ) break; $i++; if ( $category->parent != $parent ) continue; // If the page starts in a subtree, print the parents. if ( $count == $start && $category->parent > 0 ) { $my_parents = array(); $my_parent = $category->parent; while ( $my_parent) { $my_parent = get_category($my_parent); $my_parents[] = $my_parent; if ( !$my_parent->parent ) break; $my_parent = $my_parent->parent; } $num_parents = count($my_parents); while( $my_parent = array_pop($my_parents) ) { echo "\t" . _cat_row( $my_parent, $level - $num_parents ); $num_parents--; } } if ( $count >= $start ) echo "\t" . _cat_row( $category, $level ); unset($categories[$i]); // Prune the working set $count++; if ( isset($children[$category->term_id]) ) _cat_rows( $categories, $count, $category->term_id, $level + 1, $page, $per_page ); } $output = ob_get_contents(); ob_end_clean(); $output = apply_filters('cat_rows', $output); echo $output; } function _cat_row( $category, $level, $name_override = false ) { global $class; $category = get_category( $category ); $pad = str_repeat( '— ', $level ); $name = ( $name_override ? $name_override : $pad . ' ' . $category->name ); if ( current_user_can( 'manage_categories' ) ) { $edit = "name)) . "'>$name"; } else { $edit = $name; } $class = " class='alternate'" == $class ? '' : " class='alternate'"; $category->count = number_format_i18n( $category->count ); $posts_count = ( $category->count > 0 ) ? "$category->count" : $category->count; $output = "



';
}
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false)
add_action( 'in_admin_footer', 'browse_happy' );
function the_attachment_links( $id = false ) {
$id = (int) $id;
$post = & get_post( $id );
if ( $post->post_type != 'attachment' )
return false;
$icon = get_attachment_icon( $post->ID );
$attachment_data = wp_get_attachment_metadata( $id );
$thumb = isset( $attachment_data['thumb'] );
?>
role_names as $role => $name ) {
$name = translate_with_context($name);
if ( $default == $role ) // Make default first in list
$p = "\n\t";
else
$r .= "\n\t";
}
echo $p . $r;
}
function wp_convert_hr_to_bytes( $size ) {
$size = strtolower($size);
$bytes = (int) $size;
if ( strpos($size, 'k') !== false )
$bytes = intval($size) * 1024;
elseif ( strpos($size, 'm') !== false )
$bytes = intval($size) * 1024 * 1024;
elseif ( strpos($size, 'g') !== false )
$bytes = intval($size) * 1024 * 1024 * 1024;
return $bytes;
}
function wp_convert_bytes_to_hr( $bytes ) {
$units = array( 0 => 'B', 1 => 'kB', 2 => 'MB', 3 => 'GB' );
$log = log( $bytes, 1024 );
$power = (int) $log;
$size = pow(1024, $log - $power);
return $size . $units[$power];
}
function wp_max_upload_size() {
$u_bytes = wp_convert_hr_to_bytes( ini_get( 'upload_max_filesize' ) );
$p_bytes = wp_convert_hr_to_bytes( ini_get( 'post_max_size' ) );
$bytes = apply_filters( 'upload_size_limit', min($u_bytes, $p_bytes), $u_bytes, $p_bytes );
return $bytes;
}
function wp_import_upload_form( $action ) {
$bytes = apply_filters( 'import_upload_size_limit', wp_max_upload_size() );
$size = wp_convert_bytes_to_hr( $bytes );
?>
post_name); // just in case
if ( strlen($name) )
echo '';
}
/**
* add_meta_box() - Add a meta box to an edit form
*
* @since 2.5
*
* @param string $id String for use in the 'id' attribute of tags.
* @param string $title Title of the meta box
* @param string $callback Function that fills the box with the desired content. The function should echo its output.
* @param string $page The type of edit page on which to show the box (post, page, link)
* @param string $context The context within the page where the boxes should show ('normal', 'advanced')
* @param string $priority The priority within the context where the boxes should show ('high', 'low')
*/
function add_meta_box($id, $title, $callback, $page, $context = 'advanced', $priority = 'default') {
global $wp_meta_boxes;
if ( !isset($wp_meta_boxes) )
$wp_meta_boxes = array();
if ( !isset($wp_meta_boxes[$page]) )
$wp_meta_boxes[$page] = array();
if ( !isset($wp_meta_boxes[$page][$context]) )
$wp_meta_boxes[$page][$context] = array();
foreach ( array('high', 'core', 'default', 'low') as $a_priority ) {
if ( !isset($wp_meta_boxes[$page][$context][$a_priority][$id]) )
continue;
// If a core box was previously added or removed by a plugin, don't add.
if ( 'core' == $priority ) {
// If core box previously deleted, don't add
if ( false === $wp_meta_boxes[$page][$context][$a_priority][$id] )
return;
// If box was added with default priority, give it core priority to maintain sort order
if ( 'default' == $a_priority ) {
$wp_meta_boxes[$page][$context]['core'][$id] = $wp_meta_boxes[$page][$context]['default'][$id];
unset($wp_meta_boxes[$page][$context]['default'][$id]);
}
return;
}
// If no priority given and id already present, use existing priority
if ( empty($priority) )
$priority = $a_priority;
// An id can be in only one priority
if ( $priority != $a_priority )
unset($wp_meta_boxes[$page][$context][$a_priority][$id]);
}
if ( empty($priority) )
$priority = low;
if ( !isset($wp_meta_boxes[$page][$context][$priority]) )
$wp_meta_boxes[$page][$context][$priority] = array();
$wp_meta_boxes[$page][$context][$priority][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback);
}
function do_meta_boxes($page, $context, $object) {
global $wp_meta_boxes;
do_action('do_meta_boxes', $page, $context, $object);
if ( !isset($wp_meta_boxes) || !isset($wp_meta_boxes[$page]) || !isset($wp_meta_boxes[$page][$context]) )
return;
foreach ( array('high', 'core', 'default', 'low') as $priority ) {
if ( ! isset( $wp_meta_boxes[$page][$context][$priority] ) )
continue;
foreach ( (array) $wp_meta_boxes[$page][$context][$priority] as $box ) {
if ( false === $box )
continue;
echo '