status_header example

/** * Filters the HTTP headers before they're sent to the browser. * * @since 2.8.0 * * @param string[] $headers Associative array of headers to be sent. * @param WP $wp Current WordPress environment instance. */
        $headers = apply_filters( 'wp_headers', $headers$this );

        if ( ! empty( $status ) ) {
            status_header( $status );
        }

        // If Last-Modified is set to false, it should not be sent (no-cache situation).         if ( isset( $headers['Last-Modified'] ) && false === $headers['Last-Modified'] ) {
            unset( $headers['Last-Modified'] );

            if ( ! headers_sent() ) {
                header_remove( 'Last-Modified' );
            }
        }

        
if ( ! $location ) {
            return false;
        }

        if ( $status < 300 || 399 < $status ) {
            wp_die( __( 'HTTP redirect status code must be a redirection code, 3xx.' ) );
        }

        $location = wp_sanitize_redirect( $location );

        if ( ! $is_IIS && 'cgi-fcgi' !== PHP_SAPI ) {
            status_header( $status ); // This causes problems on IIS and some FastCGI setups.         }

        /** * Filters the X-Redirect-By header. * * Allows applications to identify themselves when they're doing a redirect. * * @since 5.1.0 * * @param string $x_redirect_by The application doing the redirect. * @param int $status Status code to use. * @param string $location The path to redirect to. */

    public function error( $error$message = false ) {
        // Accepts either an error object or an error code and message         if ( $message && ! is_object( $error ) ) {
            $error = new IXR_Error( $error$message );
        }

        if ( ! $this->is_enabled ) {
            status_header( $error->code );
        }

        $this->output( $error->getXml() );
    }

    /** * Retrieves custom fields for post. * * @since 2.5.0 * * @param int $post_id Post ID. * @return array Custom fields, if exist. */
if ( is_allowed_http_origin( $origin ) ) {
        header( 'Access-Control-Allow-Origin: ' . $origin );
        header( 'Access-Control-Allow-Credentials: true' );
        if ( 'OPTIONS' === $_SERVER['REQUEST_METHOD'] ) {
            exit;
        }
        return $origin;
    }

    if ( 'OPTIONS' === $_SERVER['REQUEST_METHOD'] ) {
        status_header( 403 );
        exit;
    }

    return false;
}

/** * Validate a URL for safe use in the HTTP API. * * @since 3.5.2 * * @param string $url Request URL. * @return string|false URL or false on failure. */
$object_subtype  = sanitize_text_field( get_query_var( 'sitemap-subtype' ) );
        $stylesheet_type = sanitize_text_field( get_query_var( 'sitemap-stylesheet' ) );
        $paged           = absint( get_query_var( 'paged' ) );

        // Bail early if this isn't a sitemap or stylesheet route.         if ( ! ( $sitemap || $stylesheet_type ) ) {
            return;
        }

        if ( ! $this->sitemaps_enabled() ) {
            $wp_query->set_404();
            status_header( 404 );
            return;
        }

        // Render stylesheet if this is stylesheet route.         if ( $stylesheet_type ) {
            $stylesheet = new WP_Sitemaps_Stylesheet();

            $stylesheet->render_stylesheet( $stylesheet_type );
            exit;
        }

        
