" . sprintf( __( "Do you really want to log out?"), wp_logout_url() );
wp_die( $html, $title);
}
/**
* Kill WordPress execution and display HTML message with error message.
*
* Call this function complements the die() PHP function. The difference is that
* HTML will be displayed to the user. It is recommended to use this function
* only, when the execution should not continue any further. It is not
* recommended to call this function very often and try to handle as many errors
* as possible siliently.
*
* @since 2.0.4
*
* @param string $message Error message.
* @param string $title Error title.
* @param string|array $args Optional arguements to control behaviour.
*/
function wp_die( $message, $title = '', $args = array() ) {
global $wp_locale;
$defaults = array( 'response' => 500 );
$r = wp_parse_args($args, $defaults);
$have_gettext = function_exists('__');
if ( function_exists( 'is_wp_error' ) && is_wp_error( $message ) ) {
if ( empty( $title ) ) {
$error_data = $message->get_error_data();
if ( is_array( $error_data ) && isset( $error_data['title'] ) )
$title = $error_data['title'];
}
$errors = $message->get_error_messages();
switch ( count( $errors ) ) :
case 0 :
$message = '';
break;
case 1 :
$message = "
";
}
if ( defined( 'WP_SITEURL' ) && '' != WP_SITEURL )
$admin_dir = WP_SITEURL . '/wp-admin/';
elseif ( function_exists( 'get_bloginfo' ) && '' != get_bloginfo( 'wpurl' ) )
$admin_dir = get_bloginfo( 'wpurl' ) . '/wp-admin/';
elseif ( strpos( $_SERVER['PHP_SELF'], 'wp-admin' ) !== false )
$admin_dir = '';
else
$admin_dir = 'wp-admin/';
if ( !function_exists( 'did_action' ) || !did_action( 'admin_head' ) ) :
if( !headers_sent() ){
status_header( $r['response'] );
nocache_headers();
header( 'Content-Type: text/html; charset=utf-8' );
}
if ( empty($title) ) {
$title = $have_gettext? __('WordPress › Error') : 'WordPress › Error';
}
$text_direction = 'ltr';
if ( isset($r['text_direction']) && $r['text_direction'] == 'rtl' ) $text_direction = 'rtl';
if ( ( $wp_locale ) && ( 'rtl' == $wp_locale->text_direction ) ) $text_direction = 'rtl';
?>
>
text_direction ) {
$input['directionality'] = 'rtl';
$input['plugins'] .= ',directionality';
$input['theme_advanced_buttons1'] .= ',ltr';
}
return $input;
}
/**
* Convert smiley code to the icon graphic file equivalent.
*
* You can turn off smilies, by going to the write setting screen and unchecking
* the box, or by setting 'use_smilies' option to false or removing the option.
*
* Plugins may override the default smiley list by setting the $wpsmiliestrans
* to an array, with the key the code the blogger types in and the value the
* image file.
*
* The $wp_smiliessearch global is for the regular expression and is set each
* time the function is called.
*
* The full list of smilies can be found in the function and won't be listed in
* the description. Probably should create a Codex page for it, so that it is
* available.
*
* @global array $wpsmiliestrans
* @global array $wp_smiliessearch
* @since 2.2.0
*/
function smilies_init() {
global $wpsmiliestrans, $wp_smiliessearch;
// don't bother setting up smilies if they are disabled
if ( !get_option( 'use_smilies' ) )
return;
if ( !isset( $wpsmiliestrans ) ) {
$wpsmiliestrans = array(
':mrgreen:' => 'icon_mrgreen.gif',
':neutral:' => 'icon_neutral.gif',
':twisted:' => 'icon_twisted.gif',
':arrow:' => 'icon_arrow.gif',
':shock:' => 'icon_eek.gif',
':smile:' => 'icon_smile.gif',
':???:' => 'icon_confused.gif',
':cool:' => 'icon_cool.gif',
':evil:' => 'icon_evil.gif',
':grin:' => 'icon_biggrin.gif',
':idea:' => 'icon_idea.gif',
':oops:' => 'icon_redface.gif',
':razz:' => 'icon_razz.gif',
':roll:' => 'icon_rolleyes.gif',
':wink:' => 'icon_wink.gif',
':cry:' => 'icon_cry.gif',
':eek:' => 'icon_surprised.gif',
':lol:' => 'icon_lol.gif',
':mad:' => 'icon_mad.gif',
':sad:' => 'icon_sad.gif',
'8-)' => 'icon_cool.gif',
'8-O' => 'icon_eek.gif',
':-(' => 'icon_sad.gif',
':-)' => 'icon_smile.gif',
':-?' => 'icon_confused.gif',
':-D' => 'icon_biggrin.gif',
':-P' => 'icon_razz.gif',
':-o' => 'icon_surprised.gif',
':-x' => 'icon_mad.gif',
':-|' => 'icon_neutral.gif',
';-)' => 'icon_wink.gif',
'8)' => 'icon_cool.gif',
'8O' => 'icon_eek.gif',
':(' => 'icon_sad.gif',
':)' => 'icon_smile.gif',
':?' => 'icon_confused.gif',
':D' => 'icon_biggrin.gif',
':P' => 'icon_razz.gif',
':o' => 'icon_surprised.gif',
':x' => 'icon_mad.gif',
':|' => 'icon_neutral.gif',
';)' => 'icon_wink.gif',
':!:' => 'icon_exclaim.gif',
':?:' => 'icon_question.gif',
);
}
if (count($wpsmiliestrans) == 0) {
return;
}
/*
* NOTE: we sort the smilies in reverse key order. This is to make sure
* we match the longest possible smilie (:???: vs :?) as the regular
* expression used below is first-match
*/
krsort($wpsmiliestrans);
$wp_smiliessearch = '/(?:\s|^)';
$subchar = '';
foreach ( (array) $wpsmiliestrans as $smiley => $img ) {
$firstchar = substr($smiley, 0, 1);
$rest = substr($smiley, 1);
// new subpattern?
if ($firstchar != $subchar) {
if ($subchar != '') {
$wp_smiliessearch .= ')|(?:\s|^)';
}
$subchar = $firstchar;
$wp_smiliessearch .= preg_quote($firstchar, '/') . '(?:';
} else {
$wp_smiliessearch .= '|';
}
$wp_smiliessearch .= preg_quote($rest, '/');
}
$wp_smiliessearch .= ')(?:\s|$)/m';
}
/**
* Merge user defined arguments into defaults array.
*
* This function is used throughout WordPress to allow for both string or array
* to be merged into another array.
*
* @since 2.2.0
*
* @param string|array $args Value to merge with $defaults
* @param array $defaults Array that serves as the defaults.
* @return array Merged user defined values with defaults.
*/
function wp_parse_args( $args, $defaults = '' ) {
if ( is_object( $args ) )
$r = get_object_vars( $args );
elseif ( is_array( $args ) )
$r =& $args;
else
wp_parse_str( $args, $r );
if ( is_array( $defaults ) )
return array_merge( $defaults, $r );
return $r;
}
/**
* Determines if default embed handlers should be loaded.
*
* Checks to make sure that the embeds library hasn't already been loaded. If
* it hasn't, then it will load the embeds library.
*
* @since 2.9
*/
function wp_maybe_load_embeds() {
if ( ! apply_filters('load_default_embeds', true) )
return;
require_once( ABSPATH . WPINC . '/default-embeds.php' );
}
/**
* Determines if Widgets library should be loaded.
*
* Checks to make sure that the widgets library hasn't already been loaded. If
* it hasn't, then it will load the widgets library and run an action hook.
*
* @since 2.2.0
* @uses add_action() Calls '_admin_menu' hook with 'wp_widgets_add_menu' value.
*/
function wp_maybe_load_widgets() {
if ( ! apply_filters('load_default_widgets', true) )
return;
require_once( ABSPATH . WPINC . '/default-widgets.php' );
add_action( '_admin_menu', 'wp_widgets_add_menu' );
}
/**
* Append the Widgets menu to the themes main menu.
*
* @since 2.2.0
* @uses $submenu The administration submenu list.
*/
function wp_widgets_add_menu() {
global $submenu;
$submenu['themes.php'][7] = array( __( 'Widgets' ), 'switch_themes', 'widgets.php' );
ksort( $submenu['themes.php'], SORT_NUMERIC );
}
/**
* Flush all output buffers for PHP 5.2.
*
* Make sure all output buffers are flushed before our singletons our destroyed.
*
* @since 2.2.0
*/
function wp_ob_end_flush_all() {
$levels = ob_get_level();
for ($i=0; $i<$levels; $i++)
ob_end_flush();
}
/**
* Load the correct database class file.
*
* This function is used to load the database class file either at runtime or by
* wp-admin/setup-config.php We must globalise $wpdb to ensure that it is
* defined globally by the inline code in wp-db.php.
*
* @since 2.5.0
* @global $wpdb WordPress Database Object
*/
function require_wp_db() {
global $wpdb;
if ( file_exists( WP_CONTENT_DIR . '/db.php' ) )
require_once( WP_CONTENT_DIR . '/db.php' );
else
require_once( ABSPATH . WPINC . '/wp-db.php' );
}
/**
* Load custom DB error or display WordPress DB error.
*
* If a file exists in the wp-content directory named db-error.php, then it will
* be loaded instead of displaying the WordPress DB error. If it is not found,
* then the WordPress DB error will be displayed instead.
*
* The WordPress DB error sets the HTTP status header to 500 to try to prevent
* search engines from caching the message. Custom DB messages should do the
* same.
*
* This function was backported to the the WordPress 2.3.2, but originally was
* added in WordPress 2.5.0.
*
* @since 2.3.2
* @uses $wpdb
*/
function dead_db() {
global $wpdb;
// Load custom DB error template, if present.
if ( file_exists( WP_CONTENT_DIR . '/db-error.php' ) ) {
require_once( WP_CONTENT_DIR . '/db-error.php' );
die();
}
// If installing or in the admin, provide the verbose message.
if ( defined('WP_INSTALLING') || defined('WP_ADMIN') )
wp_die($wpdb->error);
// Otherwise, be terse.
status_header( 500 );
nocache_headers();
header( 'Content-Type: text/html; charset=utf-8' );
?>
>
Database Error
Error establishing a database connection
deprecated since version %2$s! Use %3$s instead.'), $function, $version, $replacement ) );
else
trigger_error( sprintf( __('%1$s is deprecated since version %2$s with no alternative available.'), $function, $version ) );
}
}
/**
* Marks a file as deprecated and informs when it has been used.
*
* There is a hook deprecated_file_included that will be called that can be used
* to get the backtrace up to what file and function included the deprecated
* file.
*
* The current behavior is to trigger an user error if WP_DEBUG is defined and
* is true.
*
* This function is to be used in every file that is depreceated
*
* @package WordPress
* @package Debug
* @since 2.5.0
* @access private
*
* @uses do_action() Calls 'deprecated_file_included' and passes the file name and what to use instead.
* @uses apply_filters() Calls 'deprecated_file_trigger_error' and expects boolean value of true to do trigger or false to not trigger error.
*
* @param string $file The file that was included
* @param string $version The version of WordPress that deprecated the function
* @param string $replacement Optional. The function that should have been called
*/
function _deprecated_file($file, $version, $replacement=null) {
do_action('deprecated_file_included', $file, $replacement);
// Allow plugin to filter the output error trigger
if( defined('WP_DEBUG') && ( true === WP_DEBUG ) && apply_filters( 'deprecated_file_trigger_error', true )) {
if( !is_null($replacement) )
trigger_error( sprintf( __('%1$s is deprecated since version %2$s! Use %3$s instead.'), $file, $version, $replacement ) );
else
trigger_error( sprintf( __('%1$s is deprecated since version %2$s with no alternative available.'), $file, $version ) );
}
}
/**
* Is the server running earlier than 1.5.0 version of lighttpd
*
* @since 2.5.0
*
* @return bool Whether the server is running lighttpd < 1.5.0
*/
function is_lighttpd_before_150() {
$server_parts = explode( '/', isset( $_SERVER['SERVER_SOFTWARE'] )? $_SERVER['SERVER_SOFTWARE'] : '' );
$server_parts[1] = isset( $server_parts[1] )? $server_parts[1] : '';
return 'lighttpd' == $server_parts[0] && -1 == version_compare( $server_parts[1], '1.5.0' );
}
/**
* Does the specified module exist in the apache config?
*
* @since 2.5.0
*
* @param string $mod e.g. mod_rewrite
* @param bool $default The default return value if the module is not found
* @return bool
*/
function apache_mod_loaded($mod, $default = false) {
global $is_apache;
if ( !$is_apache )
return false;
if ( function_exists('apache_get_modules') ) {
$mods = apache_get_modules();
if ( in_array($mod, $mods) )
return true;
} elseif ( function_exists('phpinfo') ) {
ob_start();
phpinfo(8);
$phpinfo = ob_get_clean();
if ( false !== strpos($phpinfo, $mod) )
return true;
}
return $default;
}
/**
* File validates against allowed set of defined rules.
*
* A return value of '1' means that the $file contains either '..' or './'. A
* return value of '2' means that the $file contains ':' after the first
* character. A return value of '3' means that the file is not in the allowed
* files list.
*
* @since 1.2.0
*
* @param string $file File path.
* @param array $allowed_files List of allowed files.
* @return int 0 means nothing is wrong, greater than 0 means something was wrong.
*/
function validate_file( $file, $allowed_files = '' ) {
if ( false !== strpos( $file, '..' ))
return 1;
if ( false !== strpos( $file, './' ))
return 1;
if (':' == substr( $file, 1, 1 ))
return 2;
if (!empty ( $allowed_files ) && (!in_array( $file, $allowed_files ) ) )
return 3;
return 0;
}
/**
* Determine if SSL is used.
*
* @since 2.6.0
*
* @return bool True if SSL, false if not used.
*/
function is_ssl() {
if ( isset($_SERVER['HTTPS']) ) {
if ( 'on' == strtolower($_SERVER['HTTPS']) )
return true;
if ( '1' == $_SERVER['HTTPS'] )
return true;
} elseif ( isset($_SERVER['SERVER_PORT']) && ( '443' == $_SERVER['SERVER_PORT'] ) ) {
return true;
}
return false;
}
/**
* Whether SSL login should be forced.
*
* @since 2.6.0
*
* @param string|bool $force Optional.
* @return bool True if forced, false if not forced.
*/
function force_ssl_login( $force = null ) {
static $forced = false;
if ( !is_null( $force ) ) {
$old_forced = $forced;
$forced = $force;
return $old_forced;
}
return $forced;
}
/**
* Whether to force SSL used for the Administration Panels.
*
* @since 2.6.0
*
* @param string|bool $force
* @return bool True if forced, false if not forced.
*/
function force_ssl_admin( $force = null ) {
static $forced = false;
if ( !is_null( $force ) ) {
$old_forced = $forced;
$forced = $force;
return $old_forced;
}
return $forced;
}
/**
* Guess the URL for the site.
*
* Will remove wp-admin links to retrieve only return URLs not in the wp-admin
* directory.
*
* @since 2.6.0
*
* @return string
*/
function wp_guess_url() {
if ( defined('WP_SITEURL') && '' != WP_SITEURL ) {
$url = WP_SITEURL;
} else {
$schema = ( isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ) ? 'https://' : 'http://';
$url = preg_replace('|/wp-admin/.*|i', '', $schema . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
}
return $url;
}
/**
* Suspend cache invalidation.
*
* Turns cache invalidation on and off. Useful during imports where you don't wont to do invalidations
* every time a post is inserted. Callers must be sure that what they are doing won't lead to an inconsistent
* cache when invalidation is suspended.
*
* @since 2.7.0
*
* @param bool $suspend Whether to suspend or enable cache invalidation
* @return bool The current suspend setting
*/
function wp_suspend_cache_invalidation($suspend = true) {
global $_wp_suspend_cache_invalidation;
$current_suspend = $_wp_suspend_cache_invalidation;
$_wp_suspend_cache_invalidation = $suspend;
return $current_suspend;
}
function get_site_option( $key, $default = false, $use_cache = true ) {
// Allow plugins to short-circuit site options.
$pre = apply_filters( 'pre_site_option_' . $key, false );
if ( false !== $pre )
return $pre;
$value = get_option($key, $default);
return apply_filters( 'site_option_' . $key, $value );
}
// expects $key, $value not to be SQL escaped
function add_site_option( $key, $value ) {
$value = apply_filters( 'pre_add_site_option_' . $key, $value );
$result = add_option($key, $value);
do_action( "add_site_option_{$key}", $key, $value );
return $result;
}
function delete_site_option( $key ) {
$result = delete_option($key);
do_action( "delete_site_option_{$key}", $key );
return $result;
}
// expects $key, $value not to be SQL escaped
function update_site_option( $key, $value ) {
$oldvalue = get_site_option( $key );
$value = apply_filters( 'pre_update_site_option_' . $key, $value, $oldvalue );
$result = update_option($key, $value);
do_action( "update_site_option_{$key}", $key, $value );
return $result;
}
/**
* Delete a site transient
*
* @since 2.890
* @package WordPress
* @subpackage Transient
*
* @param string $transient Transient name. Expected to not be SQL-escaped
* @return bool true if successful, false otherwise
*/
function delete_site_transient($transient) {
global $_wp_using_ext_object_cache, $wpdb;
if ( $_wp_using_ext_object_cache ) {
return wp_cache_delete($transient, 'site-transient');
} else {
$transient = '_site_transient_' . esc_sql($transient);
return delete_site_option($transient);
}
}
/**
* Get the value of a site transient
*
* If the transient does not exist or does not have a value, then the return value
* will be false.
*
* @since 2.9.0
* @package WordPress
* @subpackage Transient
*
* @param string $transient Transient name. Expected to not be SQL-escaped
* @return mixed Value of transient
*/
function get_site_transient($transient) {
global $_wp_using_ext_object_cache, $wpdb;
$pre = apply_filters( 'pre_site_transient_' . $transient, false );
if ( false !== $pre )
return $pre;
if ( $_wp_using_ext_object_cache ) {
$value = wp_cache_get($transient, 'site-transient');
} else {
$transient_option = '_site_transient_' . esc_sql($transient);
$transient_timeout = '_site_transient_timeout_' . esc_sql($transient);
if ( get_site_option($transient_timeout) < time() ) {
delete_site_option($transient_option);
delete_site_option($transient_timeout);
return false;
}
$value = get_site_option($transient_option);
}
return apply_filters('site_transient_' . $transient, $value);
}
/**
* Set/update the value of a site transient
*
* You do not need to serialize values, if the value needs to be serialize, then
* it will be serialized before it is set.
*
* @since 2.9.0
* @package WordPress
* @subpackage Transient
*
* @param string $transient Transient name. Expected to not be SQL-escaped
* @param mixed $value Transient value.
* @param int $expiration Time until expiration in seconds, default 0
* @return bool False if value was not set and true if value was set.
*/
function set_site_transient($transient, $value, $expiration = 0) {
global $_wp_using_ext_object_cache, $wpdb;
if ( $_wp_using_ext_object_cache ) {
return wp_cache_set($transient, $value, 'site-transient', $expiration);
} else {
$transient_timeout = '_site_transient_timeout_' . $transient;
$transient = '_site_transient_' . $transient;
$safe_transient = esc_sql($transient);
if ( false === get_site_option( $safe_transient ) ) {
if ( 0 != $expiration )
add_site_option($transient_timeout, time() + $expiration);
return add_site_option($transient, $value);
} else {
if ( 0 != $expiration )
update_site_option($transient_timeout, time() + $expiration);
return update_site_option($transient, $value);
}
}
}
/**
* gmt_offset modification for smart timezone handling
*
* Overrides the gmt_offset option if we have a timezone_string available
*/
function wp_timezone_override_offset() {
if ( !wp_timezone_supported() ) {
return false;
}
if ( !$timezone_string = get_option( 'timezone_string' ) ) {
return false;
}
@date_default_timezone_set( $timezone_string );
$timezone_object = timezone_open( $timezone_string );
$datetime_object = date_create();
if ( false === $timezone_object || false === $datetime_object ) {
return false;
}
return round( timezone_offset_get( $timezone_object, $datetime_object ) / 3600, 2 );
}
/**
* Check for PHP timezone support
*/
function wp_timezone_supported() {
$support = false;
if (
function_exists( 'date_default_timezone_set' ) &&
function_exists( 'timezone_identifiers_list' ) &&
function_exists( 'timezone_open' ) &&
function_exists( 'timezone_offset_get' )
) {
$support = true;
}
return apply_filters( 'timezone_support', $support );
}
function _wp_timezone_choice_usort_callback( $a, $b ) {
// Don't use translated versions of Etc
if ( 'Etc' === $a['continent'] && 'Etc' === $b['continent'] ) {
// Make the order of these more like the old dropdown
if ( 'GMT+' === substr( $a['city'], 0, 4 ) && 'GMT+' === substr( $b['city'], 0, 4 ) ) {
return -1 * ( strnatcasecmp( $a['city'], $b['city'] ) );
}
if ( 'UTC' === $a['city'] ) {
if ( 'GMT+' === substr( $b['city'], 0, 4 ) ) {
return 1;
}
return -1;
}
if ( 'UTC' === $b['city'] ) {
if ( 'GMT+' === substr( $a['city'], 0, 4 ) ) {
return -1;
}
return 1;
}
return strnatcasecmp( $a['city'], $b['city'] );
}
if ( $a['t_continent'] == $b['t_continent'] ) {
if ( $a['t_city'] == $b['t_city'] ) {
return strnatcasecmp( $a['t_subcity'], $b['t_subcity'] );
}
return strnatcasecmp( $a['t_city'], $b['t_city'] );
} else {
// Force Etc to the bottom of the list
if ( 'Etc' === $a['continent'] ) {
return 1;
}
if ( 'Etc' === $b['continent'] ) {
return -1;
}
return strnatcasecmp( $a['t_continent'], $b['t_continent'] );
}
}
/**
* Gives a nicely formatted list of timezone strings // temporary! Not in final
*
* @param $selected_zone string Selected Zone
*
*/
function wp_timezone_choice( $selected_zone ) {
static $mo_loaded = false;
$continents = array( 'Africa', 'America', 'Antarctica', 'Arctic', 'Asia', 'Atlantic', 'Australia', 'Europe', 'Indian', 'Pacific', 'Etc' );
// Load translations for continents and cities
if ( !$mo_loaded ) {
$locale = get_locale();
$mofile = WP_LANG_DIR . '/continents-cities-' . $locale . '.mo';
load_textdomain( 'continents-cities', $mofile );
$mo_loaded = true;
}
$zonen = array();
foreach ( timezone_identifiers_list() as $zone ) {
$zone = explode( '/', $zone );
if ( !in_array( $zone[0], $continents ) ) {
continue;
}
if ( 'Etc' === $zone[0] && in_array( $zone[1], array( 'UCT', 'GMT', 'GMT0', 'GMT+0', 'GMT-0', 'Greenwich', 'Universal', 'Zulu' ) ) ) {
continue;
}
// This determines what gets set and translated - we don't translate Etc/* strings here, they are done later
$exists = array(
0 => ( isset( $zone[0] ) && $zone[0] ) ? true : false,
1 => ( isset( $zone[1] ) && $zone[1] ) ? true : false,
2 => ( isset( $zone[2] ) && $zone[2] ) ? true : false
);
$exists[3] = ( $exists[0] && 'Etc' !== $zone[0] ) ? true : false;
$exists[4] = ( $exists[1] && $exists[3] ) ? true : false;
$exists[5] = ( $exists[2] && $exists[3] ) ? true : false;
$zonen[] = array(
'continent' => ( $exists[0] ? $zone[0] : '' ),
'city' => ( $exists[1] ? $zone[1] : '' ),
'subcity' => ( $exists[2] ? $zone[2] : '' ),
't_continent' => ( $exists[3] ? translate( str_replace( '_', ' ', $zone[0] ), 'continents-cities' ) : '' ),
't_city' => ( $exists[4] ? translate( str_replace( '_', ' ', $zone[1] ), 'continents-cities' ) : '' ),
't_subcity' => ( $exists[5] ? translate( str_replace( '_', ' ', $zone[2] ), 'continents-cities' ) : '' )
);
}
usort( $zonen, '_wp_timezone_choice_usort_callback' );
$structure = array();
if ( empty( $selected_zone ) ) {
$structure[] = '';
}
foreach ( $zonen as $key => $zone ) {
// Build value in an array to join later
$value = array( $zone['continent'] );
if ( empty( $zone['city'] ) ) {
// It's at the continent level (generally won't happen)
$display = $zone['t_continent'];
} else {
// It's inside a continent group
// Continent optgroup
if ( !isset( $zonen[$key - 1] ) || $zonen[$key - 1]['continent'] !== $zone['continent'] ) {
$label = ( 'Etc' === $zone['continent'] ) ? __( 'Manual offsets' ) : $zone['t_continent'];
$structure[] = '';
}
}
return join( "\n", $structure );
}
/**
* Strip close comment and close php tags from file headers used by WP
* See http://core.trac.wordpress.org/ticket/8497
*
* @since 2.8
**/
function _cleanup_header_comment($str) {
return trim(preg_replace("/\s*(?:\*\/|\?>).*/", '', $str));
}
/**
* Permanently deletes posts, pages, attachments, and comments which have been in the trash for EMPTY_TRASH_DAYS.
*
* @since 2.9.0
*
* @return void
*/
function wp_scheduled_delete() {
global $wpdb;
$delete_timestamp = time() - (60*60*24*EMPTY_TRASH_DAYS);
$posts_to_delete = $wpdb->get_results($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wp_trash_meta_time' AND meta_value < '%d'", $delete_timestamp), ARRAY_A);
foreach ( (array) $posts_to_delete as $post ) {
wp_delete_post($post['post_id']);
}
$comments_to_delete = $wpdb->get_results($wpdb->prepare("SELECT comment_id FROM $wpdb->commentmeta WHERE meta_key = '_wp_trash_meta_time' AND meta_value < '%d'", $delete_timestamp), ARRAY_A);
foreach ( (array) $comments_to_delete as $comment ) {
wp_delete_comment($comment['comment_id']);
}
}
/**
* Parse the file contents to retrieve its metadata.
*
* Searches for metadata for a file, such as a plugin or theme. Each piece of
* metadata must be on its own line. For a field spanning multple lines, it
* must not have any newlines or only parts of it will be displayed.
*
* Some users have issues with opening large files and manipulating the contents
* for want is usually the first 1kiB or 2kiB. This function stops pulling in
* the file contents when it has all of the required data.
*
* The first 8kiB of the file will be pulled in and if the file data is not
* within that first 8kiB, then the author should correct their plugin file
* and move the data headers to the top.
*
* The file is assumed to have permissions to allow for scripts to read
* the file. This is not checked however and the file is only opened for
* reading.
*
* @since 2.9.0
*
* @param string $file Path to the file
* @param bool $markup If the returned data should have HTML markup applied
* @param string $context If specified adds filter hook "extra_<$context>_headers"
*/
function get_file_data( $file, $default_headers, $context = '' ) {
// We don't need to write to the file, so just open for reading.
$fp = fopen( $file, 'r' );
// Pull only the first 8kiB of the file in.
$file_data = fread( $fp, 8192 );
// PHP will close file handle, but we are good citizens.
fclose( $fp );
if( $context != '' ) {
$extra_headers = apply_filters( "extra_$context".'_headers', array() );
$extra_headers = array_flip( $extra_headers );
foreach( $extra_headers as $key=>$value ) {
$extra_headers[$key] = $key;
}
$all_headers = array_merge($extra_headers, $default_headers);
} else {
$all_headers = $default_headers;
}
foreach ( $all_headers as $field => $regex ) {
preg_match( '/' . preg_quote( $regex, '/' ) . ':(.*)$/mi', $file_data, ${$field});
if ( !empty( ${$field} ) )
${$field} = _cleanup_header_comment( ${$field}[1] );
else
${$field} = '';
}
$file_data = compact( array_keys( $all_headers ) );
return $file_data;
}
/*
* Used internally to tidy up the search terms
*
* @private
* @since 2.9.0
*/
function _search_terms_tidy($t) {
return trim($t, "\"\'\n\r ");
}
?>