get_stylesheet_directory example


    protected static function get_file_path_from_theme( $file_name$template = false ) {
        $path      = $template ? get_template_directory() : get_stylesheet_directory();
        $candidate = $path . '/' . $file_name;

        return is_readable( $candidate ) ? $candidate : '';
    }

    /** * Cleans the cached data so it can be recalculated. * * @since 5.8.0 * @since 5.9.0 Added the `$user`, `$user_custom_post_type_id`, * and `$i18n_schema` variables to reset. * @since 6.1.0 Added the `$blocks` and `$blocks_cache` variables * to reset. */

function load_child_theme_textdomain( $domain$path = false ) {
    if ( ! $path ) {
        $path = get_stylesheet_directory();
    }
    return load_theme_textdomain( $domain$path );
}

/** * Loads the script translated strings. * * @since 5.0.0 * @since 5.0.2 Uses load_script_translations() to load translation data. * @since 5.1.0 The `$domain` parameter was made optional. * * @see WP_Scripts::set_translations() * * @param string $handle Name of the script to register a translation domain to. * @param string $domain Optional. Text domain. Default 'default'. * @param string $path Optional. The full file path to the directory containing translation files. * @return string|false The translated strings in JSON encoding on success, * false if the script textdomain could not be loaded. */
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' );
            case 'author':
                return $this->display( 'Author' );
            

function get_locale_stylesheet_uri() {
    global $wp_locale;
    $stylesheet_dir_uri = get_stylesheet_directory_uri();
    $dir                = get_stylesheet_directory();
    $locale             = get_locale();
    if ( file_exists( "$dir/$locale.css" ) ) {
        $stylesheet_uri = "$stylesheet_dir_uri/$locale.css";
    } elseif ( ! empty( $wp_locale->text_direction ) && file_exists( "$dir/{$wp_locale->text_direction}.css" ) ) {
        $stylesheet_uri = "$stylesheet_dir_uri/{$wp_locale->text_direction}.css";
    } else {
        $stylesheet_uri = '';
    }
    /** * Filters the localized stylesheet URI. * * @since 2.1.0 * * @param string $stylesheet_uri Localized stylesheet URI. * @param string $stylesheet_dir_uri Stylesheet directory URI. */
$allowed_files = array( 'functions.php' => $allowed_files['functions.php'] ) + $allowed_files;
}
if ( isset( $allowed_files['style.css'] ) ) {
    $allowed_files = array( 'style.css' => $allowed_files['style.css'] ) + $allowed_files;
}

if ( empty( $file ) ) {
    $relative_file = 'style.css';
    $file          = $allowed_files['style.css'];
} else {
    $relative_file = wp_unslash( $file );
    $file          = $theme->get_stylesheet_directory() . '/' . $relative_file;
}

validate_file_to_edit( $file$allowed_files );

// Handle fallback editing of file when JavaScript is not available. $edit_error     = null;
$posted_content = null;

