to be integer, ' . gettype( $quote_style ) . ' given', E_USER_WARNING ); return; } return wp_specialchars_decode( $string, $quote_style ); } } // For PHP < 5.2.0 if ( !function_exists('json_encode') ) { function json_encode( $string ) { global $wp_json; if ( !is_a($wp_json, 'Services_JSON') ) { require_once( 'class-json.php' ); $wp_json = new Services_JSON(); } return $wp_json->encodeUnsafe( $string ); } } if ( !function_exists('json_decode') ) { function json_decode( $string ) { global $wp_json; if ( !is_a($wp_json, 'Services_JSON') ) { require_once( 'class-json.php' ); $wp_json = new Services_JSON(); } return $wp_json->decode( $string ); } } // pathinfo that fills 'filename' without extension like in PHP 5.2+ function pathinfo52($path) { $parts = pathinfo($path); if ( !isset($parts['filename']) ) { $parts['filename'] = substr( $parts['basename'], 0, strrpos($parts['basename'], '.') ); if ( empty($parts['filename']) ) // there's no extension $parts['filename'] = $parts['basename']; } return $parts; } rt_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'); // 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; } // 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 = $zone['t_continent']; $structure[] = ''; } } // Do UTC $structure[] = ''; // Do manual UTC offsets $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 ) { $post_id = (int) $post['post_id']; if ( !$post_id ) continue; $del_post = get_post($post_id); if ( !$del_post || 'trash' != $del_post->post_status ) { delete_post_meta($post_id, '_wp_trash_meta_status'); delete_post_meta($post_id, '_wp_trash_meta_time'); } else { wp_delete_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 ) { $comment_id = (int) $comment['comment_id']; if ( !$comment_id ) continue; $del_comment = get_comment($comment_id); if ( !$del_comment || 'trash' != $del_comment->comment_approved ) { delete_comment_meta($comment_id, '_wp_trash_meta_time'); delete_comment_meta($comment_id, '_wp_trash_meta_status'); } else { wp_delete_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 "); } ?> e specified table, resource = the database corresponding to the specified mysql resource. * @return false|string false on failure, version number on success */ function db_version() { return preg_replace('/[^0-9.].*/', '', mysql_get_server_info( $this->dbh )); } } if ( ! isset($wpdb) ) { /** * WordPress Database Object, if it isn't set already in wp-content/db.php * @global object $wpdb Creates a new wpdb object based on wp-config.php Constants for the database * @since 0.71 */ $wpdb = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST); } ?>