";
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 ' ';
$time_adj = time() + (get_option( 'gmt_offset' ) * 3600 );
$post_date = ($for_post) ? $post->post_date : $comment->comment_date;
$jj = ($edit) ? mysql2date( 'd', $post_date ) : gmdate( 'd', $time_adj );
$mm = ($edit) ? mysql2date( 'm', $post_date ) : gmdate( 'm', $time_adj );
$aa = ($edit) ? mysql2date( 'Y', $post_date ) : gmdate( 'Y', $time_adj );
$hh = ($edit) ? mysql2date( 'H', $post_date ) : gmdate( 'H', $time_adj );
$mn = ($edit) ? mysql2date( 'i', $post_date ) : gmdate( 'i', $time_adj );
$ss = ($edit) ? mysql2date( 's', $post_date ) : gmdate( 's', $time_adj );
$month = "';
$day = '';
$year = '';
$hour = '';
$minute = '';
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);
if ( $multi ) return;
echo "\n\n";
foreach ( array('mm', 'jj', 'aa', 'hh', 'mn') as $timeunit )
echo '' . "\n";
?>
$template";
endforeach;
}
function parent_dropdown( $default = 0, $parent = 0, $level = 0 ) {
global $wpdb, $post_ID;
$items = $wpdb->get_results( $wpdb->prepare("SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' ORDER BY menu_order", $parent) );
if ( $items ) {
foreach ( $items as $item ) {
// A page cannot be its own parent.
if (!empty ( $post_ID ) ) {
if ( $item->ID == $post_ID ) {
continue;
}
}
$pad = str_repeat( ' ', $level * 3 );
if ( $item->ID == $default)
$current = ' selected="selected"';
else
$current = '';
echo "\n\t";
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 ) {
$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_keys($wp_meta_boxes[$page]) as $a_context ) {
foreach ( array('high', 'core', 'default', 'low') as $a_priority ) {
if ( !isset($wp_meta_boxes[$page][$a_context][$a_priority][$id]) )
continue;
// If a core box was previously added or removed by a plugin, don't add.
if ( 'core' == $priority ) {
// If core box previously deleted, don't add
if ( false === $wp_meta_boxes[$page][$a_context][$a_priority][$id] )
return;
// If box was added with default priority, give it core priority to maintain sort order
if ( 'default' == $a_priority ) {
$wp_meta_boxes[$page][$a_context]['core'][$id] = $wp_meta_boxes[$page][$a_context]['default'][$id];
unset($wp_meta_boxes[$page][$a_context]['default'][$id]);
}
return;
}
// If no priority given and id already present, use existing priority
if ( empty($priority) ) {
$priority = $a_priority;
// else if we're adding to the sorted priortiy, we don't know the title or callback. Glab them from the previously added context/priority.
} elseif ( 'sorted' == $priority ) {
$title = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['title'];
$callback = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['callback'];
}
// An id can be in only one priority and one context
if ( $priority != $a_priority || $context != $a_context )
unset($wp_meta_boxes[$page][$a_context][$a_priority][$id]);
}
}
if ( empty($priority) )
$priority = 'low';
if ( !isset($wp_meta_boxes[$page][$context][$priority]) )
$wp_meta_boxes[$page][$context][$priority] = array();
$wp_meta_boxes[$page][$context][$priority][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback);
}
function do_meta_boxes($page, $context, $object) {
global $wp_meta_boxes;
static $already_sorted = false;
do_action('do_meta_boxes', $page, $context, $object);
$hidden = (array) get_user_option( "meta-box-hidden_$page" );
echo "
\n";
$i = 0;
do {
// Grab the ones the user has manually sorted. Pull them out of their previous context/priority and into the one the user chose
if ( !$already_sorted && $sorted = get_user_option( "meta-box-order_$page" ) ) {
foreach ( $sorted as $box_context => $ids )
foreach ( explode(',', $ids) as $id )
if ( $id )
add_meta_box( $id, null, null, $page, $box_context, 'sorted' );
}
$already_sorted = true;
if ( !isset($wp_meta_boxes) || !isset($wp_meta_boxes[$page]) || !isset($wp_meta_boxes[$page][$context]) )
break;
foreach ( array('high', 'sorted', 'core', 'default', 'low') as $priority ) {
if ( isset($wp_meta_boxes[$page][$context][$priority]) ) {
foreach ( (array) $wp_meta_boxes[$page][$context][$priority] as $box ) {
if ( false == $box || ! $box['title'] )
continue;
$i++;
$style = '';
if ( in_array($box['id'], $hidden) )
$style = 'style="display:none;"';
echo '
";
return $i;
}
/**
* remove_meta_box() - Remove a meta box from an edit form
*
* @since 2.6
*
* @param string $id String for use in the 'id' attribute of tags.
* @param string $page The type of edit page on which to show the box (post, page, link)
* @param string $context The context within the page where the boxes should show ('normal', 'advanced')
*/
function remove_meta_box($id, $page, $context) {
global $wp_meta_boxes;
if ( !isset($wp_meta_boxes) )
$wp_meta_boxes = array();
if ( !isset($wp_meta_boxes[$page]) )
$wp_meta_boxes[$page] = array();
if ( !isset($wp_meta_boxes[$page][$context]) )
$wp_meta_boxes[$page][$context] = array();
foreach ( array('high', 'core', 'default', 'low') as $priority )
$wp_meta_boxes[$page][$context][$priority][$id] = false;
}
function meta_box_prefs($page) {
global $wp_meta_boxes;
if ( empty($wp_meta_boxes[$page]) )
return;
$hidden = (array) get_user_option( "meta-box-hidden_$page" );
foreach ( array_keys($wp_meta_boxes[$page]) as $context ) {
foreach ( array_keys($wp_meta_boxes[$page][$context]) as $priority ) {
foreach ( $wp_meta_boxes[$page][$context][$priority] as $box ) {
if ( false == $box || ! $box['title'] )
continue;
// Submit box cannot be hidden
if ( 'submitdiv' == $box['id'] )
continue;
$box_id = $box['id'];
echo '\n";
}
}
}
}
/**
* Add a new section to a settings page
*
* @since 2.7
*
* @param string $id String for use in the 'id' attribute of tags.
* @param string $title Title of the section
* @param string $callback Function that fills the section with the desired content. The function should echo its output.
* @param string $page The type of settings page on which to show the section (general, reading, writing, ...)
*/
function add_settings_section($id, $title, $callback, $page) {
global $wp_settings_sections;
if ( !isset($wp_settings_sections) )
$wp_settings_sections = array();
if ( !isset($wp_settings_sections[$page]) )
$wp_settings_sections[$page] = array();
if ( !isset($wp_settings_sections[$page][$id]) )
$wp_settings_sections[$page][$id] = array();
$wp_settings_sections[$page][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback);
}
/**
* Add a new field to a settings page
*
* @since 2.7
*
* @param string $id String for use in the 'id' attribute of tags.
* @param string $title Title of the field
* @param string $callback Function that fills the field with the desired content. The function should echo its output.
* @param string $page The type of settings page on which to show the field (general, reading, writing, ...)
* @param string $section The section of the settingss page in which to show the box (default, ...)
* @param array $args Additional arguments
*/
function add_settings_field($id, $title, $callback, $page, $section = 'default', $args = array()) {
global $wp_settings_fields;
if ( !isset($wp_settings_fields) )
$wp_settings_fields = array();
if ( !isset($wp_settings_fields[$page]) )
$wp_settings_fields[$page] = array();
if ( !isset($wp_settings_fields[$page][$section]) )
$wp_settings_fields[$page][$section] = array();
$wp_settings_fields[$page][$section][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback, 'args' => $args);
}
function do_settings_sections($page) {
global $wp_settings_sections, $wp_settings_fields;
if ( !isset($wp_settings_sections) || !isset($wp_settings_sections[$page]) )
return;
foreach ( (array) $wp_settings_sections[$page] as $section ) {
echo "