";
}
function _list_meta_row( $entry, &$count ) {
$r = '';
++ $count;
if ( $count % 2 )
$style = 'alternate';
else
$style = '';
if ('_' == $entry['meta_key'] { 0 } )
$style .= ' hidden';
if ( is_serialized( $entry['meta_value'] ) ) {
if ( is_serialized_string( $entry['meta_value'] ) ) {
// this is a serialized string, so we should display it
$entry['meta_value'] = maybe_unserialize( $entry['meta_value'] );
} else {
// this is a serialized array/object so we should NOT display it
--$count;
return;
}
}
$entry['meta_key'] = attribute_escape($entry['meta_key']);
$entry['meta_value'] = attribute_escape($entry['meta_value']);
$entry['meta_id'] = (int) $entry['meta_id'];
$r .= "\n\t
";
$r .= "\n\t\t
";
$r .= "\n\t\t
";
$r .= "\n\t\t
";
$r .= "\n\t\t";
$r .= "
\n\t
";
return $r;
}
function meta_form() {
global $wpdb;
$limit = (int) apply_filters( 'postmeta_form_limit', 30 );
$keys = $wpdb->get_col( "
SELECT meta_key
FROM $wpdb->postmeta
WHERE meta_key NOT LIKE '\_%'
GROUP BY meta_key
ORDER BY meta_id DESC
LIMIT $limit" );
if ( $keys )
natcasesort($keys);
?>
post_status, array('draft', 'pending') ) && (!$post->post_date || '0000-00-00 00:00:00' == $post->post_date ) ) ? false : true;
$tab_index_attribute = '';
if ( (int) $tab_index > 0 )
$tab_index_attribute = " tabindex=\"$tab_index\"";
echo '
$template";
endforeach;
}
function parent_dropdown( $default = 0, $parent = 0, $level = 0 ) {
global $wpdb, $post_ID;
$items = $wpdb->get_results( "SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = $parent AND post_type = 'page' ORDER BY menu_order" );
if ( $items ) {
foreach ( $items as $item ) {
// A page cannot be its own parent.
if (!empty ( $post_ID ) ) {
if ( $item->ID == $post_ID ) {
continue;
}
}
$pad = str_repeat( ' ', $level * 3 );
if ( $item->ID == $default)
$current = ' selected="selected"';
else
$current = '';
echo "\n\t";
parent_dropdown( $default, $item->ID, $level +1 );
}
} else {
return false;
}
}
function browse_happy() {
$getit = __( 'WordPress recommends a better browser' );
echo '
';
}
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 )
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')
*/
function add_meta_box($id, $title, $callback, $page, $context = 'advanced') {
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();
$wp_meta_boxes[$page][$context][] = array('id' => $id, 'title' => $title, 'callback' => $callback);
}
function do_meta_boxes($page, $context, $object) {
global $wp_meta_boxes;
if ( !isset($wp_meta_boxes) || !isset($wp_meta_boxes[$page]) || !isset($wp_meta_boxes[$page][$context]) )
return;
foreach ( (array) $wp_meta_boxes[$page][$context] as $box ) {
echo '