';
return $output;
}
/**
* Outputs the html checked attribute.
*
* Compares the first two arguments and if identical marks as checked
*
* @since 1.0
*
* @param any $checked One of the values to compare
* @param any $current (true) The other value to compare if not just true
* @param bool $echo Whether or not to echo or just return the string
*/
function checked( $checked, $current = true, $echo = true) {
return __checked_selected_helper( $checked, $current, $echo, 'checked' );
}
/**
* Outputs the html selected attribute.
*
* Compares the first two arguments and if identical marks as selected
*
* @since 1.0
*
* @param any selected One of the values to compare
* @param any $current (true) The other value to compare if not just true
* @param bool $echo Whether or not to echo or just return the string
*/
function selected( $selected, $current = true, $echo = true) {
return __checked_selected_helper( $selected, $current, $echo, 'selected' );
}
/**
* Private helper function for checked and selected.
*
* Compares the first two arguments and if identical marks as $type
*
* @since 2.8
* @access private
*
* @param any $helper One of the values to compare
* @param any $current (true) The other value to compare if not just true
* @param bool $echo Whether or not to echo or just return the string
* @param string $type The type of checked|selected we are doing.
*/
function __checked_selected_helper( $helper, $current, $echo, $type) {
if ( (string) $helper === (string) $current)
$result = " $type='$type'";
else
$result = '';
if ($echo)
echo $result;
return $result;
}
//
// Category Checklists
//
/**
* {@internal Missing Short Description}}
*
* @since unknown
* @deprecated Use {@link wp_link_category_checklist()}
* @see wp_link_category_checklist()
*
* @param unknown_type $default
* @param unknown_type $parent
* @param unknown_type $popular_ids
*/
function dropdown_categories( $default = 0, $parent = 0, $popular_ids = array() ) {
global $post_ID;
wp_category_checklist($post_ID);
}
/**
* {@internal Missing Short Description}}
*
* @since unknown
*/
class Walker_Category_Checklist extends Walker {
var $tree_type = 'category';
var $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); //TODO: decouple this
function start_lvl(&$output, $depth, $args) {
$indent = str_repeat("\t", $depth);
$output .= "$indent
";
return $r;
}
/**
* {@internal Missing Short Description}}
*
* @since unknown
*/
function meta_form() {
global $wpdb;
$limit = (int) apply_filters( 'postmeta_form_limit', 30 );
$keys = $wpdb->get_col( "
SELECT meta_key
FROM $wpdb->postmeta
GROUP BY meta_key
HAVING meta_key NOT LIKE '\_%'
ORDER BY LOWER(meta_key)
LIMIT $limit" );
if ( $keys )
natcasesort($keys);
?>
$template";
endforeach;
}
/**
* {@internal Missing Short Description}}
*
* @since unknown
*
* @param unknown_type $default
* @param unknown_type $parent
* @param unknown_type $level
* @return unknown
*/
function parent_dropdown( $default = 0, $parent = 0, $level = 0 ) {
global $wpdb, $post_ID;
$items = $wpdb->get_results( $wpdb->prepare("SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' ORDER BY menu_order", $parent) );
if ( $items ) {
foreach ( $items as $item ) {
// A page cannot be its own parent.
if (!empty ( $post_ID ) ) {
if ( $item->ID == $post_ID ) {
continue;
}
}
$pad = str_repeat( ' ', $level * 3 );
if ( $item->ID == $default)
$current = ' selected="selected"';
else
$current = '';
echo "\n\t";
parent_dropdown( $default, $item->ID, $level +1 );
}
} else {
return false;
}
}
/**
* {@internal Missing Short Description}}
*
* @since unknown
*/
function browse_happy() {
$getit = __( 'WordPress recommends a better browser' );
echo '
';
}
/**
* {@internal Missing Short Description}}
*
* @since unknown
*
* @param unknown_type $id
* @return unknown
*/
function the_attachment_links( $id = false ) {
$id = (int) $id;
$post = & get_post( $id );
if ( $post->post_type != 'attachment' )
return false;
$icon = get_attachment_icon( $post->ID );
$attachment_data = wp_get_attachment_metadata( $id );
$thumb = isset( $attachment_data['thumb'] );
?>
html elements for role selectors based on $wp_roles
*
* @package WordPress
* @subpackage Administration
* @since 2.1
*
* @uses $wp_roles
* @param string $default slug for the role that should be already selected
*/
function wp_dropdown_roles( $selected = false ) {
global $wp_roles;
$p = '';
$r = '';
$editable_roles = get_editable_roles();
foreach( $editable_roles as $role => $details ) {
$name = translate_user_role($details['name'] );
if ( $selected == $role ) // Make default first in list
$p = "\n\t";
else
$r .= "\n\t";
}
echo $p . $r;
}
/**
* {@internal Missing Short Description}}
*
* @since unknown
*
* @param unknown_type $size
* @return unknown
*/
function wp_convert_hr_to_bytes( $size ) {
$size = strtolower($size);
$bytes = (int) $size;
if ( strpos($size, 'k') !== false )
$bytes = intval($size) * 1024;
elseif ( strpos($size, 'm') !== false )
$bytes = intval($size) * 1024 * 1024;
elseif ( strpos($size, 'g') !== false )
$bytes = intval($size) * 1024 * 1024 * 1024;
return $bytes;
}
/**
* {@internal Missing Short Description}}
*
* @since unknown
*
* @param unknown_type $bytes
* @return unknown
*/
function wp_convert_bytes_to_hr( $bytes ) {
$units = array( 0 => 'B', 1 => 'kB', 2 => 'MB', 3 => 'GB' );
$log = log( $bytes, 1024 );
$power = (int) $log;
$size = pow(1024, $log - $power);
return $size . $units[$power];
}
/**
* {@internal Missing Short Description}}
*
* @since unknown
*
* @return unknown
*/
function wp_max_upload_size() {
$u_bytes = wp_convert_hr_to_bytes( ini_get( 'upload_max_filesize' ) );
$p_bytes = wp_convert_hr_to_bytes( ini_get( 'post_max_size' ) );
$bytes = apply_filters( 'upload_size_limit', min($u_bytes, $p_bytes), $u_bytes, $p_bytes );
return $bytes;
}
/**
* Outputs the form used by the importers to accept the data to be imported
*
* @since 2.0
*
* @param string $action The action attribute for the form.
*/
function wp_import_upload_form( $action ) {
$bytes = apply_filters( 'import_upload_size_limit', wp_max_upload_size() );
$size = wp_convert_bytes_to_hr( $bytes );
$upload_dir = wp_upload_dir();
if ( ! empty( $upload_dir['error'] ) ) :
?>
post_name); // just in case
if ( strlen($name) )
echo '';
}
/**
* Add a meta box to an edit form.
*
* @since 2.5.0
*
* @param string $id String for use in the 'id' attribute of tags.
* @param string $title Title of the meta box.
* @param string $callback Function that fills the box with the desired content. The function should echo its output.
* @param string $page The type of edit page on which to show the box (post, page, link).
* @param string $context The context within the page where the boxes should show ('normal', 'advanced').
* @param string $priority The priority within the context where the boxes should show ('high', 'low').
*/
function add_meta_box($id, $title, $callback, $page, $context = 'advanced', $priority = 'default', $callback_args=null) {
global $wp_meta_boxes;
if ( !isset($wp_meta_boxes) )
$wp_meta_boxes = array();
if ( !isset($wp_meta_boxes[$page]) )
$wp_meta_boxes[$page] = array();
if ( !isset($wp_meta_boxes[$page][$context]) )
$wp_meta_boxes[$page][$context] = array();
foreach ( array_keys($wp_meta_boxes[$page]) as $a_context ) {
foreach ( array('high', 'core', 'default', 'low') as $a_priority ) {
if ( !isset($wp_meta_boxes[$page][$a_context][$a_priority][$id]) )
continue;
// If a core box was previously added or removed by a plugin, don't add.
if ( 'core' == $priority ) {
// If core box previously deleted, don't add
if ( false === $wp_meta_boxes[$page][$a_context][$a_priority][$id] )
return;
// If box was added with default priority, give it core priority to maintain sort order
if ( 'default' == $a_priority ) {
$wp_meta_boxes[$page][$a_context]['core'][$id] = $wp_meta_boxes[$page][$a_context]['default'][$id];
unset($wp_meta_boxes[$page][$a_context]['default'][$id]);
}
return;
}
// If no priority given and id already present, use existing priority
if ( empty($priority) ) {
$priority = $a_priority;
// else if we're adding to the sorted priortiy, we don't know the title or callback. Glab them from the previously added context/priority.
} elseif ( 'sorted' == $priority ) {
$title = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['title'];
$callback = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['callback'];
$callback_args = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['args'];
}
// An id can be in only one priority and one context
if ( $priority != $a_priority || $context != $a_context )
unset($wp_meta_boxes[$page][$a_context][$a_priority][$id]);
}
}
if ( empty($priority) )
$priority = 'low';
if ( !isset($wp_meta_boxes[$page][$context][$priority]) )
$wp_meta_boxes[$page][$context][$priority] = array();
$wp_meta_boxes[$page][$context][$priority][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback, 'args' => $callback_args);
}
/**
* {@internal Missing Short Description}}
*
* @since unknown
*
* @param unknown_type $page
* @param unknown_type $context
* @param unknown_type $object
* @return int number of meta_boxes
*/
function do_meta_boxes($page, $context, $object) {
global $wp_meta_boxes;
static $already_sorted = false;
//do_action('do_meta_boxes', $page, $context, $object);
$hidden = get_hidden_meta_boxes($page);
echo "
\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 a meta box from an edit form.
*
* @since 2.6.0
*
* @param string $id String for use in the 'id' attribute of tags.
* @param string $page The type of edit page on which to show the box (post, page, link).
* @param string $context The context within the page where the boxes should show ('normal', 'advanced').
*/
function remove_meta_box($id, $page, $context) {
global $wp_meta_boxes;
if ( !isset($wp_meta_boxes) )
$wp_meta_boxes = array();
if ( !isset($wp_meta_boxes[$page]) )
$wp_meta_boxes[$page] = array();
if ( !isset($wp_meta_boxes[$page][$context]) )
$wp_meta_boxes[$page][$context] = array();
foreach ( array('high', 'core', 'default', 'low') as $priority )
$wp_meta_boxes[$page][$context][$priority][$id] = false;
}
/**
* {@internal Missing Short Description}}
*
* @since unknown
*
* @param unknown_type $page
*/
function meta_box_prefs($page) {
global $wp_meta_boxes;
if ( empty($wp_meta_boxes[$page]) )
return;
$hidden = get_hidden_meta_boxes($page);
foreach ( array_keys($wp_meta_boxes[$page]) as $context ) {
foreach ( array_keys($wp_meta_boxes[$page][$context]) as $priority ) {
foreach ( $wp_meta_boxes[$page][$context][$priority] as $box ) {
if ( false == $box || ! $box['title'] )
continue;
// Submit box cannot be hidden
if ( 'submitdiv' == $box['id'] || 'linksubmitdiv' == $box['id'] )
continue;
$box_id = $box['id'];
echo '\n";
}
}
}
}
function get_hidden_meta_boxes($page) {
$hidden = (array) get_user_option( "meta-box-hidden_$page" );
// Hide slug boxes by default
if ( empty($hidden[0]) ) {
$hidden = array('slugdiv');
}
return $hidden;
}
/**
* Add a new section to a settings page.
*
* @since 2.7.0
*
* @param string $id String for use in the 'id' attribute of tags.
* @param string $title Title of the section.
* @param string $callback Function that fills the section with the desired content. The function should echo its output.
* @param string $page The type of settings page on which to show the section (general, reading, writing, ...).
*/
function add_settings_section($id, $title, $callback, $page) {
global $wp_settings_sections;
if ( !isset($wp_settings_sections) )
$wp_settings_sections = array();
if ( !isset($wp_settings_sections[$page]) )
$wp_settings_sections[$page] = array();
if ( !isset($wp_settings_sections[$page][$id]) )
$wp_settings_sections[$page][$id] = array();
$wp_settings_sections[$page][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback);
}
/**
* Add a new field to a settings page.
*
* @since 2.7.0
*
* @param string $id String for use in the 'id' attribute of tags.
* @param string $title Title of the field.
* @param string $callback Function that fills the field with the desired content. The function should echo its output.
* @param string $page The type of settings page on which to show the field (general, reading, writing, ...).
* @param string $section The section of the settingss page in which to show the box (default, ...).
* @param array $args Additional arguments
*/
function add_settings_field($id, $title, $callback, $page, $section = 'default', $args = array()) {
global $wp_settings_fields;
if ( !isset($wp_settings_fields) )
$wp_settings_fields = array();
if ( !isset($wp_settings_fields[$page]) )
$wp_settings_fields[$page] = array();
if ( !isset($wp_settings_fields[$page][$section]) )
$wp_settings_fields[$page][$section] = array();
$wp_settings_fields[$page][$section][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback, 'args' => $args);
}
/**
* {@internal Missing Short Description}}
*
* @since unknown
*
* @param unknown_type $page
*/
function do_settings_sections($page) {
global $wp_settings_sections, $wp_settings_fields;
if ( !isset($wp_settings_sections) || !isset($wp_settings_sections[$page]) )
return;
foreach ( (array) $wp_settings_sections[$page] as $section ) {
echo "
\n";
}
/**
* Get the post title.
*
* The post title is fetched and if it is blank then a default string is
* returned.
*
* @since 2.7.0
* @param int $id The post id. If not supplied the global $post is used.
*
*/
function _draft_or_post_title($post_id = 0)
{
$title = get_the_title($post_id);
if ( empty($title) )
$title = __('(no title)');
return $title;
}
/**
* Display the search query.
*
* A simple wrapper to display the "s" parameter in a GET URI. This function
* should only be used when {@link the_search_query()} cannot.
*
* @uses attr
* @since 2.7.0
*
*/
function _admin_search_query() {
echo isset($_GET['s']) ? esc_attr( stripslashes( $_GET['s'] ) ) : '';
}
/**
* Generic Iframe header for use with Thickbox
*
* @since 2.7.0
* @param string $title Title of the Iframe page.
* @param bool $limit_styles Limit styles to colour-related styles only (unless others are enqueued).
*
*/
function iframe_header( $title = '', $limit_styles = false ) {
?>
>
› —
>
' . __('Most of the modules on this screen can be moved. If you hover your mouse over the title bar of a module you’ll notice the 4 arrow cursor appears to let you know it is movable. Click on it, hold down the mouse button and start dragging the module to a new location. As you drag the module, notice the dotted gray box that also moves. This box indicates where the module will be placed when you release the mouse button.') . '
' . __('The same modules can be expanded and collapsed by clicking once on their title bar and also completely hidden from the Screen Options tab.') . '
';
}
function plugins_search_help() {
return '
' . __('Search help') . '
' .
'
' . __('You may search based on 3 criteria:') . ' ' .
__('Term: Searches theme names and descriptions for the specified term.') . ' ' .
__('Tag: Searches for themes tagged as such.') . ' ' .
__('Author: Searches for themes created by the Author, or which the Author contributed to.') . '
';
}
function widgets_help() {
return '
' . __('Widgets are added and arranged by simple drag ’n’ drop. If you hover your mouse over the titlebar of a widget, you’ll see a 4-arrow cursor which indicates that the widget is movable. Click on the titlebar, hold down the mouse button and drag the widget to a sidebar. As you drag, you’ll see a dotted box that also moves. This box shows where the widget will go once you drop it.') . '
' . __('To remove a widget from a sidebar, drag it back to Available Widgets or click on the arrow on its titlebar to reveal its settings, and then click Remove.') . '
' . __('To remove a widget from a sidebar and keep its configuration, drag it to Inactive Widgets.') . '
' . __('The Inactive Widgets area stores widgets that are configured but not curently used. If you change themes and the new theme has fewer sidebars than the old, all extra widgets will be stored to Inactive Widgets automatically.') . '