";
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);
?>
";
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";
}
}
}
}
/**
* Get Hidden Meta Boxes
*
* @since 2.7
*
* @param string|object $screen Screen identifier
* @return array Hidden Meta Boxes
*/
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 echoes 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 echos out any content at the top of the section (between heading and fields).
* @param string $page The slug-name of the settings page on which to show the section. Built-in pages include 'general', 'reading', 'writing', 'discussion', 'media', etc. Create your own using add_options_page();
*/
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";
$output .= "
{$details['message']}
";
$output .= "
\n";
}
echo $output;
}
/**
* {@internal Missing Short Description}}
*
* @since unknown
*
* @param unknown_type $page
*/
function manage_columns_prefs( $page ) {
global $wp_list_table;
list( $columns, $hidden ) = $wp_list_table->get_column_headers();
$special = array('_title', 'cb', 'comment', 'media', 'name', 'title', 'username');
foreach ( $columns as $column => $title ) {
// Can't hide these for they are special
if ( in_array( $column, $special ) )
continue;
if ( empty( $title ) )
continue;
if ( 'comments' == $column )
$title = __( 'Comments' );
$id = "$column-hide";
echo '\n";
}
}
/**
* {@internal Missing Short Description}}
*
* @since unknown
*
* @param unknown_type $found_action
*/
function find_posts_div($found_action = '') {
?>
\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 ">
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";
}
}
}
/**
* Convert a screen string to a screen object
*
* @since 3.0.0
*
* @param string $screen The name of the screen
* @return object An object containing the safe screen name and id
*/
function convert_to_screen( $screen ) {
$screen = str_replace( array('.php', '-new', '-add' ), '', $screen);
$screen = (string) apply_filters( 'screen_meta_screen', $screen );
$screen = (object) array('id' => $screen, 'base' => $screen);
return $screen;
}
function screen_meta($screen) {
global $wp_meta_boxes, $_wp_contextual_help, $title, $wp_list_table;
if ( is_string($screen) )
$screen = convert_to_screen($screen);
if ( is_a($wp_list_table, 'WP_List_Table') )
list( $screen_columns ) = $wp_list_table->get_column_headers();
$meta_screens = array('index' => 'dashboard');
if ( isset($meta_screens[$screen->id]) ) {
$screen->id = $meta_screens[$screen->id];
$screen->base = $screen->id;
}
$show_screen = false;
if ( !empty($wp_meta_boxes[$screen->id]) || !empty($screen_columns) )
$show_screen = true;
$screen_options = screen_options($screen);
if ( $screen_options )
$show_screen = true;
if ( !isset($_wp_contextual_help) )
$_wp_contextual_help = array();
$settings = apply_filters('screen_settings', '', $screen);
switch ( $screen->id ) {
case 'widgets':
$settings = '
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.') . '