57 'twentyfifteen' => 'Twenty Fifteen', |
57 'twentyfifteen' => 'Twenty Fifteen', |
58 'twentysixteen' => 'Twenty Sixteen', |
58 'twentysixteen' => 'Twenty Sixteen', |
59 'twentyseventeen' => 'Twenty Seventeen', |
59 'twentyseventeen' => 'Twenty Seventeen', |
60 'twentynineteen' => 'Twenty Nineteen', |
60 'twentynineteen' => 'Twenty Nineteen', |
61 'twentytwenty' => 'Twenty Twenty', |
61 'twentytwenty' => 'Twenty Twenty', |
|
62 'twentytwentyone' => 'Twenty Twenty-One', |
62 ); |
63 ); |
63 |
64 |
64 /** |
65 /** |
65 * Renamed theme tags. |
66 * Renamed theme tags. |
66 * |
67 * |
1138 return $this->get_stylesheet_directory_uri() . '/' . $screenshot; |
1139 return $this->get_stylesheet_directory_uri() . '/' . $screenshot; |
1139 } elseif ( 0 === $screenshot ) { |
1140 } elseif ( 0 === $screenshot ) { |
1140 return false; |
1141 return false; |
1141 } |
1142 } |
1142 |
1143 |
1143 foreach ( array( 'png', 'gif', 'jpg', 'jpeg' ) as $ext ) { |
1144 foreach ( array( 'png', 'gif', 'jpg', 'jpeg', 'webp' ) as $ext ) { |
1144 if ( file_exists( $this->get_stylesheet_directory() . "/screenshot.$ext" ) ) { |
1145 if ( file_exists( $this->get_stylesheet_directory() . "/screenshot.$ext" ) ) { |
1145 $this->cache_add( 'screenshot', 'screenshot.' . $ext ); |
1146 $this->cache_add( 'screenshot', 'screenshot.' . $ext ); |
1146 if ( 'relative' === $uri ) { |
1147 if ( 'relative' === $uri ) { |
1147 return 'screenshot.' . $ext; |
1148 return 'screenshot.' . $ext; |
1148 } |
1149 } |
1179 |
1180 |
1180 /** |
1181 /** |
1181 * Returns the theme's post templates. |
1182 * Returns the theme's post templates. |
1182 * |
1183 * |
1183 * @since 4.7.0 |
1184 * @since 4.7.0 |
|
1185 * @since 5.8.0 Include block templates. |
1184 * |
1186 * |
1185 * @return string[] Array of page templates, keyed by filename and post type, |
1187 * @return string[] Array of page templates, keyed by filename and post type, |
1186 * with the value of the translated header name. |
1188 * with the value of the translated header name. |
1187 */ |
1189 */ |
1188 public function get_post_templates() { |
1190 public function get_post_templates() { |
1213 if ( ! isset( $post_templates[ $type ] ) ) { |
1215 if ( ! isset( $post_templates[ $type ] ) ) { |
1214 $post_templates[ $type ] = array(); |
1216 $post_templates[ $type ] = array(); |
1215 } |
1217 } |
1216 |
1218 |
1217 $post_templates[ $type ][ $file ] = _cleanup_header_comment( $header[1] ); |
1219 $post_templates[ $type ][ $file ] = _cleanup_header_comment( $header[1] ); |
|
1220 } |
|
1221 } |
|
1222 |
|
1223 if ( current_theme_supports( 'block-templates' ) ) { |
|
1224 $block_templates = get_block_templates( array(), 'wp_template' ); |
|
1225 foreach ( get_post_types( array( 'public' => true ) ) as $type ) { |
|
1226 foreach ( $block_templates as $block_template ) { |
|
1227 $post_templates[ $type ][ $block_template->slug ] = $block_template->title; |
|
1228 } |
1218 } |
1229 } |
1219 } |
1230 } |
1220 |
1231 |
1221 $this->cache_add( 'post_templates', $post_templates ); |
1232 $this->cache_add( 'post_templates', $post_templates ); |
1222 } |
1233 } |
1255 * Filters list of page templates for a theme. |
1266 * Filters list of page templates for a theme. |
1256 * |
1267 * |
1257 * @since 4.9.6 |
1268 * @since 4.9.6 |
1258 * |
1269 * |
1259 * @param string[] $post_templates Array of template header names keyed by the template file name. |
1270 * @param string[] $post_templates Array of template header names keyed by the template file name. |
1260 * @param WP_Theme $this The theme object. |
1271 * @param WP_Theme $theme The theme object. |
1261 * @param WP_Post|null $post The post being edited, provided for context, or null. |
1272 * @param WP_Post|null $post The post being edited, provided for context, or null. |
1262 * @param string $post_type Post type to get the templates for. |
1273 * @param string $post_type Post type to get the templates for. |
1263 */ |
1274 */ |
1264 $post_templates = (array) apply_filters( 'theme_templates', $post_templates, $this, $post, $post_type ); |
1275 $post_templates = (array) apply_filters( 'theme_templates', $post_templates, $this, $post, $post_type ); |
1265 |
1276 |
1266 /** |
1277 /** |
1267 * Filters list of page templates for a theme. |
1278 * Filters list of page templates for a theme. |
1268 * |
1279 * |
1269 * The dynamic portion of the hook name, `$post_type`, refers to the post type. |
1280 * The dynamic portion of the hook name, `$post_type`, refers to the post type. |
|
1281 * |
|
1282 * Possible hook names include: |
|
1283 * |
|
1284 * - `theme_post_templates` |
|
1285 * - `theme_page_templates` |
|
1286 * - `theme_attachment_templates` |
1270 * |
1287 * |
1271 * @since 3.9.0 |
1288 * @since 3.9.0 |
1272 * @since 4.4.0 Converted to allow complete control over the `$page_templates` array. |
1289 * @since 4.4.0 Converted to allow complete control over the `$page_templates` array. |
1273 * @since 4.7.0 Added the `$post_type` parameter. |
1290 * @since 4.7.0 Added the `$post_type` parameter. |
1274 * |
1291 * |
1275 * @param string[] $post_templates Array of template header names keyed by the template file name. |
1292 * @param string[] $post_templates Array of template header names keyed by the template file name. |
1276 * @param WP_Theme $this The theme object. |
1293 * @param WP_Theme $theme The theme object. |
1277 * @param WP_Post|null $post The post being edited, provided for context, or null. |
1294 * @param WP_Post|null $post The post being edited, provided for context, or null. |
1278 * @param string $post_type Post type to get the templates for. |
1295 * @param string $post_type Post type to get the templates for. |
1279 */ |
1296 */ |
1280 $post_templates = (array) apply_filters( "theme_{$post_type}_templates", $post_templates, $this, $post, $post_type ); |
1297 $post_templates = (array) apply_filters( "theme_{$post_type}_templates", $post_templates, $this, $post, $post_type ); |
1281 |
1298 |