if ( 'POST' === $_SERVER['REQUEST_METHOD'] ) {
    $r = wp_edit_theme_plugin_file( wp_unslash( $_POST ) );
    if ( is_wp_error( $r ) ) {
        
// 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. */
    $is_parent_theme_block = str_starts_with( $script_path_norm$template_path_norm );
    
if (
        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' );

    

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

    if ( empty( $file ) ) {
        $url = get_stylesheet_directory_uri();
    } elseif ( file_exists( get_stylesheet_directory() . '/' . $file ) ) {
        $url = get_stylesheet_directory_uri() . '/' . $file;
    } else {
        $url = get_template_directory_uri() . '/' . $file;
    }

    /** * Filters the URL to a file in the theme. * * @since 4.7.0 * * @param string $url The file URL. * @param string $file The requested file to search for. */
'parent_theme'   => array(
                'label' => __( 'Parent theme' ),
                'value' => $active_theme_parent_theme,
                'debug' => $active_theme_parent_theme_debug,
            ),
            'theme_features' => array(
                'label' => __( 'Theme features' ),
                'value' => implode( ', ', $theme_features ),
            ),
            'theme_path'     => array(
                'label' => __( 'Theme directory location' ),
                'value' => get_stylesheet_directory(),
            ),
        );

        if ( $auto_updates_enabled ) {
            if ( isset( $transient->response[ $active_theme->stylesheet ] ) ) {
                $item = $transient->response[ $active_theme->stylesheet ];
            } elseif ( isset( $transient->no_update[ $active_theme->stylesheet ] ) ) {
                $item = $transient->no_update[ $active_theme->stylesheet ];
            } else {
                $item = array(
                    'theme'        => $active_theme->stylesheet,
                    
foreach ( $attachments as $symbol => $attachment ) {

            // 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'] ) ) {
                

    $themes     = array();
    $stylesheet = get_stylesheet();
    $template   = get_template();
    if ( $stylesheet !== $template ) {
        $themes[] = wp_get_theme( $stylesheet );
    }
    $themes[] = wp_get_theme( $template );

    foreach ( $themes as $theme ) {
        $dirpath = $theme->get_stylesheet_directory() . '/patterns/';
        if ( ! is_dir( $dirpath ) || ! is_readable( $dirpath ) ) {
            continue;
        }
        if ( file_exists( $dirpath ) ) {
            $files = glob( $dirpath . '*.php' );
            if ( $files ) {
                foreach ( $files as $file ) {
                    $pattern_data = get_file_data( $file$default_headers );

                    if ( empty( $pattern_data['slug'] ) ) {
                        _doing_it_wrong(
                            
default:
                    $allowed_files = array_merge( $allowed_files$theme->get_files( $type, -1 ) );
                    break;
            }
        }

        // Compare based on relative paths.         if ( 0 !== validate_file( $filearray_keys( $allowed_files ) ) ) {
            return new WP_Error( 'disallowed_theme_file', __( 'Sorry, that file cannot be edited.' ) );
        }

        $real_file = $theme->get_stylesheet_directory() . '/' . $file;

        $is_active = ( get_stylesheet() === $stylesheet || get_template() === $stylesheet );

    } else {
        return new WP_Error( 'missing_theme_or_plugin' );
    }

    // Ensure file is real.     if ( ! is_file( $real_file ) ) {
        return new WP_Error( 'file_does_not_exist', __( 'File does not exist! Please double check the name and try again.' ) );
    }

    
/* * 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 ( 'upload' !== $this->type || ! is_wp_error( $this->result ) || 'folder_exists' !== $this->result->get_error_code() ) {
            return false;
        }

        $folder = $this->result->get_error_data( 'folder_exists' );
        $folder = rtrim( $folder, '/' );

        $current_theme_data = false;
        $all_themes         = wp_get_themes( array( 'errors' => null ) );

        foreach ( $all_themes as $theme ) {
            $stylesheet_dir = wp_normalize_path( $theme->get_stylesheet_directory() );

            if ( rtrim( $stylesheet_dir, '/' ) !== $folder ) {
                continue;
            }

            $current_theme_data = $theme;
        }

        $new_theme_data = $this->upgrader->new_theme_data;

        if ( ! $current_theme_data || ! $new_theme_data ) {
            
<!DOCTYPE html> <html <?php language_attributes(); ?>> <head> <link rel="profile" href="https://gmpg.org/xfn/11" /> <meta http-equiv="Content-Type" content="<?php bloginfo( 'html_type' ); ?>; charset=<?php bloginfo( 'charset' ); ?>" /> <title><?php echo wp_get_document_title(); ?></title> <link rel="stylesheet" href="<?php bloginfo( 'stylesheet_url' ); ?>" type="text/css" media="screen" /> <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" /> <?php if ( file_exists( get_stylesheet_directory() . '/images/kubrickbgwide.jpg' ) ) { ?> <style type="text/css" media="screen"> <?php     // Checks to see whether it needs a sidebar.     if ( empty( $withcomments ) && ! is_single() ) {
        ?> #page { background: url("<?php bloginfo( 'stylesheet_directory' ); ?>/images/kubrickbg-<?php bloginfo( 'text_direction' ); ?>.jpg") repeat-y top; border: none; } <?php } else { // No sidebar. ?> #page { background: url("<?php bloginfo( 'stylesheet_directory' ); ?>/images/kubrickbgwide.jpg") repeat-y top; border: none; } <?php } ?> </style>
Home | Imprint | This part of the site doesn't use cookies.