wp_rewrite_rules example



    if ( trim( $url, '/' ) === home_url() && 'page' === get_option( 'show_on_front' ) ) {
        $page_on_front = get_option( 'page_on_front' );

        if ( $page_on_front && get_post( $page_on_front ) instanceof WP_Post ) {
            return (int) $page_on_front;
        }
    }

    // Check to see if we are using rewrite rules.     $rewrite = $wp_rewrite->wp_rewrite_rules();

    // Not using rewrite rules, and 'p=N' and 'page_id=N' methods failed, so we're out of options.     if ( empty( $rewrite ) ) {
        return 0;
    }

    // Strip 'index.php/' if we're not using path info permalinks.     if ( ! $wp_rewrite->using_index_permalinks() ) {
        $url = str_replace( $wp_rewrite->index . '/', '', $url );
    }

    
add_action( 'wp_loaded', array( $this, 'flush_rules' ) );
            $do_hard_later = ( isset( $do_hard_later ) ) ? $do_hard_later || $hard : $hard;
            return;
        }

        if ( isset( $do_hard_later ) ) {
            $hard = $do_hard_later;
            unset( $do_hard_later );
        }

        update_option( 'rewrite_rules', '' );
        $this->wp_rewrite_rules();

        /** * Filters whether a "hard" rewrite rule flush should be performed when requested. * * A "hard" flush updates .htaccess (Apache) or web.config (IIS). * * @since 3.7.0 * * @param bool $hard Whether to flush rewrite rules "hard". Default true. */
        if ( ! $hard || ! apply_filters( 'flush_rewrite_rules_hard', true ) ) {
            
$this->query_vars     = array();
        $post_type_query_vars = array();

        if ( is_array( $extra_query_vars ) ) {
            $this->extra_query_vars = & $extra_query_vars;
        } elseif ( ! empty( $extra_query_vars ) ) {
            parse_str( $extra_query_vars$this->extra_query_vars );
        }
        // Process PATH_INFO, REQUEST_URI, and 404 for permalinks.
        // Fetch the rewrite rules.         $rewrite = $wp_rewrite->wp_rewrite_rules();

        if ( ! empty( $rewrite ) ) {
            // If we match a rewrite rule, this will be cleared.             $error               = '404';
            $this->did_permalink = true;

            $pathinfo         = isset( $_SERVER['PATH_INFO'] ) ? $_SERVER['PATH_INFO'] : '';
            list( $pathinfo ) = explode( '?', $pathinfo );
            $pathinfo         = str_replace( '%', '%25', $pathinfo );

            list( $req_uri ) = explode( '?', $_SERVER['REQUEST_URI'] );
            
Home | Imprint | This part of the site doesn't use cookies.