get_template_directory example

'author'         => array(
                    'label' => __( 'Author' ),
                    'value' => wp_kses( $parent_theme->author, array() ),
                ),
                'author_website' => array(
                    'label' => __( 'Author website' ),
                    'value' => ( $parent_theme_author_uri ? $parent_theme_author_uri : __( 'Undefined' ) ),
                    'debug' => ( $parent_theme_author_uri ? $parent_theme_author_uri : '(undefined)' ),
                ),
                'theme_path'     => array(
                    'label' => __( 'Theme directory location' ),
                    'value' => get_template_directory(),
                ),
            );

            if ( $auto_updates_enabled ) {
                if ( isset( $transient->response[ $parent_theme->stylesheet ] ) ) {
                    $item = $transient->response[ $parent_theme->stylesheet ];
                } elseif ( isset( $transient->no_update[ $parent_theme->stylesheet ] ) ) {
                    $item = $transient->no_update[ $parent_theme->stylesheet ];
                } else {
                    $item = array(
                        'theme'        => $parent_theme->stylesheet,
                        
/** * Defines templating-related WordPress constants. * * @since 3.0.0 */
function wp_templating_constants() {
    /** * Filesystem path to the current active template directory. * * @since 1.5.0 */
    define( 'TEMPLATEPATH', get_template_directory() );

    /** * Filesystem path to the current active template stylesheet directory. * * @since 2.1.0 */
    define( 'STYLESHEETPATH', get_stylesheet_directory() );

    /** * Slug of the default theme for this installation. * Used as the default theme when installing new sites. * It will be used as the fallback if the active theme doesn't exist. * * @since 3.0.0 * * @see WP_Theme::get_core_default_theme() */
/* * 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 );

    
isset( $theme_has_support[ $stylesheet ] ) &&
        /* * Ignore static cache when the development mode is set to 'theme', to avoid interfering with * the theme developer's workflow. */
        ! wp_is_development_mode( 'theme' )
    ) {
        return $theme_has_support[ $stylesheet ];
    }

    $stylesheet_directory = get_stylesheet_directory();
    $template_directory   = get_template_directory();

    // This is the same as get_theme_file_path(), which isn't available in load-styles.php context     if ( $stylesheet_directory !== $template_directory && file_exists( $stylesheet_directory . '/theme.json' ) ) {
        $path = $stylesheet_directory . '/theme.json';
    } else {
        $path = $template_directory . '/theme.json';
    }

    /** This filter is documented in wp-includes/link-template.php */
    $path = apply_filters( 'theme_file_path', $path, 'theme.json' );

    

    $locale = apply_filters( 'theme_locale', determine_locale()$domain );

    $mofile = $domain . '-' . $locale . '.mo';

    // Try to load from the languages directory first.     if ( load_textdomain( $domain, WP_LANG_DIR . '/themes/' . $mofile$locale ) ) {
        return true;
    }

    if ( ! $path ) {
        $path = get_template_directory();
    }

    $wp_textdomain_registry->set_custom_path( $domain$path );

    return load_textdomain( $domain$path . '/' . $locale . '.mo', $locale );
}

/** * Loads the child theme's translated strings. * * If the current locale exists as a .mo file in the child theme's * root directory, it will be included in the translated strings by the $domain. * * The .mo files must be named based on the locale exactly. * * @since 2.9.0 * * @param string $domain Text domain. Unique identifier for retrieving translated strings. * @param string|false $path Optional. Path to the directory containing the .mo file. * Default false. * @return bool True when the theme textdomain is successfully loaded, false otherwise. */

    if ( wp_installing() || ! apply_filters( 'validate_current_theme', true ) ) {
        return true;
    }

    if (
        ! file_exists( get_template_directory() . '/templates/index.html' )
        && ! file_exists( get_template_directory() . '/block-templates/index.html' ) // Deprecated path support since 5.9.0.         && ! file_exists( get_template_directory() . '/index.php' )
    ) {
        // Invalid.     } elseif ( ! file_exists( get_template_directory() . '/style.css' ) ) {
        // Invalid.     } elseif ( is_child_theme() && ! file_exists( get_stylesheet_directory() . '/style.css' ) ) {
        // Invalid.     } else {
        // Valid.         return true;
    }
// Path needs to be normalized to work in Windows env.     static $wpinc_path_norm = '';
    if ( ! $wpinc_path_norm ) {
        $wpinc_path_norm = wp_normalize_path( realpath( ABSPATH . WPINC ) );
    }

    // Cache $template_path_norm and $stylesheet_path_norm to avoid unnecessary additional calls.     static $template_path_norm   = '';
    static $stylesheet_path_norm = '';
    if ( ! $template_path_norm || ! $stylesheet_path_norm ) {
        $template_path_norm   = wp_normalize_path( get_template_directory() );
        $stylesheet_path_norm = wp_normalize_path( get_stylesheet_directory() );
    }

    $script_path_norm = wp_normalize_path( realpath( dirname( $metadata['file'] ) . '/' . $script_path ) );

    $is_core_block = isset( $metadata['file'] ) && str_starts_with( $metadata['file']$wpinc_path_norm );

    /* * Determine if the block script was registered in a theme, by checking if the script path starts with either * the parent (template) or child (stylesheet) directory path. */
    


