@@ 4037-4057 (lines=21) @@ | ||
4034 | * @param string $file Optional. File to search for in the stylesheet directory. |
|
4035 | * @return string The URL of the file. |
|
4036 | */ |
|
4037 | function get_theme_file_uri( $file = '' ) { |
|
4038 | $file = ltrim( $file, '/' ); |
|
4039 | ||
4040 | if ( empty( $file ) ) { |
|
4041 | $url = get_stylesheet_directory_uri(); |
|
4042 | } elseif ( file_exists( get_stylesheet_directory() . '/' . $file ) ) { |
|
4043 | $url = get_stylesheet_directory_uri() . '/' . $file; |
|
4044 | } else { |
|
4045 | $url = get_template_directory_uri() . '/' . $file; |
|
4046 | } |
|
4047 | ||
4048 | /** |
|
4049 | * Filters the URL to a file in the theme. |
|
4050 | * |
|
4051 | * @since 4.7.0 |
|
4052 | * |
|
4053 | * @param string $url The file URL. |
|
4054 | * @param string $file The requested file to search for. |
|
4055 | */ |
|
4056 | return apply_filters( 'theme_file_uri', $url, $file ); |
|
4057 | } |
|
4058 | ||
4059 | /** |
|
4060 | * Retrieves the URL of a file in the parent theme. |
|
@@ 4098-4118 (lines=21) @@ | ||
4095 | * @param string $file Optional. File to search for in the stylesheet directory. |
|
4096 | * @return string The path of the file. |
|
4097 | */ |
|
4098 | function get_theme_file_path( $file = '' ) { |
|
4099 | $file = ltrim( $file, '/' ); |
|
4100 | ||
4101 | if ( empty( $file ) ) { |
|
4102 | $path = get_stylesheet_directory(); |
|
4103 | } elseif ( file_exists( get_stylesheet_directory() . '/' . $file ) ) { |
|
4104 | $path = get_stylesheet_directory() . '/' . $file; |
|
4105 | } else { |
|
4106 | $path = get_template_directory() . '/' . $file; |
|
4107 | } |
|
4108 | ||
4109 | /** |
|
4110 | * Filters the path to a file in the theme. |
|
4111 | * |
|
4112 | * @since 4.7.0 |
|
4113 | * |
|
4114 | * @param string $path The file path. |
|
4115 | * @param string $file The requested file to search for. |
|
4116 | */ |
|
4117 | return apply_filters( 'theme_file_path', $path, $file ); |
|
4118 | } |
|
4119 | ||
4120 | /** |
|
4121 | * Retrieves the path of a file in the parent theme. |