-URL-encodes things that were already in the query string if ( is_array( func_get_arg( 0 ) ) ) { $kayvees = func_get_arg( 0 ); $qs = array_merge( $qs, $kayvees ); } else { $qs[func_get_arg( 0 )] = func_get_arg( 1 ); } foreach ( $qs as $k => $v ) { if ( $v === false ) unset( $qs[$k] ); } $ret = build_query( $qs ); $ret = trim( $ret, '?' ); $ret = preg_replace( '#=(&|$)#', '$1', $ret ); $ret = $protocol . $base . $ret . $frag; $ret = rtrim( $ret, '?' ); return $ret; } /** * Removes an item or list from the query string. * * @since 1.5.0 * * @param string|array $key Query key or keys to remove. * @param bool $query When false uses the $_SERVER value. * @return unknown */ function remove_query_arg( $key, $query=false ) { if ( is_array( $key ) ) { // removing multiple keys foreach ( (array) $key as $k ) $query = add_query_arg( $k, false, $query ); return $query; } return add_query_arg( $key, false, $query ); } /** * Walks the array while sanitizing the contents. * * @uses $wpdb Used to sanitize values * * @param array $array Array to used to walk while sanitizing contents. * @return array Sanitized $array. */ function add_magic_quotes( $array ) { global $wpdb; foreach ( $array as $k => $v ) { if ( is_array( $v ) ) { $array[$k] = add_magic_quotes( $v ); } else { $array[$k] = $wpdb->escape( $v ); } } return $array; } /** * HTTP request for URI to retrieve content. * * Tries to retrieve the HTTP content with fopen first and then using cURL, if * fopen can't be used. * * @since unknown * * @param string $uri URI/URL of web page to retrieve. * @return string HTTP content. */ function wp_remote_fopen( $uri ) { $timeout = 10; $parsed_url = @parse_url( $uri ); if ( !$parsed_url || !is_array( $parsed_url ) ) return false; if ( !isset( $parsed_url['scheme'] ) || !in_array( $parsed_url['scheme'], array( 'http','https' ) ) ) $uri = 'http://' . $uri; if ( ini_get( 'allow_url_fopen' ) ) { $fp = @fopen( $uri, 'r' ); if ( !$fp ) return false; //stream_set_timeout($fp, $timeout); // Requires php 4.3 $linea = ''; while ( $remote_read = fread( $fp, 4096 ) ) $linea .= $remote_read; fclose( $fp ); return $linea; } elseif ( function_exists( 'curl_init' ) ) { $handle = curl_init(); curl_setopt( $handle, CURLOPT_URL, $uri); curl_setopt( $handle, CURLOPT_CONNECTTIMEOUT, 1 ); curl_setopt( $handle, CURLOPT_RETURNTRANSFER, 1 ); curl_setopt( $handle, CURLOPT_TIMEOUT, $timeout ); $buffer = curl_exec( $handle ); curl_close( $handle ); return $buffer; } else { return false; } } function wp( $query_vars = '' ) { global $wp, $wp_query, $wp_the_query; $wp->main( $query_vars ); if( !isset($wp_the_query) ) $wp_the_query = $wp_query; } /** * Retrieve the description for the HTTP status. * * @since 2.3.0 * * @param int $code HTTP status code. * @return string Empty string if not found, or description if found. */ function get_status_header_desc( $code ) { global $wp_header_to_desc; $code = absint( $code ); if ( !isset( $wp_header_to_desc ) ) { $wp_header_to_desc = array( 100 => 'Continue', 101 => 'Switching Protocols', 200 => 'OK', 201 => 'Created', 202 => 'Accepted', 203 => 'Non-Authoritative Information', 204 => 'No Content', 205 => 'Reset Content', 206 => 'Partial Content', 300 => 'Multiple Choices', 301 => 'Moved Permanently', 302 => 'Found', 303 => 'See Other', 304 => 'Not Modified', 305 => 'Use Proxy', 307 => 'Temporary Redirect', 400 => 'Bad Request', 401 => 'Unauthorized', 403 => 'Forbidden', 404 => 'Not Found', 405 => 'Method Not Allowed', 406 => 'Not Acceptable', 407 => 'Proxy Authentication Required', 408 => 'Request Timeout', 409 => 'Conflict', 410 => 'Gone', 411 => 'Length Required', 412 => 'Precondition Failed', 413 => 'Request Entity Too Large', 414 => 'Request-URI Too Long', 415 => 'Unsupported Media Type', 416 => 'Requested Range Not Satisfiable', 417 => 'Expectation Failed', 500 => 'Internal Server Error', 501 => 'Not Implemented', 502 => 'Bad Gateway', 503 => 'Service Unavailable', 504 => 'Gateway Timeout', 505 => 'HTTP Version Not Supported' ); } if ( isset( $wp_header_to_desc[$code] ) ) return $wp_header_to_desc[$code]; else return ''; } /** * Set HTTP status header. * * @since unknown * @uses apply_filters() Calls 'status_header' on status header string, HTTP * HTTP code, HTTP code description, and protocol string as separate * parameters. * * @param int $header HTTP status code * @return null Does not return anything. */ function status_header( $header ) { $text = get_status_header_desc( $header ); if ( empty( $text ) ) return false; $protocol = $_SERVER["SERVER_PROTOCOL"]; if ( 'HTTP/1.1' != $protocol && 'HTTP/1.0' != $protocol ) $protocol = 'HTTP/1.0'; $status_header = "$protocol $header $text"; if ( function_exists( 'apply_filters' ) ) $status_header = apply_filters( 'status_header', $status_header, $header, $text, $protocol ); if ( version_compare( phpversion(), '4.3.0', '>=' ) ) return @header( $status_header, true, $header ); else return @header( $status_header ); } /** * Sets the headers to prevent caching for the different browsers. * * Different browsers support different nocache headers, so several headers must * be sent so that all of them get the point that no caching should occur. * * @since 2.0.0 */ function nocache_headers() { // why are these @-silenced when other header calls aren't? @header( 'Expires: Wed, 11 Jan 1984 05:00:00 GMT' ); @header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' ); @header( 'Cache-Control: no-cache, must-revalidate, max-age=0' ); @header( 'Pragma: no-cache' ); } /** * Set the headers for caching for 10 days with JavaScript content type. * * @since 2.1.0 */ function cache_javascript_headers() { $expiresOffset = 864000; // 10 days header( "Content-Type: text/javascript; charset=" . get_bloginfo( 'charset' ) ); header( "Vary: Accept-Encoding" ); // Handle proxies header( "Expires: " . gmdate( "D, d M Y H:i:s", time() + $expiresOffset ) . " GMT" ); } /** * Retrieve the number of database queries during the WordPress execution. * * @since 2.0.0 * * @return int Number of database queries */ function get_num_queries() { global $wpdb; return $wpdb->num_queries; } /** * Whether input is yes or no. Must be 'y' to be true. * * @since 1.0.0 * * @param string $yn Character string containing either 'y' or 'n' * @return bool True if yes, false on anything else */ function bool_from_yn( $yn ) { return ( strtolower( $yn ) == 'y' ); } function do_feed() { global $wp_query; $feed = get_query_var( 'feed' ); // Remove the pad, if present. $feed = preg_replace( '/^_+/', '', $feed ); if ( $feed == '' || $feed == 'feed' ) $feed = get_default_feed(); $hook = 'do_feed_' . $feed; if ( !has_action($hook) ) { $message = sprintf( __( 'ERROR: %s is not a valid feed template' ), wp_specialchars($feed)); wp_die($message); } do_action( $hook, $wp_query->is_comment_feed ); } /** * Load the RDF RSS 0.91 Feed template. * * @since 2.1.0 */ function do_feed_rdf() { load_template( ABSPATH . WPINC . '/feed-rdf.php' ); } /** * Load the RSS 1.0 Feed Template * * @since 2.1.0 */ function do_feed_rss() { load_template( ABSPATH . WPINC . '/feed-rss.php' ); } /** * Load either the RSS2 comment feed or the RSS2 posts feed. * * @since 2.1.0 * * @param bool $for_comments True for the comment feed, false for normal feed. */ function do_feed_rss2( $for_comments ) { if ( $for_comments ) load_template( ABSPATH . WPINC . '/feed-rss2-comments.php' ); else load_template( ABSPATH . WPINC . '/feed-rss2.php' ); } /** * Load either Atom comment feed or Atom posts feed. * * @since 2.1.0 * * @param bool $for_comments True for the comment feed, false for normal feed. */ function do_feed_atom( $for_comments ) { if ($for_comments) load_template( ABSPATH . WPINC . '/feed-atom-comments.php'); else load_template( ABSPATH . WPINC . '/feed-atom.php' ); } /** * Display the robot.txt file content. * * The echo content should be with usage of the permalinks or for creating the * robot.txt file. * * @since 2.1.0 * @uses do_action() Calls 'do_robotstxt' hook for displaying robot.txt rules. */ function do_robots() { header( 'Content-Type: text/plain; charset=utf-8' ); do_action( 'do_robotstxt' ); if ( '0' == get_option( 'blog_public' ) ) { echo "User-agent: *\n"; echo "Disallow: /\n"; } else { echo "User-agent: *\n"; echo "Disallow:\n"; } } function is_blog_installed() { global $wpdb; // Check cache first. If options table goes away and we have true cached, oh well. if ( wp_cache_get('is_blog_installed') ) return true; $suppress = $wpdb->suppress_errors(); $installed = $wpdb->get_var( "SELECT option_value FROM $wpdb->options WHERE option_name = 'siteurl'" ); $wpdb->suppress_errors($suppress); $installed = !empty( $installed ) ? true : false; wp_cache_set('is_blog_installed', $installed); return $installed; } function wp_nonce_url( $actionurl, $action = -1 ) { $actionurl = str_replace( '&', '&', $actionurl ); return wp_specialchars( add_query_arg( '_wpnonce', wp_create_nonce( $action ), $actionurl ) ); } function wp_nonce_field( $action = -1, $name = "_wpnonce", $referer = true , $echo = true ) { $name = attribute_escape( $name ); $nonce_field = ''; if ( $echo ) echo $nonce_field; if ( $referer ) wp_referer_field( $echo, 'previous' ); return $nonce_field; } function wp_referer_field( $echo = true) { $ref = attribute_escape( $_SERVER['REQUEST_URI'] ); $referer_field = ''; if ( $echo ) echo $referer_field; return $referer_field; } function wp_original_referer_field( $echo = true, $jump_back_to = 'current' ) { $jump_back_to = ( 'previous' == $jump_back_to ) ? wp_get_referer() : $_SERVER['REQUEST_URI']; $ref = ( wp_get_original_referer() ) ? wp_get_original_referer() : $jump_back_to; $orig_referer_field = ''; if ( $echo ) echo $orig_referer_field; return $orig_referer_field; } function wp_get_referer() { if ( ! empty( $_REQUEST['_wp_http_referer'] ) ) $ref = $_REQUEST['_wp_http_referer']; else if ( ! empty( $_SERVER['HTTP_REFERER'] ) ) $ref = $_SERVER['HTTP_REFERER']; if ( $ref !== $_SERVER['REQUEST_URI'] ) return $ref; return false; } function wp_get_original_referer() { if ( !empty( $_REQUEST['_wp_original_http_referer'] ) ) return $_REQUEST['_wp_original_http_referer']; return false; } function wp_mkdir_p( $target ) { // from php.net/mkdir user contributed notes $target = str_replace( '//', '/', $target ); if ( file_exists( $target ) ) return @is_dir( $target ); // Attempting to create the directory may clutter up our display. if ( @mkdir( $target ) ) { $stat = @stat( dirname( $target ) ); $dir_perms = $stat['mode'] & 0007777; // Get the permission bits. @chmod( $target, $dir_perms ); return true; } elseif ( is_dir( dirname( $target ) ) ) { return false; } // If the above failed, attempt to create the parent node, then try again. if ( wp_mkdir_p( dirname( $target ) ) ) return wp_mkdir_p( $target ); return false; } // Test if a give filesystem path is absolute ('/foo/bar', 'c:\windows') function path_is_absolute( $path ) { // this is definitive if true but fails if $path does not exist or contains a symbolic link if ( realpath($path) == $path ) return true; if ( strlen($path) == 0 || $path{0} == '.' ) return false; // windows allows absolute paths like this if ( preg_match('#^[a-zA-Z]:\\\\#', $path) ) return true; // a path starting with / or \ is absolute; anything else is relative return (bool) preg_match('#^[/\\\\]#', $path); } // Join two filesystem paths together (e.g. 'give me $path relative to $base') function path_join( $base, $path ) { if ( path_is_absolute($path) ) return $path; return rtrim($base, '/') . '/' . ltrim($path, '/'); } // Returns an array containing the current upload directory's path and url, or an error message. function wp_upload_dir( $time = NULL ) { $siteurl = get_option( 'siteurl' ); $upload_path = get_option( 'upload_path' ); $upload_path = trim($upload_path); if ( empty($upload_path) ) $dir = WP_CONTENT_DIR . '/uploads'; else $dir = $upload_path; // $dir is absolute, $path is (maybe) relative to ABSPATH $dir = path_join( ABSPATH, $dir ); if ( !$url = get_option( 'upload_url_path' ) ) { if ( empty($upload_path) or ( $upload_path == $dir ) ) $url = WP_CONTENT_URL . '/uploads'; else $url = trailingslashit( $siteurl ) . $upload_path; } if ( defined('UPLOADS') ) { $dir = ABSPATH . UPLOADS; $url = trailingslashit( $siteurl ) . UPLOADS; } $bdir = $dir; $burl = $url; $subdir = ''; if ( get_option( 'uploads_use_yearmonth_folders' ) ) { // Generate the yearly and monthly dirs if ( !$time ) $time = current_time( 'mysql' ); $y = substr( $time, 0, 4 ); $m = substr( $time, 5, 2 ); $subdir = "/$y/$m"; } $dir .= $subdir; $url .= $subdir; // Make sure we have an uploads dir if ( ! wp_mkdir_p( $dir ) ) { $message = sprintf( __( 'Unable to create directory %s. Is its parent directory writable by the server?' ), $dir ); return array( 'error' => $message ); } $uploads = array( 'path' => $dir, 'url' => $url, 'subdir' => $subdir, 'basedir' => $bdir, 'baseurl' => $burl, 'error' => false ); return apply_filters( 'upload_dir', $uploads ); } // return a filename that is sanitized and unique for the given directory function wp_unique_filename( $dir, $filename, $unique_filename_callback = NULL ) { $filename = strtolower( $filename ); // separate the filename into a name and extension $info = pathinfo($filename); $ext = $info['extension']; $name = basename($filename, ".{$ext}"); // edge case: if file is named '.ext', treat as an empty name if( $name === ".$ext" ) $name = ''; // Increment the file number until we have a unique file to save in $dir. Use $override['unique_filename_callback'] if supplied. if ( $unique_filename_callback && function_exists( $unique_filename_callback ) ) { $filename = $unique_filename_callback( $dir, $name ); } else { $number = ''; if ( empty( $ext ) ) $ext = ''; else $ext = strtolower( ".$ext" ); $filename = str_replace( $ext, '', $filename ); // Strip % so the server doesn't try to decode entities. $filename = str_replace('%', '', sanitize_title_with_dashes( $filename ) ) . $ext; while ( file_exists( $dir . "/$filename" ) ) { if ( '' == "$number$ext" ) $filename = $filename . ++$number . $ext; else $filename = str_replace( "$number$ext", ++$number . $ext, $filename ); } } return $filename; } function wp_upload_bits( $name, $deprecated, $bits, $time = NULL ) { if ( empty( $name ) ) return array( 'error' => __( "Empty filename" ) ); $wp_filetype = wp_check_filetype( $name ); if ( !$wp_filetype['ext'] ) return array( 'error' => __( "Invalid file type" ) ); $upload = wp_upload_dir( $time ); if ( $upload['error'] !== false ) return $upload; $filename = wp_unique_filename( $upload['path'], $name ); $new_file = $upload['path'] . "/$filename"; if ( ! wp_mkdir_p( dirname( $new_file ) ) ) { $message = sprintf( __( 'Unable to create directory %s. Is its parent directory writable by the server?' ), dirname( $new_file ) ); return array( 'error' => $message ); } $ifp = @ fopen( $new_file, 'wb' ); if ( ! $ifp ) return array( 'error' => sprintf( __( 'Could not write file %s' ), $new_file ) ); @fwrite( $ifp, $bits ); fclose( $ifp ); // Set correct file permissions $stat = @ stat( dirname( $new_file ) ); $perms = $stat['mode'] & 0007777; $perms = $perms & 0000666; @ chmod( $new_file, $perms ); // Compute the URL $url = $upload['url'] . "/$filename"; return array( 'file' => $new_file, 'url' => $url, 'error' => false ); } function wp_ext2type( $ext ) { $ext2type = apply_filters('ext2type', array( 'audio' => array('aac','ac3','aif','aiff','mp1','mp2','mp3','m3a','m4a','m4b','ogg','ram','wav','wma'), 'video' => array('asf','avi','divx','dv','mov','mpg','mpeg','mp4','mpv','ogm','qt','rm','vob','wmv'), 'document' => array('doc','pages','odt','rtf','pdf'), 'spreadsheet' => array('xls','numbers','ods'), 'interactive' => array('ppt','key','odp','swf'), 'text' => array('txt'), 'archive' => array('tar','bz2','gz','cab','dmg','rar','sea','sit','sqx','zip'), 'code' => array('css','html','php','js'), )); foreach ( $ext2type as $type => $exts ) if ( in_array($ext, $exts) ) return $type; } function wp_check_filetype( $filename, $mimes = null ) { // Accepted MIME types are set here as PCRE unless provided. $mimes = ( is_array( $mimes ) ) ? $mimes : apply_filters( 'upload_mimes', array( 'jpg|jpeg|jpe' => 'image/jpeg', 'gif' => 'image/gif', 'png' => 'image/png', 'bmp' => 'image/bmp', 'tif|tiff' => 'image/tiff', 'ico' => 'image/x-icon', 'asf|asx|wax|wmv|wmx' => 'video/asf', 'avi' => 'video/avi', 'mov|qt' => 'video/quicktime', 'mpeg|mpg|mpe|mp4' => 'video/mpeg', 'txt|c|cc|h' => 'text/plain', 'rtx' => 'text/richtext', 'css' => 'text/css', 'htm|html' => 'text/html', 'mp3|m4a' => 'audio/mpeg', 'ra|ram' => 'audio/x-realaudio', 'wav' => 'audio/wav', 'ogg' => 'audio/ogg', 'mid|midi' => 'audio/midi', 'wma' => 'audio/wma', 'rtf' => 'application/rtf', 'js' => 'application/javascript', 'pdf' => 'application/pdf', 'doc' => 'application/msword', 'pot|pps|ppt' => 'application/vnd.ms-powerpoint', 'wri' => 'application/vnd.ms-write', 'xla|xls|xlt|xlw' => 'application/vnd.ms-excel', 'mdb' => 'application/vnd.ms-access', 'mpp' => 'application/vnd.ms-project', 'swf' => 'application/x-shockwave-flash', 'class' => 'application/java', 'tar' => 'application/x-tar', 'zip' => 'application/zip', 'gz|gzip' => 'application/x-gzip', 'exe' => 'application/x-msdownload', // openoffice formats 'odt' => 'application/vnd.oasis.opendocument.text', 'odp' => 'application/vnd.oasis.opendocument.presentation', 'ods' => 'application/vnd.oasis.opendocument.spreadsheet', 'odg' => 'application/vnd.oasis.opendocument.graphics', 'odc' => 'application/vnd.oasis.opendocument.chart', 'odb' => 'application/vnd.oasis.opendocument.database', 'odf' => 'application/vnd.oasis.opendocument.formula', ) ); $type = false; $ext = false; foreach ( $mimes as $ext_preg => $mime_match ) { $ext_preg = '!\.(' . $ext_preg . ')$!i'; if ( preg_match( $ext_preg, $filename, $ext_matches ) ) { WordPress › Error

There doesn't seem to be a wp-config.php file. I need this before we can get started. Need more help? We got it. You can create a wp-config.php file through a web interface, but this doesn't work for all server setups. The safest way is to manually create the file.

Create a Configuration File