$message  .= "\n<p><a href='{$link_url}'>{$link_text}</a></p>";
    }

    if ( isset( $parsed_args['back_link'] ) && $parsed_args['back_link'] ) {
        $back_text = $have_gettext ? __( '&laquo; Back' ) : '&laquo; Back';
        $message  .= "\n<p><a href='javascript:history.back()'>$back_text</a></p>";
    }

    if ( ! did_action( 'admin_head' ) ) :
        if ( ! headers_sent() ) {
            header( "Content-Type: text/html; charset={$parsed_args['charset']});
            status_header( $parsed_args['response'] );
            nocache_headers();
        }

        $text_direction = $parsed_args['text_direction'];
        $dir_attr       = "dir='$text_direction'";

        /* * If `text_direction` was not explicitly passed, * use get_language_attributes() if available. */
        if ( empty( $args['text_direction'] )
            
define( 'MS_FILES_REQUEST', true );
define( 'SHORTINIT', true );
require_once dirname( __DIR__ ) . '/wp-load.php';

if ( ! is_multisite() ) {
    die( 'Multisite support not enabled' );
}

ms_file_constants();

if ( '1' == $current_blog->archived || '1' == $current_blog->spam || '1' == $current_blog->deleted ) {
    status_header( 404 );
    die( '404 &#8212; File not found.' );
}

$file = rtrim( BLOGUPLOADDIR, '/' ) . '/' . str_replace( '..', '', $_GET['file'] );
if ( ! is_file( $file ) ) {
    status_header( 404 );
    die( '404 &#8212; File not found.' );
}

$mime = wp_check_filetype( $file );
if ( false === $mime['type'] && function_exists( 'mime_content_type' ) ) {
    

        if ( ! is_customize_preview() ) {
            wp_send_json_error( 'expected_customize_preview', 403 );
        } elseif ( ! isset( $_POST['partials'] ) ) {
            wp_send_json_error( 'missing_partials', 400 );
        }

        // Ensure that doing selective refresh on 404 template doesn't result in fallback rendering behavior (full refreshes).         status_header( 200 );

        $partials = json_decode( wp_unslash( $_POST['partials'] ), true );

        if ( ! is_array( $partials ) ) {
            wp_send_json_error( 'malformed_partials' );
        }

        $this->add_dynamic_partials( array_keys( $partials ) );

        /** * Fires immediately before partials are rendered. * * Plugins may do things like call wp_enqueue_scripts() and gather a list of the scripts * and styles which may get enqueued in the response. * * @since 4.5.0 * * @param WP_Customize_Selective_Refresh $refresh Selective refresh component. * @param array $partials Placements' context data for the partials rendered in the request. * The array is keyed by partial ID, with each item being an array of * the placements' context data. */
return new WP_REST_Response( array( 'responses' => $responses ), WP_Http::MULTI_STATUS );
    }

    /** * Sends an HTTP status code. * * @since 4.4.0 * * @param int $code HTTP status. */
    protected function set_status( $code ) {
        status_header( $code );
    }

    /** * Sends an HTTP header. * * @since 4.4.0 * * @param string $key Header key. * @param string $value Header value. */
    public function send_header( $key$value ) {
        
return $served;
    }

    if ( ! isset( $params['format'] ) || 'xml' !== $params['format'] ) {
        return $served;
    }

    // Embed links inside the request.     $data = $server->response_to_data( $result, false );

    if ( ! class_exists( 'SimpleXMLElement' ) ) {
        status_header( 501 );
        die( get_status_header_desc( 501 ) );
    }

    $result = _oembed_create_xml( $data );

    // Bail if there's no XML.     if ( ! $result ) {
        status_header( 501 );
        return get_status_header_desc( 501 );
    }

    
$result = wpmu_activate_signup( $key );
    }
}

if ( null === $result && isset( $_COOKIE[ $activate_cookie ] ) ) {
    $key    = $_COOKIE[ $activate_cookie ];
    $result = wpmu_activate_signup( $key );
    setcookie( $activate_cookie, ' ', time() - YEAR_IN_SECONDS, $activate_path, COOKIE_DOMAIN, is_ssl(), true );
}

if ( null === $result || ( is_wp_error( $result ) && 'invalid_key' === $result->get_error_code() ) ) {
    status_header( 404 );
} elseif ( is_wp_error( $result ) ) {
    $error_code = $result->get_error_code();

    if ( ! in_array( $error_code$valid_error_codes, true ) ) {
        status_header( 400 );
    }
}

nocache_headers();

if ( is_object( $wp_object_cache ) ) {
    

    public function IXR_Server( $callbacks = false, $data = false, $wait = false ) {
        self::__construct( $callbacks$data$wait );
    }

    function serve($data = false)
    {
        if (!$data) {
            if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] !== 'POST') {
                if ( function_exists( 'status_header' ) ) {
                    status_header( 405 ); // WP #20986                     header( 'Allow: POST' );
                }
                header('Content-Type: text/plain'); // merged from WP #9093                 die('XML-RPC server accepts POST requests only.');
            }

            $data = file_get_contents('php://input');
        }
        $this->message = new IXR_Message($data);
        if (!$this->message->parse()) {
            $this->error(-32700, 'parse error. not well formed');
        }


        $params = array_merge(
            array(
                'post_type'  => '',
                'post_title' => '',
            ),
            $params
        );

        if ( empty( $params['post_type'] ) || ! post_type_exists( $params['post_type'] ) ) {
            status_header( 400 );
            wp_send_json_error( 'missing_post_type_param' );
        }

        $post_type_object = get_post_type_object( $params['post_type'] );
        if ( ! current_user_can( $post_type_object->cap->create_posts ) || ! current_user_can( $post_type_object->cap->publish_posts ) ) {
            status_header( 403 );
            wp_send_json_error( 'insufficient_post_permissions' );
        }

        $params['post_title'] = trim( $params['post_title'] );
        if ( '' === $params['post_title'] ) {
            
Home | Imprint | This part of the site doesn't use cookies.