+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 robots.txt file content.
+ *
+ * The echo content should be with usage of the permalinks or for creating the
+ * robots.txt file.
+ *
+ * @since 2.1.0
+ * @uses do_action() Calls 'do_robotstxt' hook for displaying robots.txt rules.
+ */
+function do_robots() {
+ header( 'Content-Type: text/plain; charset=utf-8' );
+
+ do_action( 'do_robotstxt' );
+
+ $output = "User-agent: *\n";
+ $public = get_option( 'blog_public' );
+ if ( '0' == $public ) {
+ $output .= "Disallow: /\n";
+ } else {
+ $site_url = parse_url( site_url() );
+ $path = ( !empty( $site_url['path'] ) ) ? $site_url['path'] : '';
+ $output .= "Disallow: $path/wp-admin/\n";
+ $output .= "Disallow: $path/wp-includes/\n";
+ }
+
+ echo apply_filters('robots_txt', $output, $public);
+}
+
+/**
+ * Test whether blog is already installed.
+ *
+ * The cache will be checked first. If you have a cache plugin, which saves the
+ * cache values, then this will work. If you use the default WordPress cache,
+ * and the database goes away, then you might have problems.
+ *
+ * Checks for the option siteurl for whether WordPress is installed.
+ *
+ * @since 2.1.0
+ * @uses $wpdb
+ *
+ * @return bool Whether blog is already installed.
+ */
+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();
+ if ( ! defined( 'WP_INSTALLING' ) ) {
+ $alloptions = wp_load_alloptions();
+ }
+ // If siteurl is not set to autoload, check it specifically
+ if ( !isset( $alloptions['siteurl'] ) )
+ $installed = $wpdb->get_var( "SELECT option_value FROM $wpdb->options WHERE option_name = 'siteurl'" );
+ else
+ $installed = $alloptions['siteurl'];
+ $wpdb->suppress_errors( $suppress );
+
+ $installed = !empty( $installed );
+ wp_cache_set( 'is_blog_installed', $installed );
+
+ if ( $installed )
+ return true;
+
+ // If visiting repair.php, return true and let it take over.
+ if ( defined( 'WP_REPAIRING' ) )
+ return true;
+
+ $suppress = $wpdb->suppress_errors();
+
+ // Loop over the WP tables. If none exist, then scratch install is allowed.
+ // If one or more exist, suggest table repair since we got here because the options
+ // table could not be accessed.
+ $wp_tables = $wpdb->tables();
+ foreach ( $wp_tables as $table ) {
+ // The existence of custom user tables shouldn't suggest an insane state or prevent a clean install.
+ if ( defined( 'CUSTOM_USER_TABLE' ) && CUSTOM_USER_TABLE == $table )
+ continue;
+ if ( defined( 'CUSTOM_USER_META_TABLE' ) && CUSTOM_USER_META_TABLE == $table )
+ continue;
+
+ if ( ! $wpdb->get_results( "DESCRIBE $table;" ) )
+ continue;
+
+ // One or more tables exist. We are insane.
+
+ wp_load_translations_early();
+
+ // Die with a DB error.
+ $wpdb->error = sprintf( __( 'One or more database tables are unavailable. The database may need to be <a href="%s">repaired</a>.' ), 'maint/repair.php?referrer=is_blog_installed' );
+ dead_db();
+ }
+
+ $wpdb->suppress_errors( $suppress );
+
+ wp_cache_set( 'is_blog_installed', false );
+
+ return false;
+}
+
+/**
+ * Retrieve URL with nonce added to URL query.
+ *
+ * @package WordPress
+ * @subpackage Security
+ * @since 2.0.4
+ *
+ * @param string $actionurl URL to add nonce action.
+ * @param string $action Optional. Nonce action name.
+ * @param string $name Optional. Nonce name.
+ * @return string URL with nonce action added.
+ */
+function wp_nonce_url( $actionurl, $action = -1, $name = '_wpnonce' ) {
+ $actionurl = str_replace( '&', '&', $actionurl );
+ return esc_html( add_query_arg( $name, wp_create_nonce( $action ), $actionurl ) );
+}
+
+/**
+ * Retrieve or display nonce hidden field for forms.
+ *
+ * The nonce field is used to validate that the contents of the form came from
+ * the location on the current site and not somewhere else. The nonce does not
+ * offer absolute protection, but should protect against most cases. It is very
+ * important to use nonce field in forms.
+ *
+ * The $action and $name are optional, but if you want to have better security,
+ * it is strongly suggested to set those two parameters. It is easier to just
+ * call the function without any parameters, because validation of the nonce
+ * doesn't require any parameters, but since crackers know what the default is
+ * it won't be difficult for them to find a way around your nonce and cause
+ * damage.
+ *
+ * The input name will be whatever $name value you gave. The input value will be
+ * the nonce creation value.
+ *
+ * @package WordPress
+ * @subpackage Security
+ * @since 2.0.4
+ *
+ * @param string $action Optional. Action name.
+ * @param string $name Optional. Nonce name.
+ * @param bool $referer Optional, default true. Whether to set the referer field for validation.
+ * @param bool $echo Optional, default true. Whether to display or return hidden form field.
+ * @return string Nonce field.
+ */
+function wp_nonce_field( $action = -1, $name = "_wpnonce", $referer = true , $echo = true ) {
+ $name = esc_attr( $name );
+ $nonce_field = '<input type="hidden" id="' . $name . '" name="' . $name . '" value="' . wp_create_nonce( $action ) . '" />';
+
+ if ( $referer )
+ $nonce_field .= wp_referer_field( false );
+
+ if ( $echo )
+ echo $nonce_field;
+
+ return $nonce_field;
+}
+
+/**
+ * Retrieve or display referer hidden field for forms.
+ *
+ * The referer link is the current Request URI from the server super global. The
+ * input name is '_wp_http_referer', in case you wanted to check manually.
+ *
+ * @package WordPress
+ * @subpackage Security
+ * @since 2.0.4
+ *
+ * @param bool $echo Whether to echo or return the referer field.
+ * @return string Referer field.
+ */
+function wp_referer_field( $echo = true ) {
+ $referer_field = '<input type="hidden" name="_wp_http_referer" value="'. esc_attr( wp_unslash( $_SERVER['REQUEST_URI'] ) ) . '" />';
+
+ if ( $echo )
+ echo $referer_field;
+ return $referer_field;
+}
+
+/**
+ * Retrieve or display original referer hidden field for forms.
+ *
+ * The input name is '_wp_original_http_referer' and will be either the same
+ * value of {@link wp_referer_field()}, if that was posted already or it will
+ * be the current page, if it doesn't exist.
+ *
+ * @package WordPress
+ * @subpackage Security
+ * @since 2.0.4
+ *
+ * @param bool $echo Whether to echo the original http referer
+ * @param string $jump_back_to Optional, default is 'current'. Can be 'previous' or page you want to jump back to.
+ * @return string Original referer field.
+ */
+function wp_original_referer_field( $echo = true, $jump_back_to = 'current' ) {
+ if ( ! $ref = wp_get_original_referer() ) {
+ $ref = 'previous' == $jump_back_to ? wp_get_referer() : wp_unslash( $_SERVER['REQUEST_URI'] );
+ }
+ $orig_referer_field = '<input type="hidden" name="_wp_original_http_referer" value="' . esc_attr( $ref ) . '" />';
+ if ( $echo )
+ echo $orig_referer_field;
+ return $orig_referer_field;
+}
+
+/**
+ * Retrieve referer from '_wp_http_referer' or HTTP referer. If it's the same
+ * as the current request URL, will return false.
+ *
+ * @package WordPress
+ * @subpackage Security
+ * @since 2.0.4
+ *
+ * @return string|bool False on failure. Referer URL on success.
+ */
+function wp_get_referer() {
+ $ref = false;
+ if ( ! empty( $_REQUEST['_wp_http_referer'] ) )
+ $ref = wp_unslash( $_REQUEST['_wp_http_referer'] );
+ else if ( ! empty( $_SERVER['HTTP_REFERER'] ) )
+ $ref = wp_unslash( $_SERVER['HTTP_REFERER'] );
+
+ if ( $ref && $ref !== wp_unslash( $_SERVER['REQUEST_URI'] ) )
+ return wp_unslash( $ref );
+ return false;
+}
+
+/**
+ * Retrieve original referer that was posted, if it exists.
+ *
+ * @package WordPress
+ * @subpackage Security
+ * @since 2.0.4
+ *
+ * @return string|bool False if no original referer or original referer if set.
+ */
+function wp_get_original_referer() {
+ if ( !empty( $_REQUEST['_wp_original_http_referer'] ) )
+ return wp_unslash( $_REQUEST['_wp_original_http_referer'] );
+ return false;
+}
+
+/**
+ * Recursive directory creation based on full path.
+ *
+ * Will attempt to set permissions on folders.
+ *
+ * @since 2.0.1
+ *
+ * @param string $target Full path to attempt to create.
+ * @return bool Whether the path was created. True if path already exists.
+ */
+function wp_mkdir_p( $target ) {
+ $wrapper = null;
+
+ // strip the protocol
+ if( wp_is_stream( $target ) ) {
+ list( $wrapper, $target ) = explode( '://', $target, 2 );
+ }
+
+ // from php.net/mkdir user contributed notes
+ $target = str_replace( '//', '/', $target );
+
+ // put the wrapper back on the target
+ if( $wrapper !== null ) {
+ $target = $wrapper . '://' . $target;
+ }
+
+ // safe mode fails with a trailing slash under certain PHP versions.
+ $target = rtrim($target, '/'); // Use rtrim() instead of untrailingslashit to avoid formatting.php dependency.
+ if ( empty($target) )
+ $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 ( ( $target != '/' ) && ( wp_mkdir_p( dirname( $target ) ) ) )
+ return wp_mkdir_p( $target );
+
+ return false;
+}
+
+/**
+ * Test if a give filesystem path is absolute ('/foo/bar', 'c:\windows').
+ *
+ * @since 2.5.0
+ *
+ * @param string $path File path
+ * @return bool True if path is absolute, false is not absolute.
+ */
+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 ( $path[0] == '/' || $path[0] == '\\' );
+}
+
+/**
+ * Join two filesystem paths together (e.g. 'give me $path relative to $base').
+ *
+ * If the $path is absolute, then it the full path is returned.
+ *
+ * @since 2.5.0
+ *
+ * @param string $base
+ * @param string $path
+ * @return string The path with the base or absolute path.
+ */
+function path_join( $base, $path ) {
+ if ( path_is_absolute($path) )
+ return $path;
+
+ return rtrim($base, '/') . '/' . ltrim($path, '/');
+}
+
+/**
+ * Determines a writable directory for temporary files.
+ * Function's preference is the return value of <code>sys_get_temp_dir()</code>,
+ * followed by your PHP temporary upload directory, followed by WP_CONTENT_DIR,
+ * before finally defaulting to /tmp/
+ *
+ * In the event that this function does not find a writable location,
+ * It may be overridden by the <code>WP_TEMP_DIR</code> constant in
+ * your <code>wp-config.php</code> file.
+ *
+ * @since 2.5.0
+ *
+ * @return string Writable temporary directory
+ */
+function get_temp_dir() {
+ static $temp;
+ if ( defined('WP_TEMP_DIR') )
+ return trailingslashit(WP_TEMP_DIR);
+
+ if ( $temp )
+ return trailingslashit( rtrim( $temp, '\\' ) );
+
+ if ( function_exists('sys_get_temp_dir') ) {
+ $temp = sys_get_temp_dir();
+ if ( @is_dir( $temp ) && wp_is_writable( $temp ) )
+ return trailingslashit( rtrim( $temp, '\\' ) );
+ }
+
+ $temp = ini_get('upload_tmp_dir');
+ if ( is_dir( $temp ) && wp_is_writable( $temp ) )
+ return trailingslashit( rtrim( $temp, '\\' ) );
+
+ $temp = WP_CONTENT_DIR . '/';
+ if ( is_dir( $temp ) && wp_is_writable( $temp ) )
+ return $temp;
+
+ $temp = '/tmp/';
+ return $temp;
+}
+
+/**
+ * Determine if a directory is writable.
+ *
+ * This function is used to work around certain ACL issues
+ * in PHP primarily affecting Windows Servers.
+ *
+ * @see win_is_writable()
+ *
+ * @since 3.6.0
+ *
+ * @param string $path
+ * @return bool
+ */
+function wp_is_writable( $path ) {
+ if ( 'WIN' === strtoupper( substr( PHP_OS, 0, 3 ) ) )
+ return win_is_writable( $path );
+ else
+ return @is_writable( $path );
+}
+
+/**
+ * Workaround for Windows bug in is_writable() function
+ *
+ * PHP has issues with Windows ACL's for determine if a
+ * directory is writable or not, this works around them by
+ * checking the ability to open files rather than relying
+ * upon PHP to interprate the OS ACL.
+ *
+ * @link http://bugs.php.net/bug.php?id=27609
+ * @link http://bugs.php.net/bug.php?id=30931
+ *
+ * @since 2.8.0
+ *
+ * @param string $path
+ * @return bool
+ */
+function win_is_writable( $path ) {
+
+ if ( $path[strlen( $path ) - 1] == '/' ) // if it looks like a directory, check a random file within the directory
+ return win_is_writable( $path . uniqid( mt_rand() ) . '.tmp');
+ else if ( is_dir( $path ) ) // If it's a directory (and not a file) check a random file within the directory
+ return win_is_writable( $path . '/' . uniqid( mt_rand() ) . '.tmp' );
+
+ // check tmp file for read/write capabilities
+ $should_delete_tmp_file = !file_exists( $path );
+ $f = @fopen( $path, 'a' );
+ if ( $f === false )
+ return false;
+ fclose( $f );
+ if ( $should_delete_tmp_file )
+ unlink( $path );
+ return true;
+}
+
+/**
+ * Get an array containing the current upload directory's path and url.
+ *
+ * Checks the 'upload_path' option, which should be from the web root folder,
+ * and if it isn't empty it will be used. If it is empty, then the path will be
+ * 'WP_CONTENT_DIR/uploads'. If the 'UPLOADS' constant is defined, then it will
+ * override the 'upload_path' option and 'WP_CONTENT_DIR/uploads' path.
+ *
+ * The upload URL path is set either by the 'upload_url_path' option or by using
+ * the 'WP_CONTENT_URL' constant and appending '/uploads' to the path.
+ *
+ * If the 'uploads_use_yearmonth_folders' is set to true (checkbox if checked in
+ * the administration settings panel), then the time will be used. The format
+ * will be year first and then month.
+ *
+ * If the path couldn't be created, then an error will be returned with the key
+ * 'error' containing the error message. The error suggests that the parent
+ * directory is not writable by the server.
+ *
+ * On success, the returned array will have many indices:
+ * 'path' - base directory and sub directory or full path to upload directory.
+ * 'url' - base url and sub directory or absolute URL to upload directory.
+ * 'subdir' - sub directory if uploads use year/month folders option is on.
+ * 'basedir' - path without subdir.
+ * 'baseurl' - URL path without subdir.
+ * 'error' - set to false.
+ *
+ * @since 2.0.0
+ * @uses apply_filters() Calls 'upload_dir' on returned array.
+ *
+ * @param string $time Optional. Time formatted in 'yyyy/mm'.
+ * @return array See above for description.
+ */
+function wp_upload_dir( $time = null ) {
+ $siteurl = get_option( 'siteurl' );
+ $upload_path = trim( get_option( 'upload_path' ) );
+
+ if ( empty( $upload_path ) || 'wp-content/uploads' == $upload_path ) {
+ $dir = WP_CONTENT_DIR . '/uploads';
+ } elseif ( 0 !== strpos( $upload_path, ABSPATH ) ) {
+ // $dir is absolute, $upload_path is (maybe) relative to ABSPATH
+ $dir = path_join( ABSPATH, $upload_path );
+ } else {
+ $dir = $upload_path;
+ }
+
+ if ( !$url = get_option( 'upload_url_path' ) ) {
+ if ( empty($upload_path) || ( 'wp-content/uploads' == $upload_path ) || ( $upload_path == $dir ) )
+ $url = WP_CONTENT_URL . '/uploads';
+ else
+ $url = trailingslashit( $siteurl ) . $upload_path;
+ }
+
+ // Obey the value of UPLOADS. This happens as long as ms-files rewriting is disabled.
+ // We also sometimes obey UPLOADS when rewriting is enabled -- see the next block.
+ if ( defined( 'UPLOADS' ) && ! ( is_multisite() && get_site_option( 'ms_files_rewriting' ) ) ) {
+ $dir = ABSPATH . UPLOADS;
+ $url = trailingslashit( $siteurl ) . UPLOADS;
+ }
+
+ // If multisite (and if not the main site in a post-MU network)
+ if ( is_multisite() && ! ( is_main_site() && defined( 'MULTISITE' ) ) ) {
+
+ if ( ! get_site_option( 'ms_files_rewriting' ) ) {
+ // If ms-files rewriting is disabled (networks created post-3.5), it is fairly straightforward:
+ // Append sites/%d if we're not on the main site (for post-MU networks). (The extra directory
+ // prevents a four-digit ID from conflicting with a year-based directory for the main site.
+ // But if a MU-era network has disabled ms-files rewriting manually, they don't need the extra
+ // directory, as they never had wp-content/uploads for the main site.)
+
+ if ( defined( 'MULTISITE' ) )
+ $ms_dir = '/sites/' . get_current_blog_id();
+ else
+ $ms_dir = '/' . get_current_blog_id();
+
+ $dir .= $ms_dir;
+ $url .= $ms_dir;
+
+ } elseif ( defined( 'UPLOADS' ) && ! ms_is_switched() ) {
+ // Handle the old-form ms-files.php rewriting if the network still has that enabled.
+ // When ms-files rewriting is enabled, then we only listen to UPLOADS when:
+ // 1) we are not on the main site in a post-MU network,
+ // as wp-content/uploads is used there, and
+ // 2) we are not switched, as ms_upload_constants() hardcodes
+ // these constants to reflect the original blog ID.
+ //
+ // Rather than UPLOADS, we actually use BLOGUPLOADDIR if it is set, as it is absolute.
+ // (And it will be set, see ms_upload_constants().) Otherwise, UPLOADS can be used, as
+ // as it is relative to ABSPATH. For the final piece: when UPLOADS is used with ms-files
+ // rewriting in multisite, the resulting URL is /files. (#WP22702 for background.)
+
+ if ( defined( 'BLOGUPLOADDIR' ) )
+ $dir = untrailingslashit( BLOGUPLOADDIR );
+ else
+ $dir = ABSPATH . UPLOADS;
+ $url = trailingslashit( $siteurl ) . 'files';
+ }
+ }
+
+ $basedir = $dir;
+ $baseurl = $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;
+
+ $uploads = apply_filters( 'upload_dir',
+ array(
+ 'path' => $dir,
+ 'url' => $url,
+ 'subdir' => $subdir,
+ 'basedir' => $basedir,
+ 'baseurl' => $baseurl,
+ 'error' => false,
+ ) );
+
+ // Make sure we have an uploads dir
+ if ( ! wp_mkdir_p( $uploads['path'] ) ) {
+ if ( 0 === strpos( $uploads['basedir'], ABSPATH ) )
+ $error_path = str_replace( ABSPATH, '', $uploads['basedir'] ) . $uploads['subdir'];
+ else
+ $error_path = basename( $uploads['basedir'] ) . $uploads['subdir'];
+
+ $message = sprintf( __( 'Unable to create directory %s. Is its parent directory writable by the server?' ), $error_path );
+ $uploads['error'] = $message;
+ }
+
+ return $uploads;
+}
+
+/**
+ * Get a filename that is sanitized and unique for the given directory.
+ *
+ * If the filename is not unique, then a number will be added to the filename
+ * before the extension, and will continue adding numbers until the filename is
+ * unique.
+ *
+ * The callback is passed three parameters, the first one is the directory, the
+ * second is the filename, and the third is the extension.
+ *
+ * @since 2.5.0
+ *
+ * @param string $dir
+ * @param string $filename
+ * @param mixed $unique_filename_callback Callback.
+ * @return string New filename, if given wasn't unique.
+ */
+function wp_unique_filename( $dir, $filename, $unique_filename_callback = null ) {
+ // sanitize the file name before we begin processing
+ $filename = sanitize_file_name($filename);
+
+ // separate the filename into a name and extension
+ $info = pathinfo($filename);
+ $ext = !empty($info['extension']) ? '.' . $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 callback if supplied.
+ if ( $unique_filename_callback && is_callable( $unique_filename_callback ) ) {
+ $filename = call_user_func( $unique_filename_callback, $dir, $name, $ext );
+ } else {
+ $number = '';
+
+ // change '.ext' to lower case
+ if ( $ext && strtolower($ext) != $ext ) {
+ $ext2 = strtolower($ext);
+ $filename2 = preg_replace( '|' . preg_quote($ext) . '$|', $ext2, $filename );
+
+ // check for both lower and upper case extension or image sub-sizes may be overwritten
+ while ( file_exists($dir . "/$filename") || file_exists($dir . "/$filename2") ) {
+ $new_number = $number + 1;
+ $filename = str_replace( "$number$ext", "$new_number$ext", $filename );
+ $filename2 = str_replace( "$number$ext2", "$new_number$ext2", $filename2 );
+ $number = $new_number;
+ }
+ return $filename2;
+ }
+
+ while ( file_exists( $dir . "/$filename" ) ) {
+ if ( '' == "$number$ext" )
+ $filename = $filename . ++$number . $ext;
+ else
+ $filename = str_replace( "$number$ext", ++$number . $ext, $filename );
+ }
+ }
+
+ return $filename;
+}
+
+/**
+ * Create a file in the upload folder with given content.
+ *
+ * If there is an error, then the key 'error' will exist with the error message.
+ * If success, then the key 'file' will have the unique file path, the 'url' key
+ * will have the link to the new file. and the 'error' key will be set to false.
+ *
+ * This function will not move an uploaded file to the upload folder. It will
+ * create a new file with the content in $bits parameter. If you move the upload
+ * file, read the content of the uploaded file, and then you can give the
+ * filename and content to this function, which will add it to the upload
+ * folder.
+ *
+ * The permissions will be set on the new file automatically by this function.
+ *
+ * @since 2.0.0
+ *
+ * @param string $name
+ * @param null $deprecated Never used. Set to null.
+ * @param mixed $bits File content
+ * @param string $time Optional. Time formatted in 'yyyy/mm'.
+ * @return array
+ */
+function wp_upload_bits( $name, $deprecated, $bits, $time = null ) {
+ if ( !empty( $deprecated ) )
+ _deprecated_argument( __FUNCTION__, '2.0' );
+
+ if ( empty( $name ) )
+ return array( 'error' => __( 'Empty filename' ) );
+
+ $wp_filetype = wp_check_filetype( $name );
+ if ( ! $wp_filetype['ext'] && ! current_user_can( 'unfiltered_upload' ) )
+ return array( 'error' => __( 'Invalid file type' ) );
+
+ $upload = wp_upload_dir( $time );
+
+ if ( $upload['error'] !== false )
+ return $upload;
+
+ $upload_bits_error = apply_filters( 'wp_upload_bits', array( 'name' => $name, 'bits' => $bits, 'time' => $time ) );
+ if ( !is_array( $upload_bits_error ) ) {
+ $upload[ 'error' ] = $upload_bits_error;
+ return $upload;
+ }
+
+ $filename = wp_unique_filename( $upload['path'], $name );
+
+ $new_file = $upload['path'] . "/$filename";
+ if ( ! wp_mkdir_p( dirname( $new_file ) ) ) {
+ if ( 0 === strpos( $upload['basedir'], ABSPATH ) )
+ $error_path = str_replace( ABSPATH, '', $upload['basedir'] ) . $upload['subdir'];
+ else
+ $error_path = basename( $upload['basedir'] ) . $upload['subdir'];
+
+ $message = sprintf( __( 'Unable to create directory %s. Is its parent directory writable by the server?' ), $error_path );
+ 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 );
+ clearstatcache();
+
+ // Set correct file permissions
+ $stat = @ stat( dirname( $new_file ) );
+ $perms = $stat['mode'] & 0007777;
+ $perms = $perms & 0000666;
+ @ chmod( $new_file, $perms );
+ clearstatcache();
+
+ // Compute the URL
+ $url = $upload['url'] . "/$filename";
+
+ return array( 'file' => $new_file, 'url' => $url, 'error' => false );
+}
+
+/**
+ * Retrieve the file type based on the extension name.
+ *
+ * @package WordPress
+ * @since 2.5.0
+ * @uses apply_filters() Calls 'ext2type' hook on default supported types.
+ *
+ * @param string $ext The extension to search.
+ * @return string|null The file type, example: audio, video, document, spreadsheet, etc. Null if not found.
+ */
+function wp_ext2type( $ext ) {
+ $ext2type = apply_filters( 'ext2type', array(
+ 'audio' => array( 'aac', 'ac3', 'aif', 'aiff', 'm3a', 'm4a', 'm4b', 'mka', 'mp1', 'mp2', 'mp3', 'ogg', 'oga', 'ram', 'wav', 'wma' ),
+ 'video' => array( 'asf', 'avi', 'divx', 'dv', 'flv', 'm4v', 'mkv', 'mov', 'mp4', 'mpeg', 'mpg', 'mpv', 'ogm', 'ogv', 'qt', 'rm', 'vob', 'wmv' ),
+ 'document' => array( 'doc', 'docx', 'docm', 'dotm', 'odt', 'pages', 'pdf', 'rtf', 'wp', 'wpd' ),
+ 'spreadsheet' => array( 'numbers', 'ods', 'xls', 'xlsx', 'xlsm', 'xlsb' ),
+ 'interactive' => array( 'swf', 'key', 'ppt', 'pptx', 'pptm', 'pps', 'ppsx', 'ppsm', 'sldx', 'sldm', 'odp' ),
+ 'text' => array( 'asc', 'csv', 'tsv', 'txt' ),
+ 'archive' => array( 'bz2', 'cab', 'dmg', 'gz', 'rar', 'sea', 'sit', 'sqx', 'tar', 'tgz', 'zip', '7z' ),
+ 'code' => array( 'css', 'htm', 'html', 'php', 'js' ),
+ ));
+ foreach ( $ext2type as $type => $exts )
+ if ( in_array( $ext, $exts ) )
+ return $type;
+}
+
+/**
+ * Retrieve the file type from the file name.
+ *
+ * You can optionally define the mime array, if needed.
+ *
+ * @since 2.0.4
+ *
+ * @param string $filename File name or path.
+ * @param array $mimes Optional. Key is the file extension with value as the mime type.
+ * @return array Values with extension first and mime type.
+ */
+function wp_check_filetype( $filename, $mimes = null ) {
+ if ( empty($mimes) )
+ $mimes = get_allowed_mime_types();
+ $type = false;
+ $ext = false;
+
+ foreach ( $mimes as $ext_preg => $mime_match ) {
+ $ext_preg = '!\.(' . $ext_preg . ')$!i';
+ if ( preg_match( $ext_preg, $filename, $ext_matches ) ) {
+ $type = $mime_match;
+ $ext = $ext_matches[1];
+ break;
+ }
+ }
+
+ return compact( 'ext', 'type' );
+}
+
+/**
+ * Attempt to determine the real file type of a file.
+ * If unable to, the file name extension will be used to determine type.
+ *
+ * If it's determined that the extension does not match the file's real type,
+ * then the "proper_filename" value will be set with a proper filename and extension.
+ *
+ * Currently this function only supports validating images known to getimagesize().
+ *
+ * @since 3.0.0
+ *
+ * @param string $file Full path to the image.
+ * @param string $filename The filename of the image (may differ from $file due to $file being in a tmp directory)
+ * @param array $mimes Optional. Key is the file extension with value as the mime type.
+ * @return array Values for the extension, MIME, and either a corrected filename or false if original $filename is valid
+ */
+function wp_check_filetype_and_ext( $file, $filename, $mimes = null ) {
+
+ $proper_filename = false;
+
+ // Do basic extension validation and MIME mapping
+ $wp_filetype = wp_check_filetype( $filename, $mimes );
+ extract( $wp_filetype );
+
+ // We can't do any further validation without a file to work with
+ if ( ! file_exists( $file ) )
+ return compact( 'ext', 'type', 'proper_filename' );
+
+ // We're able to validate images using GD
+ if ( $type && 0 === strpos( $type, 'image/' ) && function_exists('getimagesize') ) {
+
+ // Attempt to figure out what type of image it actually is
+ $imgstats = @getimagesize( $file );
+
+ // If getimagesize() knows what kind of image it really is and if the real MIME doesn't match the claimed MIME
+ if ( !empty($imgstats['mime']) && $imgstats['mime'] != $type ) {
+ // This is a simplified array of MIMEs that getimagesize() can detect and their extensions
+ // You shouldn't need to use this filter, but it's here just in case
+ $mime_to_ext = apply_filters( 'getimagesize_mimes_to_exts', array(
+ 'image/jpeg' => 'jpg',
+ 'image/png' => 'png',
+ 'image/gif' => 'gif',
+ 'image/bmp' => 'bmp',
+ 'image/tiff' => 'tif',
+ ) );
+
+ // Replace whatever is after the last period in the filename with the correct extension
+ if ( ! empty( $mime_to_ext[ $imgstats['mime'] ] ) ) {
+ $filename_parts = explode( '.', $filename );
+ array_pop( $filename_parts );
+ $filename_parts[] = $mime_to_ext[ $imgstats['mime'] ];
+ $new_filename = implode( '.', $filename_parts );
+
+ if ( $new_filename != $filename )
+ $proper_filename = $new_filename; // Mark that it changed
+
+ // Redefine the extension / MIME
+ $wp_filetype = wp_check_filetype( $new_filename, $mimes );
+ extract( $wp_filetype );
+ }
+ }
+ }
+
+ // Let plugins try and validate other types of files
+ // Should return an array in the style of array( 'ext' => $ext, 'type' => $type, 'proper_filename' => $proper_filename )
+ return apply_filters( 'wp_check_filetype_and_ext', compact( 'ext', 'type', 'proper_filename' ), $file, $filename, $mimes );
+}
+
+/**
+ * Retrieve list of mime types and file extensions.
+ *
+ * @since 3.5.0
+ *
+ * @uses apply_filters() Calls 'mime_types' on returned array. This filter should
+ * be used to add types, not remove them. To remove types use the upload_mimes filter.
+ *
+ * @return array Array of mime types keyed by the file extension regex corresponding to those types.
+ */
+function wp_get_mime_types() {
+ // Accepted MIME types are set here as PCRE unless provided.
+ return apply_filters( 'mime_types', array(
+ // Image formats
+ 'jpg|jpeg|jpe' => 'image/jpeg',
+ 'gif' => 'image/gif',
+ 'png' => 'image/png',
+ 'bmp' => 'image/bmp',
+ 'tif|tiff' => 'image/tiff',
+ 'ico' => 'image/x-icon',
+ // Video formats
+ 'asf|asx' => 'video/x-ms-asf',
+ 'wmv' => 'video/x-ms-wmv',
+ 'wmx' => 'video/x-ms-wmx',
+ 'wm' => 'video/x-ms-wm',
+ 'avi' => 'video/avi',
+ 'divx' => 'video/divx',
+ 'flv' => 'video/x-flv',
+ 'mov|qt' => 'video/quicktime',
+ 'mpeg|mpg|mpe' => 'video/mpeg',
+ 'mp4|m4v' => 'video/mp4',
+ 'ogv' => 'video/ogg',
+ 'webm' => 'video/webm',
+ 'mkv' => 'video/x-matroska',
+ // Text formats
+ 'txt|asc|c|cc|h' => 'text/plain',
+ 'csv' => 'text/csv',
+ 'tsv' => 'text/tab-separated-values',
+ 'ics' => 'text/calendar',
+ 'rtx' => 'text/richtext',
+ 'css' => 'text/css',
+ 'htm|html' => 'text/html',
+ // Audio formats
+ 'mp3|m4a|m4b' => 'audio/mpeg',
+ 'ra|ram' => 'audio/x-realaudio',
+ 'wav' => 'audio/wav',
+ 'ogg|oga' => 'audio/ogg',
+ 'mid|midi' => 'audio/midi',
+ 'wma' => 'audio/x-ms-wma',
+ 'wax' => 'audio/x-ms-wax',
+ 'mka' => 'audio/x-matroska',
+ // Misc application formats
+ 'rtf' => 'application/rtf',
+ 'js' => 'application/javascript',
+ 'pdf' => 'application/pdf',
+ 'swf' => 'application/x-shockwave-flash',
+ 'class' => 'application/java',
+ 'tar' => 'application/x-tar',
+ 'zip' => 'application/zip',
+ 'gz|gzip' => 'application/x-gzip',
+ 'rar' => 'application/rar',
+ '7z' => 'application/x-7z-compressed',
+ 'exe' => 'application/x-msdownload',
+ // MS Office formats
+ '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',
+ 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
+ 'docm' => 'application/vnd.ms-word.document.macroEnabled.12',
+ 'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
+ 'dotm' => 'application/vnd.ms-word.template.macroEnabled.12',
+ 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
+ 'xlsm' => 'application/vnd.ms-excel.sheet.macroEnabled.12',
+ 'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12',
+ 'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template',
+ 'xltm' => 'application/vnd.ms-excel.template.macroEnabled.12',
+ 'xlam' => 'application/vnd.ms-excel.addin.macroEnabled.12',
+ 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
+ 'pptm' => 'application/vnd.ms-powerpoint.presentation.macroEnabled.12',
+ 'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow',
+ 'ppsm' => 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12',
+ 'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template',
+ 'potm' => 'application/vnd.ms-powerpoint.template.macroEnabled.12',
+ 'ppam' => 'application/vnd.ms-powerpoint.addin.macroEnabled.12',
+ 'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide',
+ 'sldm' => 'application/vnd.ms-powerpoint.slide.macroEnabled.12',
+ 'onetoc|onetoc2|onetmp|onepkg' => 'application/onenote',
+ // 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',
+ // WordPerfect formats
+ 'wp|wpd' => 'application/wordperfect',
+ // iWork formats
+ 'key' => 'application/vnd.apple.keynote',
+ 'numbers' => 'application/vnd.apple.numbers',
+ 'pages' => 'application/vnd.apple.pages',
+ ) );
+}
+/**
+ * Retrieve list of allowed mime types and file extensions.
+ *
+ * @since 2.8.6
+ *
+ * @uses apply_filters() Calls 'upload_mimes' on returned array
+ * @uses wp_get_upload_mime_types() to fetch the list of mime types
+ *
+ * @return array Array of mime types keyed by the file extension regex corresponding to those types.
+ */
+function get_allowed_mime_types() {
+ return apply_filters( 'upload_mimes', wp_get_mime_types() );
+}
+
+/**
+ * Display "Are You Sure" message to confirm the action being taken.
+ *
+ * If the action has the nonce explain message, then it will be displayed along
+ * with the "Are you sure?" message.
+ *
+ * @package WordPress
+ * @subpackage Security
+ * @since 2.0.4
+ *
+ * @param string $action The nonce action.
+ */
+function wp_nonce_ays( $action ) {
+ $title = __( 'WordPress Failure Notice' );
+ if ( 'log-out' == $action ) {
+ $html = sprintf( __( 'You are attempting to log out of %s' ), get_bloginfo( 'name' ) ) . '</p><p>';
+ $html .= sprintf( __( "Do you really want to <a href='%s'>log out</a>?"), wp_logout_url() );
+ } else {
+ $html = __( 'Are you sure you want to do this?' );
+ if ( wp_get_referer() )
+ $html .= "</p><p><a href='" . esc_url( remove_query_arg( 'updated', wp_get_referer() ) ) . "'>" . __( 'Please try again.' ) . "</a>";
+ }
+
+ wp_die( $html, $title, array('response' => 403) );
+}
+
+/**
+ * Kill WordPress execution and display HTML message with error message.
+ *
+ * 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 silently.
+ *
+ * @since 2.0.4
+ *
+ * @param string $message Error message.
+ * @param string $title Error title.
+ * @param string|array $args Optional arguments to control behavior.
+ */
+function wp_die( $message = '', $title = '', $args = array() ) {
+ if ( defined( 'DOING_AJAX' ) && DOING_AJAX )
+ $function = apply_filters( 'wp_die_ajax_handler', '_ajax_wp_die_handler' );
+ elseif ( defined( 'XMLRPC_REQUEST' ) && XMLRPC_REQUEST )
+ $function = apply_filters( 'wp_die_xmlrpc_handler', '_xmlrpc_wp_die_handler' );
+ else
+ $function = apply_filters( 'wp_die_handler', '_default_wp_die_handler' );
+
+ call_user_func( $function, $message, $title, $args );
+}
+
+/**
+ * Kill WordPress execution and display HTML message with error message.
+ *
+ * This is the default handler for wp_die if you want a custom one for your
+ * site then you can overload using the wp_die_handler filter in wp_die
+ *
+ * @since 3.0.0
+ * @access private
+ *
+ * @param string $message Error message.
+ * @param string $title Error title.
+ * @param string|array $args Optional arguments to control behavior.
+ */
+function _default_wp_die_handler( $message, $title = '', $args = array() ) {
+ $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 = "<p>{$errors[0]}</p>";
+ break;
+ default :
+ $message = "<ul>\n\t\t<li>" . join( "</li>\n\t\t<li>", $errors ) . "</li>\n\t</ul>";
+ break;
+ endswitch;
+ } elseif ( is_string( $message ) ) {
+ $message = "<p>$message</p>";
+ }
+
+ if ( isset( $r['back_link'] ) && $r['back_link'] ) {
+ $back_text = $have_gettext? __('« Back') : '« Back';
+ $message .= "\n<p><a href='javascript:history.back()'>$back_text</a></p>";
+ }
+
+ if ( ! 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']) && 'rtl' == $r['text_direction'] )
+ $text_direction = 'rtl';
+ elseif ( function_exists( 'is_rtl' ) && is_rtl() )
+ $text_direction = 'rtl';
+?>
+<!DOCTYPE html>
+<!-- Ticket #11289, IE bug fix: always pad the error page with enough characters such that it is greater than 512 bytes, even after gzip compression abcdefghijklmnopqrstuvwxyz1234567890aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz11223344556677889900abacbcbdcdcededfefegfgfhghgihihjijikjkjlklkmlmlnmnmononpopoqpqprqrqsrsrtstsubcbcdcdedefefgfabcadefbghicjkldmnoepqrfstugvwxhyz1i234j567k890laabmbccnddeoeffpgghqhiirjjksklltmmnunoovppqwqrrxsstytuuzvvw0wxx1yyz2z113223434455666777889890091abc2def3ghi4jkl5mno6pqr7stu8vwx9yz11aab2bcc3dd4ee5ff6gg7hh8ii9j0jk1kl2lmm3nnoo4p5pq6qrr7ss8tt9uuvv0wwx1x2yyzz13aba4cbcb5dcdc6dedfef8egf9gfh0ghg1ihi2hji3jik4jkj5lkl6kml7mln8mnm9ono
+-->
+<html xmlns="http://www.w3.org/1999/xhtml" <?php if ( function_exists( 'language_attributes' ) && function_exists( 'is_rtl' ) ) language_attributes(); else echo "dir='$text_direction'"; ?>>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <title><?php echo $title ?></title>
+ <style type="text/css">
+ html {
+ background: #f9f9f9;
+ }
+ body {
+ background: #fff;
+ color: #333;
+ font-family: sans-serif;
+ margin: 2em auto;
+ padding: 1em 2em;
+ -webkit-border-radius: 3px;
+ border-radius: 3px;
+ border: 1px solid #dfdfdf;
+ max-width: 700px;
+ }
+ h1 {
+ border-bottom: 1px solid #dadada;
+ clear: both;
+ color: #666;
+ font: 24px Georgia, "Times New Roman", Times, serif;
+ margin: 30px 0 0 0;
+ padding: 0;
+ padding-bottom: 7px;
+ }
+ #error-page {
+ margin-top: 50px;
+ }
+ #error-page p {
+ font-size: 14px;
+ line-height: 1.5;
+ margin: 25px 0 20px;
+ }
+ #error-page code {
+ font-family: Consolas, Monaco, monospace;
+ }
+ ul li {
+ margin-bottom: 10px;
+ font-size: 14px ;
+ }
+ a {
+ color: #21759B;
+ text-decoration: none;
+ }
+ a:hover {
+ color: #D54E21;
+ }
+ .button {
+ display: inline-block;
+ text-decoration: none;
+ font-size: 14px;
+ line-height: 23px;
+ height: 24px;
+ margin: 0;
+ padding: 0 10px 1px;
+ cursor: pointer;
+ border-width: 1px;
+ border-style: solid;
+ -webkit-border-radius: 3px;
+ border-radius: 3px;
+ white-space: nowrap;
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+ background: #f3f3f3;
+ background-image: -webkit-gradient(linear, left top, left bottom, from(#fefefe), to(#f4f4f4));
+ background-image: -webkit-linear-gradient(top, #fefefe, #f4f4f4);
+ background-image: -moz-linear-gradient(top, #fefefe, #f4f4f4);
+ background-image: -o-linear-gradient(top, #fefefe, #f4f4f4);
+ background-image: linear-gradient(to bottom, #fefefe, #f4f4f4);
+ border-color: #bbb;
+ color: #333;
+ text-shadow: 0 1px 0 #fff;
+ }
+
+ .button.button-large {
+ height: 29px;
+ line-height: 28px;
+ padding: 0 12px;
+ }
+
+ .button:hover,
+ .button:focus {
+ background: #f3f3f3;
+ background-image: -webkit-gradient(linear, left top, left bottom, from(#fff), to(#f3f3f3));
+ background-image: -webkit-linear-gradient(top, #fff, #f3f3f3);
+ background-image: -moz-linear-gradient(top, #fff, #f3f3f3);
+ background-image: -ms-linear-gradient(top, #fff, #f3f3f3);
+ background-image: -o-linear-gradient(top, #fff, #f3f3f3);
+ background-image: linear-gradient(to bottom, #fff, #f3f3f3);
+ border-color: #999;
+ color: #222;
+ }
+
+ .button:focus {
+ -webkit-box-shadow: 1px 1px 1px rgba(0,0,0,.2);
+ box-shadow: 1px 1px 1px rgba(0,0,0,.2);
+ }
+
+ .button:active {
+ outline: none;
+ background: #eee;
+ background-image: -webkit-gradient(linear, left top, left bottom, from(#f4f4f4), to(#fefefe));
+ background-image: -webkit-linear-gradient(top, #f4f4f4, #fefefe);
+ background-image: -moz-linear-gradient(top, #f4f4f4, #fefefe);
+ background-image: -ms-linear-gradient(top, #f4f4f4, #fefefe);
+ background-image: -o-linear-gradient(top, #f4f4f4, #fefefe);
+ background-image: linear-gradient(to bottom, #f4f4f4, #fefefe);
+ border-color: #999;
+ color: #333;
+ text-shadow: 0 -1px 0 #fff;
+ -webkit-box-shadow: inset 0 2px 5px -3px rgba( 0, 0, 0, 0.5 );
+ box-shadow: inset 0 2px 5px -3px rgba( 0, 0, 0, 0.5 );
+ }
+
+ <?php if ( 'rtl' == $text_direction ) : ?>
+ body { font-family: Tahoma, Arial; }
+ <?php endif; ?>
+ </style>
+</head>
+<body id="error-page">
+<?php endif; // ! did_action( 'admin_head' ) ?>
+ <?php echo $message; ?>
+</body>
+</html>
+<?php
+ die();
+}
+
+/**
+ * Kill WordPress execution and display XML message with error message.
+ *
+ * This is the handler for wp_die when processing XMLRPC requests.
+ *
+ * @since 3.2.0
+ * @access private
+ *
+ * @param string $message Error message.
+ * @param string $title Error title.
+ * @param string|array $args Optional arguments to control behavior.
+ */
+function _xmlrpc_wp_die_handler( $message, $title = '', $args = array() ) {
+ global $wp_xmlrpc_server;
+ $defaults = array( 'response' => 500 );
+
+ $r = wp_parse_args($args, $defaults);
+
+ if ( $wp_xmlrpc_server ) {
+ $error = new IXR_Error( $r['response'] , $message);
+ $wp_xmlrpc_server->output( $error->getXml() );