';
return $output;
}
/**
* Outputs the html checked attribute.
*
* Compares the first two arguments and if identical marks as checked
*
* @since unknown
*
* @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 unknown
*
* @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 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 unknown
* @access private
*
* @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
* @param string $type The type of checked|selected we are doing.
*/
function __checked_selected_helper( $helper, $current, $echo, $type) {
if ( $helper == $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
WHERE meta_key NOT LIKE '\_%'
GROUP BY meta_key
ORDER BY meta_id DESC
LIMIT $limit" );
if ( $keys )
natcasesort($keys);
?>
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", 0, false ) ) {
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", 0, false );
// Hide slug boxes by default
if ( empty($hidden[0]) ) {
if ( 'page' == $page )
$hidden = array('pageslugdiv');
elseif ( 'post' == $page )
$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 attribute_escape
* @since 2.7.0
*
*/
function _admin_search_query() {
echo isset($_GET['s']) ? attribute_escape( 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) {
?>
>
› —
>
';
}
function _post_states($post) {
$post_states = array();
if ( isset($_GET['post_status']) )
$post_status = $_GET['post_status'];
else
$post_status = '';
if ( !empty($post->post_password) )
$post_states[] = __('Password protected');
if ( 'private' == $post->post_status && 'private' != $post_status )
$post_states[] = __('Private');
if ( 'draft' == $post->post_status && 'draft' != $post_status )
$post_states[] = __('Draft');
if ( 'pending' == $post->post_status && 'pending' != $post_status )
/* translators: post state */
$post_states[] = _x('Pending', 'post state');
if ( is_sticky($post->ID) )
$post_states[] = __('Sticky');
$post_states = apply_filters( 'display_post_states', $post_states );
if ( ! empty($post_states) ) {
$state_count = count($post_states);
$i = 0;
echo ' - ';
foreach ( $post_states as $state ) {
++$i;
( $i == $state_count ) ? $sep = '' : $sep = ', ';
echo "$state$sep";
}
}
}
function screen_meta($screen) {
global $wp_meta_boxes, $_wp_contextual_help;
$screen = str_replace('.php', '', $screen);
$screen = str_replace('-new', '', $screen);
$screen = str_replace('-add', '', $screen);
$screen = apply_filters('screen_meta_screen', $screen);
$column_screens = get_column_headers($screen);
$meta_screens = array('index' => 'dashboard');
if ( isset($meta_screens[$screen]) )
$screen = $meta_screens[$screen];
$show_screen = false;
if ( !empty($wp_meta_boxes[$screen]) || !empty($column_screens) )
$show_screen = true;
?>
' . __('Writing Posts') . '';
$_wp_contextual_help['post'] = $help;
}
break;
case 'page':
if ( !isset($_wp_contextual_help['page']) ) {
$help = drag_drop_help();
$_wp_contextual_help['page'] = $help;
}
break;
case 'dashboard':
if ( !isset($_wp_contextual_help['dashboard']) ) {
$help = '
' . __('The modules on this screen can be arranged in several columns. You can select the number of columns from the Screen Options tab.') . "
\n";
$help .= drag_drop_help();
$_wp_contextual_help['dashboard'] = $help;
}
break;
case 'link':
if ( !isset($_wp_contextual_help['link']) ) {
$help = drag_drop_help();
$_wp_contextual_help['link'] = $help;
}
break;
case 'options-general':
if ( !isset($_wp_contextual_help['options-general']) )
$_wp_contextual_help['options-general'] = __('General Settings');
break;
case 'theme-install':
case 'plugin-install':
if ( !isset($_GET['tab']) || 'dashboard' == $_GET['tab'] )
$_wp_contextual_help[$screen] = '
' . __('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.') . "
' . __('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.') . '