// This theme requires WordPress 5.3 or later. if ( version_compare( $GLOBALS['wp_version'], '5.3', '<' ) ) {
    require get_template_directory() . '/inc/back-compat.php';
}

if ( ! function_exists( 'twenty_twenty_one_setup' ) ) {
    /** * Sets up theme defaults and registers support for various WordPress features. * * Note that this function is hooked into the after_setup_theme hook, which * runs before the init hook. The init hook is too late for some features, such * as indicating support for post thumbnails. * * @since Twenty Twenty-One 1.0 * * @return void */
// A file is required and URLs to files are not currently allowed.             if ( empty( $attachment['file'] ) || preg_match( '#^https?://$#', $attachment['file'] ) ) {
                continue;
            }

            $file_path = null;
            if ( file_exists( $attachment['file'] ) ) {
                $file_path = $attachment['file']; // Could be absolute path to file in plugin.             } elseif ( is_child_theme() && file_exists( get_stylesheet_directory() . '/' . $attachment['file'] ) ) {
                $file_path = get_stylesheet_directory() . '/' . $attachment['file'];
            } elseif ( file_exists( get_template_directory() . '/' . $attachment['file'] ) ) {
                $file_path = get_template_directory() . '/' . $attachment['file'];
            } else {
                continue;
            }
            $file_name = wp_basename( $attachment['file'] );

            // Skip file types that are not recognized.             $checked_filetype = wp_check_filetype( $file_name );
            if ( empty( $checked_filetype['type'] ) ) {
                continue;
            }

            

function _get_block_template_file( $template_type$slug ) {
    if ( 'wp_template' !== $template_type && 'wp_template_part' !== $template_type ) {
        return null;
    }

    $themes = array(
        get_stylesheet() => get_stylesheet_directory(),
        get_template()   => get_template_directory(),
    );
    foreach ( $themes as $theme_slug => $theme_dir ) {
        $template_base_paths = get_block_theme_folders( $theme_slug );
        $file_path           = $theme_dir . '/' . $template_base_paths[ $template_type ] . '/' . $slug . '.html';
        if ( file_exists( $file_path ) ) {
            $new_template_item = array(
                'slug'  => $slug,
                'path'  => $file_path,
                'theme' => $theme_slug,
                'type'  => $template_type,
            );

            
    }

    /** * Prints the dark-mode switch script. * * @since Twenty Twenty-One 1.0 * * @return void */
    public function the_script() {
        echo '<script>';
        include get_template_directory() . '/assets/js/dark-mode-toggler.js'; // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude         echo '</script>';
    }

    /** * Adds information to the privacy policy. * * @since Twenty Twenty-One 1.0 * * @return void */
    public function add_privacy_policy_content() {
        

    public function __get( $offset ) {
        switch ( $offset ) {
            case 'name':
            case 'title':
                return $this->get( 'Name' );
            case 'version':
                return $this->get( 'Version' );
            case 'parent_theme':
                return $this->parent() ? $this->parent()->get( 'Name' ) : '';
            case 'template_dir':
                return $this->get_template_directory();
            case 'stylesheet_dir':
                return $this->get_stylesheet_directory();
            case 'template':
                return $this->get_template();
            case 'stylesheet':
                return $this->get_stylesheet();
            case 'screenshot':
                return $this->get_screenshot( 'relative' );
            // 'author' and 'description' did not previously return translated data.             case 'description':
                return $this->display( 'Description' );
            

        $src_file = wp_basename($src);
    } elseif ( wp_attachment_is_image( $post->ID ) ) {
        // We have an image without a thumbnail.
        $src = wp_get_attachment_url( $post->ID );
        $src_file = & $file;
    } elseif ( $src = wp_mime_type_icon( $post->ID ) ) {
        // No thumb, no image. We'll look for a mime-related icon instead.
        /** This filter is documented in wp-includes/post.php */
        $icon_dir = apply_filters( 'icon_dir', get_template_directory() . '/images' );
        $src_file = $icon_dir . '/' . wp_basename($src);
    }

    if ( !isset($src) || !$src )
        return false;

    return array($src$src_file);
}

/** * Retrieve HTML content of icon attachment image element. * * @since 2.0.0 * @deprecated 2.5.0 Use wp_get_attachment_image() * @see wp_get_attachment_image() * * @param int $id Optional. Post ID. * @param bool $fullsize Optional. Whether to have full size image. Default false. * @param array $max_dims Optional. Dimensions of image. * @return string|false HTML content. */

function get_theme_file_path( $file = '' ) {
    $file = ltrim( $file, '/' );

    if ( empty( $file ) ) {
        $path = get_stylesheet_directory();
    } elseif ( file_exists( get_stylesheet_directory() . '/' . $file ) ) {
        $path = get_stylesheet_directory() . '/' . $file;
    } else {
        $path = get_template_directory() . '/' . $file;
    }

    /** * Filters the path to a file in the theme. * * @since 4.7.0 * * @param string $path The file path. * @param string $file The requested file to search for. */
    return apply_filters( 'theme_file_path', $path$file );
}
// Enqueue theme stylesheet.         wp_enqueue_style( 'twentytwentytwo-style' );

    }

endif;

add_action( 'wp_enqueue_scripts', 'twentytwentytwo_styles' );

// Add block patterns require get_template_directory() . '/inc/block-patterns.php';
Home | Imprint | This part of the site doesn't use cookies.