";
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 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
*
* @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 = wp_get_attachment_image( $post->ID, 'thumbnail', true );
$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 ) {
$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 $screen
*/
function meta_box_prefs($screen) {
global $wp_meta_boxes;
if ( is_string($screen) )
$screen = convert_to_screen($screen);
if ( empty($wp_meta_boxes[$screen->id]) )
return;
$hidden = get_hidden_meta_boxes($screen);
foreach ( array_keys($wp_meta_boxes[$screen->id]) as $context ) {
foreach ( array_keys($wp_meta_boxes[$screen->id][$context]) as $priority ) {
foreach ( $wp_meta_boxes[$screen->id][$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($screen) {
if ( is_string($screen) )
$screen = convert_to_screen($screen);
$hidden = get_user_option( "metaboxhidden_$screen->id" );
// Hide slug boxes by default
if ( !is_array($hidden) )
$hidden = array('slugdiv');
return $hidden;
}
/**
* Add a new section to a settings page.
*
* Part of the Settings API. Use this to define new settings sections for an admin page.
* Show settings sections in your admin page callback function with do_settings_sections().
* Add settings fields to your section with add_settings_field()
*
* The $callback argument should be the name of a function that echos out any
* content you want to show at the top of the settings section before the actual
* fields. It can output nothing if you want.
*
* @since 2.7.0
*
* @global $wp_settings_sections Storage array of all settings sections added to admin pages
* @param string $id Slug-name to identify the section. Used in the 'id' attribute of tags.
* @param string $title Formatted title of the section. Shown as the heading for the section.
* @param string $callback Function that echo's out content for the section heading.
* @param string $page The slug-name of the settings page on which to show the section (general, reading, writing, ...).
*/
function add_settings_section($id, $title, $callback, $page) {
global $wp_settings_sections;
if ( 'misc' == $page ) {
_deprecated_argument( __FUNCTION__, '3.0', __( 'The miscellaneous options group has been removed. Use another settings group.' ) );
$page = 'general';
}
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 section of a settings page
*
* Part of the Settings API. Use this to define a settings field that will show
* as part of a settings section inside a settings page. The fields are shown using
* do_settings_fields() in do_settings-sections()
*
* The $callback argument should be the name of a function that echoes out the
* html input tags for this setting field. Use get_option() to retrive existing
* values to show.
*
* @since 2.7.0
*
* @global $wp_settings_fields Storage array of settings fields and info about their pages/sections
*
* @param string $id Slug-name to identify the field. Used in the 'id' attribute of tags.
* @param string $title Formatted title of the field. Shown as the label for the field during output.
* @param string $callback Function that fills the field with the desired form inputs. The function should echo its output.
* @param string $page The slug-name of the settings page on which to show the section (general, reading, writing, ...).
* @param string $section The slug-name of 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 ( 'misc' == $page ) {
_deprecated_argument( __FUNCTION__, '3.0', __( 'The miscellaneous options group has been removed. Use another settings group.' ) );
$page = 'general';
}
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);
}
/**
* Prints out all settings sections added to a particular settings page
*
* Part of the Settings API. Use this in a settings page callback function
* to output all the sections and fields that were added to that $page with
* add_settings_section() and add_settings_field()
*
* @global $wp_settings_sections Storage array of all settings sections added to admin pages
* @global $wp_settings_fields Storage array of settings fields and info about their pages/sections
* @since unknown
*
* @param string $page The slug name of the page whos settings sections you want to output
*/
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 "
';
}
}
/**
* Print out the settings fields for a particular settings section
*
* Part of the Settings API. Use this in a settings page to output
* a specific section. Should normally be called by do_settings_sections()
* rather than directly.
*
* @global $wp_settings_fields Storage array of settings fields and their pages/sections
*
* @since unknown
*
* @param string $page Slug title of the admin page who's settings fields you want to show.
* @param section $section Slug title of the settings section who's fields you want to show.
*/
function do_settings_fields($page, $section) {
global $wp_settings_fields;
if ( !isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section]) )
return;
foreach ( (array) $wp_settings_fields[$page][$section] as $field ) {
echo '
';
if ( !empty($field['args']['label_for']) )
echo '
';
}
}
/**
* Register a settings error to be displayed to the user
*
* Part of the Settings API. Use this to show messages to users about settings validation
* problems, missing settings or anything else.
*
* Settings errors should be added inside the $sanitize_callback function defined in
* register_setting() for a given setting to give feedback about the submission.
*
* By default messages will show immediately after the submission that generated the error.
* Additional calls to settings_errors() can be used to show errors even when the settings
* page is first accessed.
*
* @global array $wp_settings_errors Storage array of errors registered during this pageload
*
* @param string $setting Slug title of the setting to which this error applies
* @param string $code Slug-name to identify the error. Used as part of 'id' attribute in HTML output.
* @param string $message The formatted message text to display to the user (will be shown inside styled
and
)
* @param string $type The type of message it is, controls HTML class. Use 'error' or 'updated'.
*/
function add_settings_error( $setting, $code, $message, $type = 'error' ) {
global $wp_settings_errors;
if ( !isset($wp_settings_errors) )
$wp_settings_errors = array();
$new_error = array(
'setting' => $setting,
'code' => $code,
'message' => $message,
'type' => $type
);
$wp_settings_errors[] = $new_error;
}
/**
* Fetch settings errors registered by add_settings_error()
*
* Checks the $wp_settings_errors array for any errors declared during the current
* pageload and returns them.
*
* If changes were just submitted ($_GET['updated']) and settings errors were saved
* to the 'settings_errors' transient then those errors will be returned instead. This
* is used to pass errors back across pageloads.
*
* Use the $sanitize argument to manually re-sanitize the option before returning errors.
* This is useful if you have errors or notices you want to show even when the user
* hasn't submitted data (i.e. when they first load an options page, or in admin_notices action hook)
*
* @global array $wp_settings_errors Storage array of errors registered during this pageload
*
* @param string $setting Optional slug title of a specific setting who's errors you want.
* @param boolean $sanitize Whether to re-sanitize the setting value before returning errors.
* @return array Array of settings errors
*/
function get_settings_errors( $setting = '', $sanitize = FALSE ) {
global $wp_settings_errors;
// If $sanitize is true, manually re-run the sanitizisation for this option
// This allows the $sanitize_callback from register_setting() to run, adding
// any settings errors you want to show by default.
if ( $sanitize )
sanitize_option( $setting, get_option($setting));
// If settings were passed back from options.php then use them
// Ignore transients if $sanitize is true, we dont' want the old values anyway
if ( isset($_GET['updated']) && $_GET['updated'] && get_transient('settings_errors') ) {
$settings_errors = get_transient('settings_errors');
delete_transient('settings_errors');
// Otherwise check global in case validation has been run on this pageload
} elseif ( count( $wp_settings_errors ) ) {
$settings_errors = $wp_settings_errors;
} else {
return;
}
// Filter the results to those of a specific setting if one was set
if ( $setting ) {
foreach ( (array) $settings_errors as $key => $details )
if ( $setting != $details['setting'] )
unset( $settings_errors[$key] );
}
return $settings_errors;
}
/**
* Display settings errors registered by add_settings_error()
*
* Part of the Settings API. Outputs a
for each error retrieved by get_settings_errors().
*
* This is called automatically after a settings page based on the Settings API is submitted.
* Errors should be added during the validation callback function for a setting defined in register_setting()
*
* The $sanitize option is passed into get_settings_errors() and will re-run the setting sanitization
* on its current value.
*
* The $hide_on_update option will cause errors to only show when the settings page is first loaded.
* if the user has already saved new values it will be hidden to avoid repeating messages already
* shown in the default error reporting after submission. This is useful to show general errors like missing
* settings when the user arrives at the settings page.
*
* @param string $setting Optional slug title of a specific setting who's errors you want.
* @param boolean $sanitize Whether to re-sanitize the setting value before returning errors.
* @param boolean $hide_on_update If set to true errors will not be shown if the settings page has already been submitted.
* @return
*/
function settings_errors ( $setting = '', $sanitize = FALSE, $hide_on_update = FALSE ) {
if ($hide_on_update AND $_GET['updated']) return;
$settings_errors = get_settings_errors( $setting, $sanitize );
if ( !is_array($settings_errors) ) return;
$output = '';
foreach ( $settings_errors as $key => $details ) {
$css_id = 'setting-error-' . $details['code'];
$css_class = $details['type'] . ' settings-error';
$output .= "
\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 ) {
global $hook_suffix;
?>
>
› —
class="no-js ">
id] = $help;
}
function drag_drop_help() {
return '
' . __('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.') . '