Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../public_h.../wp-inclu...
File: class-wp-theme.php
* @param string $header Theme header. Name, Description, Author, Version, ThemeURI, AuthorURI, Status, Tags.
[1000] Fix | Delete
* @param string|array $value Value to mark up. An array for Tags header, string otherwise.
[1001] Fix | Delete
* @param string $translate Whether the header has been translated.
[1002] Fix | Delete
* @return string Value, marked up.
[1003] Fix | Delete
*/
[1004] Fix | Delete
private function markup_header( $header, $value, $translate ) {
[1005] Fix | Delete
switch ( $header ) {
[1006] Fix | Delete
case 'Name':
[1007] Fix | Delete
if ( empty( $value ) ) {
[1008] Fix | Delete
$value = esc_html( $this->get_stylesheet() );
[1009] Fix | Delete
}
[1010] Fix | Delete
break;
[1011] Fix | Delete
case 'Description':
[1012] Fix | Delete
$value = wptexturize( $value );
[1013] Fix | Delete
break;
[1014] Fix | Delete
case 'Author':
[1015] Fix | Delete
if ( $this->get( 'AuthorURI' ) ) {
[1016] Fix | Delete
$value = sprintf( '<a href="%1$s">%2$s</a>', $this->display( 'AuthorURI', true, $translate ), $value );
[1017] Fix | Delete
} elseif ( ! $value ) {
[1018] Fix | Delete
$value = __( 'Anonymous' );
[1019] Fix | Delete
}
[1020] Fix | Delete
break;
[1021] Fix | Delete
case 'Tags':
[1022] Fix | Delete
static $comma = null;
[1023] Fix | Delete
if ( ! isset( $comma ) ) {
[1024] Fix | Delete
$comma = wp_get_list_item_separator();
[1025] Fix | Delete
}
[1026] Fix | Delete
$value = implode( $comma, $value );
[1027] Fix | Delete
break;
[1028] Fix | Delete
case 'ThemeURI':
[1029] Fix | Delete
case 'AuthorURI':
[1030] Fix | Delete
$value = esc_url( $value );
[1031] Fix | Delete
break;
[1032] Fix | Delete
}
[1033] Fix | Delete
[1034] Fix | Delete
return $value;
[1035] Fix | Delete
}
[1036] Fix | Delete
[1037] Fix | Delete
/**
[1038] Fix | Delete
* Translates a theme header.
[1039] Fix | Delete
*
[1040] Fix | Delete
* @since 3.4.0
[1041] Fix | Delete
*
[1042] Fix | Delete
* @param string $header Theme header. Name, Description, Author, Version, ThemeURI, AuthorURI, Status, Tags.
[1043] Fix | Delete
* @param string|array $value Value to translate. An array for Tags header, string otherwise.
[1044] Fix | Delete
* @return string|array Translated value. An array for Tags header, string otherwise.
[1045] Fix | Delete
*/
[1046] Fix | Delete
private function translate_header( $header, $value ) {
[1047] Fix | Delete
switch ( $header ) {
[1048] Fix | Delete
case 'Name':
[1049] Fix | Delete
// Cached for sorting reasons.
[1050] Fix | Delete
if ( isset( $this->name_translated ) ) {
[1051] Fix | Delete
return $this->name_translated;
[1052] Fix | Delete
}
[1053] Fix | Delete
[1054] Fix | Delete
// phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText,WordPress.WP.I18n.NonSingularStringLiteralDomain
[1055] Fix | Delete
$this->name_translated = translate( $value, $this->get( 'TextDomain' ) );
[1056] Fix | Delete
[1057] Fix | Delete
return $this->name_translated;
[1058] Fix | Delete
case 'Tags':
[1059] Fix | Delete
if ( empty( $value ) || ! function_exists( 'get_theme_feature_list' ) ) {
[1060] Fix | Delete
return $value;
[1061] Fix | Delete
}
[1062] Fix | Delete
[1063] Fix | Delete
static $tags_list;
[1064] Fix | Delete
if ( ! isset( $tags_list ) ) {
[1065] Fix | Delete
$tags_list = array(
[1066] Fix | Delete
// As of 4.6, deprecated tags which are only used to provide translation for older themes.
[1067] Fix | Delete
'black' => __( 'Black' ),
[1068] Fix | Delete
'blue' => __( 'Blue' ),
[1069] Fix | Delete
'brown' => __( 'Brown' ),
[1070] Fix | Delete
'gray' => __( 'Gray' ),
[1071] Fix | Delete
'green' => __( 'Green' ),
[1072] Fix | Delete
'orange' => __( 'Orange' ),
[1073] Fix | Delete
'pink' => __( 'Pink' ),
[1074] Fix | Delete
'purple' => __( 'Purple' ),
[1075] Fix | Delete
'red' => __( 'Red' ),
[1076] Fix | Delete
'silver' => __( 'Silver' ),
[1077] Fix | Delete
'tan' => __( 'Tan' ),
[1078] Fix | Delete
'white' => __( 'White' ),
[1079] Fix | Delete
'yellow' => __( 'Yellow' ),
[1080] Fix | Delete
'dark' => _x( 'Dark', 'color scheme' ),
[1081] Fix | Delete
'light' => _x( 'Light', 'color scheme' ),
[1082] Fix | Delete
'fixed-layout' => __( 'Fixed Layout' ),
[1083] Fix | Delete
'fluid-layout' => __( 'Fluid Layout' ),
[1084] Fix | Delete
'responsive-layout' => __( 'Responsive Layout' ),
[1085] Fix | Delete
'blavatar' => __( 'Blavatar' ),
[1086] Fix | Delete
'photoblogging' => __( 'Photoblogging' ),
[1087] Fix | Delete
'seasonal' => __( 'Seasonal' ),
[1088] Fix | Delete
);
[1089] Fix | Delete
[1090] Fix | Delete
$feature_list = get_theme_feature_list( false ); // No API.
[1091] Fix | Delete
[1092] Fix | Delete
foreach ( $feature_list as $tags ) {
[1093] Fix | Delete
$tags_list += $tags;
[1094] Fix | Delete
}
[1095] Fix | Delete
}
[1096] Fix | Delete
[1097] Fix | Delete
foreach ( $value as &$tag ) {
[1098] Fix | Delete
if ( isset( $tags_list[ $tag ] ) ) {
[1099] Fix | Delete
$tag = $tags_list[ $tag ];
[1100] Fix | Delete
} elseif ( isset( self::$tag_map[ $tag ] ) ) {
[1101] Fix | Delete
$tag = $tags_list[ self::$tag_map[ $tag ] ];
[1102] Fix | Delete
}
[1103] Fix | Delete
}
[1104] Fix | Delete
[1105] Fix | Delete
return $value;
[1106] Fix | Delete
[1107] Fix | Delete
default:
[1108] Fix | Delete
// phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText,WordPress.WP.I18n.NonSingularStringLiteralDomain
[1109] Fix | Delete
$value = translate( $value, $this->get( 'TextDomain' ) );
[1110] Fix | Delete
}
[1111] Fix | Delete
return $value;
[1112] Fix | Delete
}
[1113] Fix | Delete
[1114] Fix | Delete
/**
[1115] Fix | Delete
* Returns the directory name of the theme's "stylesheet" files, inside the theme root.
[1116] Fix | Delete
*
[1117] Fix | Delete
* In the case of a child theme, this is directory name of the child theme.
[1118] Fix | Delete
* Otherwise, get_stylesheet() is the same as get_template().
[1119] Fix | Delete
*
[1120] Fix | Delete
* @since 3.4.0
[1121] Fix | Delete
*
[1122] Fix | Delete
* @return string Stylesheet
[1123] Fix | Delete
*/
[1124] Fix | Delete
public function get_stylesheet() {
[1125] Fix | Delete
return $this->stylesheet;
[1126] Fix | Delete
}
[1127] Fix | Delete
[1128] Fix | Delete
/**
[1129] Fix | Delete
* Returns the directory name of the theme's "template" files, inside the theme root.
[1130] Fix | Delete
*
[1131] Fix | Delete
* In the case of a child theme, this is the directory name of the parent theme.
[1132] Fix | Delete
* Otherwise, the get_template() is the same as get_stylesheet().
[1133] Fix | Delete
*
[1134] Fix | Delete
* @since 3.4.0
[1135] Fix | Delete
*
[1136] Fix | Delete
* @return string Template
[1137] Fix | Delete
*/
[1138] Fix | Delete
public function get_template() {
[1139] Fix | Delete
return $this->template;
[1140] Fix | Delete
}
[1141] Fix | Delete
[1142] Fix | Delete
/**
[1143] Fix | Delete
* Returns the absolute path to the directory of a theme's "stylesheet" files.
[1144] Fix | Delete
*
[1145] Fix | Delete
* In the case of a child theme, this is the absolute path to the directory
[1146] Fix | Delete
* of the child theme's files.
[1147] Fix | Delete
*
[1148] Fix | Delete
* @since 3.4.0
[1149] Fix | Delete
*
[1150] Fix | Delete
* @return string Absolute path of the stylesheet directory.
[1151] Fix | Delete
*/
[1152] Fix | Delete
public function get_stylesheet_directory() {
[1153] Fix | Delete
if ( $this->errors() && in_array( 'theme_root_missing', $this->errors()->get_error_codes(), true ) ) {
[1154] Fix | Delete
return '';
[1155] Fix | Delete
}
[1156] Fix | Delete
[1157] Fix | Delete
return $this->theme_root . '/' . $this->stylesheet;
[1158] Fix | Delete
}
[1159] Fix | Delete
[1160] Fix | Delete
/**
[1161] Fix | Delete
* Returns the absolute path to the directory of a theme's "template" files.
[1162] Fix | Delete
*
[1163] Fix | Delete
* In the case of a child theme, this is the absolute path to the directory
[1164] Fix | Delete
* of the parent theme's files.
[1165] Fix | Delete
*
[1166] Fix | Delete
* @since 3.4.0
[1167] Fix | Delete
*
[1168] Fix | Delete
* @return string Absolute path of the template directory.
[1169] Fix | Delete
*/
[1170] Fix | Delete
public function get_template_directory() {
[1171] Fix | Delete
if ( $this->parent() ) {
[1172] Fix | Delete
$theme_root = $this->parent()->theme_root;
[1173] Fix | Delete
} else {
[1174] Fix | Delete
$theme_root = $this->theme_root;
[1175] Fix | Delete
}
[1176] Fix | Delete
[1177] Fix | Delete
return $theme_root . '/' . $this->template;
[1178] Fix | Delete
}
[1179] Fix | Delete
[1180] Fix | Delete
/**
[1181] Fix | Delete
* Returns the URL to the directory of a theme's "stylesheet" files.
[1182] Fix | Delete
*
[1183] Fix | Delete
* In the case of a child theme, this is the URL to the directory of the
[1184] Fix | Delete
* child theme's files.
[1185] Fix | Delete
*
[1186] Fix | Delete
* @since 3.4.0
[1187] Fix | Delete
*
[1188] Fix | Delete
* @return string URL to the stylesheet directory.
[1189] Fix | Delete
*/
[1190] Fix | Delete
public function get_stylesheet_directory_uri() {
[1191] Fix | Delete
return $this->get_theme_root_uri() . '/' . str_replace( '%2F', '/', rawurlencode( $this->stylesheet ) );
[1192] Fix | Delete
}
[1193] Fix | Delete
[1194] Fix | Delete
/**
[1195] Fix | Delete
* Returns the URL to the directory of a theme's "template" files.
[1196] Fix | Delete
*
[1197] Fix | Delete
* In the case of a child theme, this is the URL to the directory of the
[1198] Fix | Delete
* parent theme's files.
[1199] Fix | Delete
*
[1200] Fix | Delete
* @since 3.4.0
[1201] Fix | Delete
*
[1202] Fix | Delete
* @return string URL to the template directory.
[1203] Fix | Delete
*/
[1204] Fix | Delete
public function get_template_directory_uri() {
[1205] Fix | Delete
if ( $this->parent() ) {
[1206] Fix | Delete
$theme_root_uri = $this->parent()->get_theme_root_uri();
[1207] Fix | Delete
} else {
[1208] Fix | Delete
$theme_root_uri = $this->get_theme_root_uri();
[1209] Fix | Delete
}
[1210] Fix | Delete
[1211] Fix | Delete
return $theme_root_uri . '/' . str_replace( '%2F', '/', rawurlencode( $this->template ) );
[1212] Fix | Delete
}
[1213] Fix | Delete
[1214] Fix | Delete
/**
[1215] Fix | Delete
* Returns the absolute path to the directory of the theme root.
[1216] Fix | Delete
*
[1217] Fix | Delete
* This is typically the absolute path to wp-content/themes.
[1218] Fix | Delete
*
[1219] Fix | Delete
* @since 3.4.0
[1220] Fix | Delete
*
[1221] Fix | Delete
* @return string Theme root.
[1222] Fix | Delete
*/
[1223] Fix | Delete
public function get_theme_root() {
[1224] Fix | Delete
return $this->theme_root;
[1225] Fix | Delete
}
[1226] Fix | Delete
[1227] Fix | Delete
/**
[1228] Fix | Delete
* Returns the URL to the directory of the theme root.
[1229] Fix | Delete
*
[1230] Fix | Delete
* This is typically the absolute URL to wp-content/themes. This forms the basis
[1231] Fix | Delete
* for all other URLs returned by WP_Theme, so we pass it to the public function
[1232] Fix | Delete
* get_theme_root_uri() and allow it to run the {@see 'theme_root_uri'} filter.
[1233] Fix | Delete
*
[1234] Fix | Delete
* @since 3.4.0
[1235] Fix | Delete
*
[1236] Fix | Delete
* @return string Theme root URI.
[1237] Fix | Delete
*/
[1238] Fix | Delete
public function get_theme_root_uri() {
[1239] Fix | Delete
if ( ! isset( $this->theme_root_uri ) ) {
[1240] Fix | Delete
$this->theme_root_uri = get_theme_root_uri( $this->stylesheet, $this->theme_root );
[1241] Fix | Delete
}
[1242] Fix | Delete
return $this->theme_root_uri;
[1243] Fix | Delete
}
[1244] Fix | Delete
[1245] Fix | Delete
/**
[1246] Fix | Delete
* Returns the main screenshot file for the theme.
[1247] Fix | Delete
*
[1248] Fix | Delete
* The main screenshot is called screenshot.png. gif and jpg extensions are also allowed.
[1249] Fix | Delete
*
[1250] Fix | Delete
* Screenshots for a theme must be in the stylesheet directory. (In the case of child
[1251] Fix | Delete
* themes, parent theme screenshots are not inherited.)
[1252] Fix | Delete
*
[1253] Fix | Delete
* @since 3.4.0
[1254] Fix | Delete
*
[1255] Fix | Delete
* @param string $uri Type of URL to return, either 'relative' or an absolute URI. Defaults to absolute URI.
[1256] Fix | Delete
* @return string|false Screenshot file. False if the theme does not have a screenshot.
[1257] Fix | Delete
*/
[1258] Fix | Delete
public function get_screenshot( $uri = 'uri' ) {
[1259] Fix | Delete
$screenshot = $this->cache_get( 'screenshot' );
[1260] Fix | Delete
if ( $screenshot ) {
[1261] Fix | Delete
if ( 'relative' === $uri ) {
[1262] Fix | Delete
return $screenshot;
[1263] Fix | Delete
}
[1264] Fix | Delete
return $this->get_stylesheet_directory_uri() . '/' . $screenshot;
[1265] Fix | Delete
} elseif ( 0 === $screenshot ) {
[1266] Fix | Delete
return false;
[1267] Fix | Delete
}
[1268] Fix | Delete
[1269] Fix | Delete
foreach ( array( 'png', 'gif', 'jpg', 'jpeg', 'webp', 'avif' ) as $ext ) {
[1270] Fix | Delete
if ( file_exists( $this->get_stylesheet_directory() . "/screenshot.$ext" ) ) {
[1271] Fix | Delete
$this->cache_add( 'screenshot', 'screenshot.' . $ext );
[1272] Fix | Delete
if ( 'relative' === $uri ) {
[1273] Fix | Delete
return 'screenshot.' . $ext;
[1274] Fix | Delete
}
[1275] Fix | Delete
return $this->get_stylesheet_directory_uri() . '/' . 'screenshot.' . $ext;
[1276] Fix | Delete
}
[1277] Fix | Delete
}
[1278] Fix | Delete
[1279] Fix | Delete
$this->cache_add( 'screenshot', 0 );
[1280] Fix | Delete
return false;
[1281] Fix | Delete
}
[1282] Fix | Delete
[1283] Fix | Delete
/**
[1284] Fix | Delete
* Returns files in the theme's directory.
[1285] Fix | Delete
*
[1286] Fix | Delete
* @since 3.4.0
[1287] Fix | Delete
*
[1288] Fix | Delete
* @param string[]|string $type Optional. Array of extensions to find, string of a single extension,
[1289] Fix | Delete
* or null for all extensions. Default null.
[1290] Fix | Delete
* @param int $depth Optional. How deep to search for files. Defaults to a flat scan (0 depth).
[1291] Fix | Delete
* -1 depth is infinite.
[1292] Fix | Delete
* @param bool $search_parent Optional. Whether to return parent files. Default false.
[1293] Fix | Delete
* @return string[] Array of files, keyed by the path to the file relative to the theme's directory, with the values
[1294] Fix | Delete
* being absolute paths.
[1295] Fix | Delete
*/
[1296] Fix | Delete
public function get_files( $type = null, $depth = 0, $search_parent = false ) {
[1297] Fix | Delete
$files = (array) self::scandir( $this->get_stylesheet_directory(), $type, $depth );
[1298] Fix | Delete
[1299] Fix | Delete
if ( $search_parent && $this->parent() ) {
[1300] Fix | Delete
$files += (array) self::scandir( $this->get_template_directory(), $type, $depth );
[1301] Fix | Delete
}
[1302] Fix | Delete
[1303] Fix | Delete
return array_filter( $files );
[1304] Fix | Delete
}
[1305] Fix | Delete
[1306] Fix | Delete
/**
[1307] Fix | Delete
* Returns the theme's post templates.
[1308] Fix | Delete
*
[1309] Fix | Delete
* @since 4.7.0
[1310] Fix | Delete
* @since 5.8.0 Include block templates.
[1311] Fix | Delete
*
[1312] Fix | Delete
* @return array[] Array of page template arrays, keyed by post type and filename,
[1313] Fix | Delete
* with the value of the translated header name.
[1314] Fix | Delete
*/
[1315] Fix | Delete
public function get_post_templates() {
[1316] Fix | Delete
// If you screw up your active theme and we invalidate your parent, most things still work. Let it slide.
[1317] Fix | Delete
if ( $this->errors() && $this->errors()->get_error_codes() !== array( 'theme_parent_invalid' ) ) {
[1318] Fix | Delete
return array();
[1319] Fix | Delete
}
[1320] Fix | Delete
[1321] Fix | Delete
$post_templates = $this->cache_get( 'post_templates' );
[1322] Fix | Delete
[1323] Fix | Delete
if ( ! is_array( $post_templates ) ) {
[1324] Fix | Delete
$post_templates = array();
[1325] Fix | Delete
[1326] Fix | Delete
$files = (array) $this->get_files( 'php', 1, true );
[1327] Fix | Delete
[1328] Fix | Delete
foreach ( $files as $file => $full_path ) {
[1329] Fix | Delete
if ( ! preg_match( '|Template Name:(.*)$|mi', file_get_contents( $full_path ), $header ) ) {
[1330] Fix | Delete
continue;
[1331] Fix | Delete
}
[1332] Fix | Delete
[1333] Fix | Delete
$types = array( 'page' );
[1334] Fix | Delete
if ( preg_match( '|Template Post Type:(.*)$|mi', file_get_contents( $full_path ), $type ) ) {
[1335] Fix | Delete
$types = explode( ',', _cleanup_header_comment( $type[1] ) );
[1336] Fix | Delete
}
[1337] Fix | Delete
[1338] Fix | Delete
foreach ( $types as $type ) {
[1339] Fix | Delete
$type = sanitize_key( $type );
[1340] Fix | Delete
if ( ! isset( $post_templates[ $type ] ) ) {
[1341] Fix | Delete
$post_templates[ $type ] = array();
[1342] Fix | Delete
}
[1343] Fix | Delete
[1344] Fix | Delete
$post_templates[ $type ][ $file ] = _cleanup_header_comment( $header[1] );
[1345] Fix | Delete
}
[1346] Fix | Delete
}
[1347] Fix | Delete
[1348] Fix | Delete
$this->cache_add( 'post_templates', $post_templates );
[1349] Fix | Delete
}
[1350] Fix | Delete
[1351] Fix | Delete
if ( current_theme_supports( 'block-templates' ) ) {
[1352] Fix | Delete
$block_templates = get_block_templates( array(), 'wp_template' );
[1353] Fix | Delete
foreach ( get_post_types( array( 'public' => true ) ) as $type ) {
[1354] Fix | Delete
foreach ( $block_templates as $block_template ) {
[1355] Fix | Delete
if ( ! $block_template->is_custom ) {
[1356] Fix | Delete
continue;
[1357] Fix | Delete
}
[1358] Fix | Delete
[1359] Fix | Delete
if ( isset( $block_template->post_types ) && ! in_array( $type, $block_template->post_types, true ) ) {
[1360] Fix | Delete
continue;
[1361] Fix | Delete
}
[1362] Fix | Delete
[1363] Fix | Delete
$post_templates[ $type ][ $block_template->slug ] = $block_template->title;
[1364] Fix | Delete
}
[1365] Fix | Delete
}
[1366] Fix | Delete
}
[1367] Fix | Delete
[1368] Fix | Delete
if ( $this->load_textdomain() ) {
[1369] Fix | Delete
foreach ( $post_templates as &$post_type ) {
[1370] Fix | Delete
foreach ( $post_type as &$post_template ) {
[1371] Fix | Delete
$post_template = $this->translate_header( 'Template Name', $post_template );
[1372] Fix | Delete
}
[1373] Fix | Delete
}
[1374] Fix | Delete
}
[1375] Fix | Delete
[1376] Fix | Delete
return $post_templates;
[1377] Fix | Delete
}
[1378] Fix | Delete
[1379] Fix | Delete
/**
[1380] Fix | Delete
* Returns the theme's post templates for a given post type.
[1381] Fix | Delete
*
[1382] Fix | Delete
* @since 3.4.0
[1383] Fix | Delete
* @since 4.7.0 Added the `$post_type` parameter.
[1384] Fix | Delete
*
[1385] Fix | Delete
* @param WP_Post|null $post Optional. The post being edited, provided for context.
[1386] Fix | Delete
* @param string $post_type Optional. Post type to get the templates for. Default 'page'.
[1387] Fix | Delete
* If a post is provided, its post type is used.
[1388] Fix | Delete
* @return string[] Array of template header names keyed by the template file name.
[1389] Fix | Delete
*/
[1390] Fix | Delete
public function get_page_templates( $post = null, $post_type = 'page' ) {
[1391] Fix | Delete
if ( $post ) {
[1392] Fix | Delete
$post_type = get_post_type( $post );
[1393] Fix | Delete
}
[1394] Fix | Delete
[1395] Fix | Delete
$post_templates = $this->get_post_templates();
[1396] Fix | Delete
$post_templates = isset( $post_templates[ $post_type ] ) ? $post_templates[ $post_type ] : array();
[1397] Fix | Delete
[1398] Fix | Delete
/**
[1399] Fix | Delete
* Filters list of page templates for a theme.
[1400] Fix | Delete
*
[1401] Fix | Delete
* @since 4.9.6
[1402] Fix | Delete
*
[1403] Fix | Delete
* @param string[] $post_templates Array of template header names keyed by the template file name.
[1404] Fix | Delete
* @param WP_Theme $theme The theme object.
[1405] Fix | Delete
* @param WP_Post|null $post The post being edited, provided for context, or null.
[1406] Fix | Delete
* @param string $post_type Post type to get the templates for.
[1407] Fix | Delete
*/
[1408] Fix | Delete
$post_templates = (array) apply_filters( 'theme_templates', $post_templates, $this, $post, $post_type );
[1409] Fix | Delete
[1410] Fix | Delete
/**
[1411] Fix | Delete
* Filters list of page templates for a theme.
[1412] Fix | Delete
*
[1413] Fix | Delete
* The dynamic portion of the hook name, `$post_type`, refers to the post type.
[1414] Fix | Delete
*
[1415] Fix | Delete
* Possible hook names include:
[1416] Fix | Delete
*
[1417] Fix | Delete
* - `theme_post_templates`
[1418] Fix | Delete
* - `theme_page_templates`
[1419] Fix | Delete
* - `theme_attachment_templates`
[1420] Fix | Delete
*
[1421] Fix | Delete
* @since 3.9.0
[1422] Fix | Delete
* @since 4.4.0 Converted to allow complete control over the `$page_templates` array.
[1423] Fix | Delete
* @since 4.7.0 Added the `$post_type` parameter.
[1424] Fix | Delete
*
[1425] Fix | Delete
* @param string[] $post_templates Array of template header names keyed by the template file name.
[1426] Fix | Delete
* @param WP_Theme $theme The theme object.
[1427] Fix | Delete
* @param WP_Post|null $post The post being edited, provided for context, or null.
[1428] Fix | Delete
* @param string $post_type Post type to get the templates for.
[1429] Fix | Delete
*/
[1430] Fix | Delete
$post_templates = (array) apply_filters( "theme_{$post_type}_templates", $post_templates, $this, $post, $post_type );
[1431] Fix | Delete
[1432] Fix | Delete
return $post_templates;
[1433] Fix | Delete
}
[1434] Fix | Delete
[1435] Fix | Delete
/**
[1436] Fix | Delete
* Scans a directory for files of a certain extension.
[1437] Fix | Delete
*
[1438] Fix | Delete
* @since 3.4.0
[1439] Fix | Delete
*
[1440] Fix | Delete
* @param string $path Absolute path to search.
[1441] Fix | Delete
* @param array|string|null $extensions Optional. Array of extensions to find, string of a single extension,
[1442] Fix | Delete
* or null for all extensions. Default null.
[1443] Fix | Delete
* @param int $depth Optional. How many levels deep to search for files. Accepts 0, 1+, or
[1444] Fix | Delete
* -1 (infinite depth). Default 0.
[1445] Fix | Delete
* @param string $relative_path Optional. The basename of the absolute path. Used to control the
[1446] Fix | Delete
* returned path for the found files, particularly when this function
[1447] Fix | Delete
* recurses to lower depths. Default empty.
[1448] Fix | Delete
* @return string[]|false Array of files, keyed by the path to the file relative to the `$path` directory prepended
[1449] Fix | Delete
* with `$relative_path`, with the values being absolute paths. False otherwise.
[1450] Fix | Delete
*/
[1451] Fix | Delete
private static function scandir( $path, $extensions = null, $depth = 0, $relative_path = '' ) {
[1452] Fix | Delete
if ( ! is_dir( $path ) ) {
[1453] Fix | Delete
return false;
[1454] Fix | Delete
}
[1455] Fix | Delete
[1456] Fix | Delete
if ( $extensions ) {
[1457] Fix | Delete
$extensions = (array) $extensions;
[1458] Fix | Delete
$_extensions = implode( '|', $extensions );
[1459] Fix | Delete
}
[1460] Fix | Delete
[1461] Fix | Delete
$relative_path = trailingslashit( $relative_path );
[1462] Fix | Delete
if ( '/' === $relative_path ) {
[1463] Fix | Delete
$relative_path = '';
[1464] Fix | Delete
}
[1465] Fix | Delete
[1466] Fix | Delete
$results = scandir( $path );
[1467] Fix | Delete
$files = array();
[1468] Fix | Delete
[1469] Fix | Delete
/**
[1470] Fix | Delete
* Filters the array of excluded directories and files while scanning theme folder.
[1471] Fix | Delete
*
[1472] Fix | Delete
* @since 4.7.4
[1473] Fix | Delete
*
[1474] Fix | Delete
* @param string[] $exclusions Array of excluded directories and files.
[1475] Fix | Delete
*/
[1476] Fix | Delete
$exclusions = (array) apply_filters( 'theme_scandir_exclusions', array( 'CVS', 'node_modules', 'vendor', 'bower_components' ) );
[1477] Fix | Delete
[1478] Fix | Delete
foreach ( $results as $result ) {
[1479] Fix | Delete
if ( '.' === $result[0] || in_array( $result, $exclusions, true ) ) {
[1480] Fix | Delete
continue;
[1481] Fix | Delete
}
[1482] Fix | Delete
if ( is_dir( $path . '/' . $result ) ) {
[1483] Fix | Delete
if ( ! $depth ) {
[1484] Fix | Delete
continue;
[1485] Fix | Delete
}
[1486] Fix | Delete
$found = self::scandir( $path . '/' . $result, $extensions, $depth - 1, $relative_path . $result );
[1487] Fix | Delete
$files = array_merge_recursive( $files, $found );
[1488] Fix | Delete
} elseif ( ! $extensions || preg_match( '~\.(' . $_extensions . ')$~', $result ) ) {
[1489] Fix | Delete
$files[ $relative_path . $result ] = $path . '/' . $result;
[1490] Fix | Delete
}
[1491] Fix | Delete
}
[1492] Fix | Delete
[1493] Fix | Delete
return $files;
[1494] Fix | Delete
}
[1495] Fix | Delete
[1496] Fix | Delete
/**
[1497] Fix | Delete
* Loads the theme's textdomain.
[1498] Fix | Delete
*
[1499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function