Edit File by line
/home/zeestwma/richards.../wp-inclu...
File: template.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Template loading functions.
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
* @subpackage Template
[5] Fix | Delete
*/
[6] Fix | Delete
[7] Fix | Delete
/**
[8] Fix | Delete
* Retrieves path to a template.
[9] Fix | Delete
*
[10] Fix | Delete
* Used to quickly retrieve the path of a template without including the file
[11] Fix | Delete
* extension. It will also check the parent theme, if the file exists, with
[12] Fix | Delete
* the use of locate_template(). Allows for more generic template location
[13] Fix | Delete
* without the use of the other get_*_template() functions.
[14] Fix | Delete
*
[15] Fix | Delete
* @since 1.5.0
[16] Fix | Delete
*
[17] Fix | Delete
* @param string $type Filename without extension.
[18] Fix | Delete
* @param string[] $templates An optional list of template candidates.
[19] Fix | Delete
* @return string Full path to template file.
[20] Fix | Delete
*/
[21] Fix | Delete
function get_query_template( $type, $templates = array() ) {
[22] Fix | Delete
$type = preg_replace( '|[^a-z0-9-]+|', '', $type );
[23] Fix | Delete
[24] Fix | Delete
if ( empty( $templates ) ) {
[25] Fix | Delete
$templates = array( "{$type}.php" );
[26] Fix | Delete
}
[27] Fix | Delete
[28] Fix | Delete
/**
[29] Fix | Delete
* Filters the list of template filenames that are searched for when retrieving a template to use.
[30] Fix | Delete
*
[31] Fix | Delete
* The dynamic portion of the hook name, `$type`, refers to the filename -- minus the file
[32] Fix | Delete
* extension and any non-alphanumeric characters delimiting words -- of the file to load.
[33] Fix | Delete
* The last element in the array should always be the fallback template for this query type.
[34] Fix | Delete
*
[35] Fix | Delete
* Possible hook names include:
[36] Fix | Delete
*
[37] Fix | Delete
* - `404_template_hierarchy`
[38] Fix | Delete
* - `archive_template_hierarchy`
[39] Fix | Delete
* - `attachment_template_hierarchy`
[40] Fix | Delete
* - `author_template_hierarchy`
[41] Fix | Delete
* - `category_template_hierarchy`
[42] Fix | Delete
* - `date_template_hierarchy`
[43] Fix | Delete
* - `embed_template_hierarchy`
[44] Fix | Delete
* - `frontpage_template_hierarchy`
[45] Fix | Delete
* - `home_template_hierarchy`
[46] Fix | Delete
* - `index_template_hierarchy`
[47] Fix | Delete
* - `page_template_hierarchy`
[48] Fix | Delete
* - `paged_template_hierarchy`
[49] Fix | Delete
* - `privacypolicy_template_hierarchy`
[50] Fix | Delete
* - `search_template_hierarchy`
[51] Fix | Delete
* - `single_template_hierarchy`
[52] Fix | Delete
* - `singular_template_hierarchy`
[53] Fix | Delete
* - `tag_template_hierarchy`
[54] Fix | Delete
* - `taxonomy_template_hierarchy`
[55] Fix | Delete
*
[56] Fix | Delete
* @since 4.7.0
[57] Fix | Delete
*
[58] Fix | Delete
* @param string[] $templates A list of template candidates, in descending order of priority.
[59] Fix | Delete
*/
[60] Fix | Delete
$templates = apply_filters( "{$type}_template_hierarchy", $templates );
[61] Fix | Delete
[62] Fix | Delete
$template = locate_template( $templates );
[63] Fix | Delete
[64] Fix | Delete
$template = locate_block_template( $template, $type, $templates );
[65] Fix | Delete
[66] Fix | Delete
/**
[67] Fix | Delete
* Filters the path of the queried template by type.
[68] Fix | Delete
*
[69] Fix | Delete
* The dynamic portion of the hook name, `$type`, refers to the filename -- minus the file
[70] Fix | Delete
* extension and any non-alphanumeric characters delimiting words -- of the file to load.
[71] Fix | Delete
* This hook also applies to various types of files loaded as part of the Template Hierarchy.
[72] Fix | Delete
*
[73] Fix | Delete
* Possible hook names include:
[74] Fix | Delete
*
[75] Fix | Delete
* - `404_template`
[76] Fix | Delete
* - `archive_template`
[77] Fix | Delete
* - `attachment_template`
[78] Fix | Delete
* - `author_template`
[79] Fix | Delete
* - `category_template`
[80] Fix | Delete
* - `date_template`
[81] Fix | Delete
* - `embed_template`
[82] Fix | Delete
* - `frontpage_template`
[83] Fix | Delete
* - `home_template`
[84] Fix | Delete
* - `index_template`
[85] Fix | Delete
* - `page_template`
[86] Fix | Delete
* - `paged_template`
[87] Fix | Delete
* - `privacypolicy_template`
[88] Fix | Delete
* - `search_template`
[89] Fix | Delete
* - `single_template`
[90] Fix | Delete
* - `singular_template`
[91] Fix | Delete
* - `tag_template`
[92] Fix | Delete
* - `taxonomy_template`
[93] Fix | Delete
*
[94] Fix | Delete
* @since 1.5.0
[95] Fix | Delete
* @since 4.8.0 The `$type` and `$templates` parameters were added.
[96] Fix | Delete
*
[97] Fix | Delete
* @param string $template Path to the template. See locate_template().
[98] Fix | Delete
* @param string $type Sanitized filename without extension.
[99] Fix | Delete
* @param string[] $templates A list of template candidates, in descending order of priority.
[100] Fix | Delete
*/
[101] Fix | Delete
return apply_filters( "{$type}_template", $template, $type, $templates );
[102] Fix | Delete
}
[103] Fix | Delete
[104] Fix | Delete
/**
[105] Fix | Delete
* Retrieves path of index template in current or parent template.
[106] Fix | Delete
*
[107] Fix | Delete
* The template hierarchy and template path are filterable via the {@see '$type_template_hierarchy'}
[108] Fix | Delete
* and {@see '$type_template'} dynamic hooks, where `$type` is 'index'.
[109] Fix | Delete
*
[110] Fix | Delete
* @since 3.0.0
[111] Fix | Delete
*
[112] Fix | Delete
* @see get_query_template()
[113] Fix | Delete
*
[114] Fix | Delete
* @return string Full path to index template file.
[115] Fix | Delete
*/
[116] Fix | Delete
function get_index_template() {
[117] Fix | Delete
return get_query_template( 'index' );
[118] Fix | Delete
}
[119] Fix | Delete
[120] Fix | Delete
/**
[121] Fix | Delete
* Retrieves path of 404 template in current or parent template.
[122] Fix | Delete
*
[123] Fix | Delete
* The template hierarchy and template path are filterable via the {@see '$type_template_hierarchy'}
[124] Fix | Delete
* and {@see '$type_template'} dynamic hooks, where `$type` is '404'.
[125] Fix | Delete
*
[126] Fix | Delete
* @since 1.5.0
[127] Fix | Delete
*
[128] Fix | Delete
* @see get_query_template()
[129] Fix | Delete
*
[130] Fix | Delete
* @return string Full path to 404 template file.
[131] Fix | Delete
*/
[132] Fix | Delete
function get_404_template() {
[133] Fix | Delete
return get_query_template( '404' );
[134] Fix | Delete
}
[135] Fix | Delete
[136] Fix | Delete
/**
[137] Fix | Delete
* Retrieves path of archive template in current or parent template.
[138] Fix | Delete
*
[139] Fix | Delete
* The template hierarchy and template path are filterable via the {@see '$type_template_hierarchy'}
[140] Fix | Delete
* and {@see '$type_template'} dynamic hooks, where `$type` is 'archive'.
[141] Fix | Delete
*
[142] Fix | Delete
* @since 1.5.0
[143] Fix | Delete
*
[144] Fix | Delete
* @see get_query_template()
[145] Fix | Delete
*
[146] Fix | Delete
* @return string Full path to archive template file.
[147] Fix | Delete
*/
[148] Fix | Delete
function get_archive_template() {
[149] Fix | Delete
$post_types = array_filter( (array) get_query_var( 'post_type' ) );
[150] Fix | Delete
[151] Fix | Delete
$templates = array();
[152] Fix | Delete
[153] Fix | Delete
if ( count( $post_types ) === 1 ) {
[154] Fix | Delete
$post_type = reset( $post_types );
[155] Fix | Delete
$templates[] = "archive-{$post_type}.php";
[156] Fix | Delete
}
[157] Fix | Delete
$templates[] = 'archive.php';
[158] Fix | Delete
[159] Fix | Delete
return get_query_template( 'archive', $templates );
[160] Fix | Delete
}
[161] Fix | Delete
[162] Fix | Delete
/**
[163] Fix | Delete
* Retrieves path of post type archive template in current or parent template.
[164] Fix | Delete
*
[165] Fix | Delete
* The template hierarchy and template path are filterable via the {@see '$type_template_hierarchy'}
[166] Fix | Delete
* and {@see '$type_template'} dynamic hooks, where `$type` is 'archive'.
[167] Fix | Delete
*
[168] Fix | Delete
* @since 3.7.0
[169] Fix | Delete
*
[170] Fix | Delete
* @see get_archive_template()
[171] Fix | Delete
*
[172] Fix | Delete
* @return string Full path to archive template file.
[173] Fix | Delete
*/
[174] Fix | Delete
function get_post_type_archive_template() {
[175] Fix | Delete
$post_type = get_query_var( 'post_type' );
[176] Fix | Delete
if ( is_array( $post_type ) ) {
[177] Fix | Delete
$post_type = reset( $post_type );
[178] Fix | Delete
}
[179] Fix | Delete
[180] Fix | Delete
$obj = get_post_type_object( $post_type );
[181] Fix | Delete
if ( ! ( $obj instanceof WP_Post_Type ) || ! $obj->has_archive ) {
[182] Fix | Delete
return '';
[183] Fix | Delete
}
[184] Fix | Delete
[185] Fix | Delete
return get_archive_template();
[186] Fix | Delete
}
[187] Fix | Delete
[188] Fix | Delete
/**
[189] Fix | Delete
* Retrieves path of author template in current or parent template.
[190] Fix | Delete
*
[191] Fix | Delete
* The hierarchy for this template looks like:
[192] Fix | Delete
*
[193] Fix | Delete
* 1. author-{nicename}.php
[194] Fix | Delete
* 2. author-{id}.php
[195] Fix | Delete
* 3. author.php
[196] Fix | Delete
*
[197] Fix | Delete
* An example of this is:
[198] Fix | Delete
*
[199] Fix | Delete
* 1. author-john.php
[200] Fix | Delete
* 2. author-1.php
[201] Fix | Delete
* 3. author.php
[202] Fix | Delete
*
[203] Fix | Delete
* The template hierarchy and template path are filterable via the {@see '$type_template_hierarchy'}
[204] Fix | Delete
* and {@see '$type_template'} dynamic hooks, where `$type` is 'author'.
[205] Fix | Delete
*
[206] Fix | Delete
* @since 1.5.0
[207] Fix | Delete
*
[208] Fix | Delete
* @see get_query_template()
[209] Fix | Delete
*
[210] Fix | Delete
* @return string Full path to author template file.
[211] Fix | Delete
*/
[212] Fix | Delete
function get_author_template() {
[213] Fix | Delete
$author = get_queried_object();
[214] Fix | Delete
[215] Fix | Delete
$templates = array();
[216] Fix | Delete
[217] Fix | Delete
if ( $author instanceof WP_User ) {
[218] Fix | Delete
$templates[] = "author-{$author->user_nicename}.php";
[219] Fix | Delete
$templates[] = "author-{$author->ID}.php";
[220] Fix | Delete
}
[221] Fix | Delete
$templates[] = 'author.php';
[222] Fix | Delete
[223] Fix | Delete
return get_query_template( 'author', $templates );
[224] Fix | Delete
}
[225] Fix | Delete
[226] Fix | Delete
/**
[227] Fix | Delete
* Retrieves path of category template in current or parent template.
[228] Fix | Delete
*
[229] Fix | Delete
* The hierarchy for this template looks like:
[230] Fix | Delete
*
[231] Fix | Delete
* 1. category-{slug}.php
[232] Fix | Delete
* 2. category-{id}.php
[233] Fix | Delete
* 3. category.php
[234] Fix | Delete
*
[235] Fix | Delete
* An example of this is:
[236] Fix | Delete
*
[237] Fix | Delete
* 1. category-news.php
[238] Fix | Delete
* 2. category-2.php
[239] Fix | Delete
* 3. category.php
[240] Fix | Delete
*
[241] Fix | Delete
* The template hierarchy and template path are filterable via the {@see '$type_template_hierarchy'}
[242] Fix | Delete
* and {@see '$type_template'} dynamic hooks, where `$type` is 'category'.
[243] Fix | Delete
*
[244] Fix | Delete
* @since 1.5.0
[245] Fix | Delete
* @since 4.7.0 The decoded form of `category-{slug}.php` was added to the top of the
[246] Fix | Delete
* template hierarchy when the category slug contains multibyte characters.
[247] Fix | Delete
*
[248] Fix | Delete
* @see get_query_template()
[249] Fix | Delete
*
[250] Fix | Delete
* @return string Full path to category template file.
[251] Fix | Delete
*/
[252] Fix | Delete
function get_category_template() {
[253] Fix | Delete
$category = get_queried_object();
[254] Fix | Delete
[255] Fix | Delete
$templates = array();
[256] Fix | Delete
[257] Fix | Delete
if ( ! empty( $category->slug ) ) {
[258] Fix | Delete
[259] Fix | Delete
$slug_decoded = urldecode( $category->slug );
[260] Fix | Delete
if ( $slug_decoded !== $category->slug ) {
[261] Fix | Delete
$templates[] = "category-{$slug_decoded}.php";
[262] Fix | Delete
}
[263] Fix | Delete
[264] Fix | Delete
$templates[] = "category-{$category->slug}.php";
[265] Fix | Delete
$templates[] = "category-{$category->term_id}.php";
[266] Fix | Delete
}
[267] Fix | Delete
$templates[] = 'category.php';
[268] Fix | Delete
[269] Fix | Delete
return get_query_template( 'category', $templates );
[270] Fix | Delete
}
[271] Fix | Delete
[272] Fix | Delete
/**
[273] Fix | Delete
* Retrieves path of tag template in current or parent template.
[274] Fix | Delete
*
[275] Fix | Delete
* The hierarchy for this template looks like:
[276] Fix | Delete
*
[277] Fix | Delete
* 1. tag-{slug}.php
[278] Fix | Delete
* 2. tag-{id}.php
[279] Fix | Delete
* 3. tag.php
[280] Fix | Delete
*
[281] Fix | Delete
* An example of this is:
[282] Fix | Delete
*
[283] Fix | Delete
* 1. tag-wordpress.php
[284] Fix | Delete
* 2. tag-3.php
[285] Fix | Delete
* 3. tag.php
[286] Fix | Delete
*
[287] Fix | Delete
* The template hierarchy and template path are filterable via the {@see '$type_template_hierarchy'}
[288] Fix | Delete
* and {@see '$type_template'} dynamic hooks, where `$type` is 'tag'.
[289] Fix | Delete
*
[290] Fix | Delete
* @since 2.3.0
[291] Fix | Delete
* @since 4.7.0 The decoded form of `tag-{slug}.php` was added to the top of the
[292] Fix | Delete
* template hierarchy when the tag slug contains multibyte characters.
[293] Fix | Delete
*
[294] Fix | Delete
* @see get_query_template()
[295] Fix | Delete
*
[296] Fix | Delete
* @return string Full path to tag template file.
[297] Fix | Delete
*/
[298] Fix | Delete
function get_tag_template() {
[299] Fix | Delete
$tag = get_queried_object();
[300] Fix | Delete
[301] Fix | Delete
$templates = array();
[302] Fix | Delete
[303] Fix | Delete
if ( ! empty( $tag->slug ) ) {
[304] Fix | Delete
[305] Fix | Delete
$slug_decoded = urldecode( $tag->slug );
[306] Fix | Delete
if ( $slug_decoded !== $tag->slug ) {
[307] Fix | Delete
$templates[] = "tag-{$slug_decoded}.php";
[308] Fix | Delete
}
[309] Fix | Delete
[310] Fix | Delete
$templates[] = "tag-{$tag->slug}.php";
[311] Fix | Delete
$templates[] = "tag-{$tag->term_id}.php";
[312] Fix | Delete
}
[313] Fix | Delete
$templates[] = 'tag.php';
[314] Fix | Delete
[315] Fix | Delete
return get_query_template( 'tag', $templates );
[316] Fix | Delete
}
[317] Fix | Delete
[318] Fix | Delete
/**
[319] Fix | Delete
* Retrieves path of custom taxonomy term template in current or parent template.
[320] Fix | Delete
*
[321] Fix | Delete
* The hierarchy for this template looks like:
[322] Fix | Delete
*
[323] Fix | Delete
* 1. taxonomy-{taxonomy_slug}-{term_slug}.php
[324] Fix | Delete
* 2. taxonomy-{taxonomy_slug}.php
[325] Fix | Delete
* 3. taxonomy.php
[326] Fix | Delete
*
[327] Fix | Delete
* An example of this is:
[328] Fix | Delete
*
[329] Fix | Delete
* 1. taxonomy-location-texas.php
[330] Fix | Delete
* 2. taxonomy-location.php
[331] Fix | Delete
* 3. taxonomy.php
[332] Fix | Delete
*
[333] Fix | Delete
* The template hierarchy and template path are filterable via the {@see '$type_template_hierarchy'}
[334] Fix | Delete
* and {@see '$type_template'} dynamic hooks, where `$type` is 'taxonomy'.
[335] Fix | Delete
*
[336] Fix | Delete
* @since 2.5.0
[337] Fix | Delete
* @since 4.7.0 The decoded form of `taxonomy-{taxonomy_slug}-{term_slug}.php` was added to the top of the
[338] Fix | Delete
* template hierarchy when the term slug contains multibyte characters.
[339] Fix | Delete
*
[340] Fix | Delete
* @see get_query_template()
[341] Fix | Delete
*
[342] Fix | Delete
* @return string Full path to custom taxonomy term template file.
[343] Fix | Delete
*/
[344] Fix | Delete
function get_taxonomy_template() {
[345] Fix | Delete
$term = get_queried_object();
[346] Fix | Delete
[347] Fix | Delete
$templates = array();
[348] Fix | Delete
[349] Fix | Delete
if ( ! empty( $term->slug ) ) {
[350] Fix | Delete
$taxonomy = $term->taxonomy;
[351] Fix | Delete
[352] Fix | Delete
$slug_decoded = urldecode( $term->slug );
[353] Fix | Delete
if ( $slug_decoded !== $term->slug ) {
[354] Fix | Delete
$templates[] = "taxonomy-$taxonomy-{$slug_decoded}.php";
[355] Fix | Delete
}
[356] Fix | Delete
[357] Fix | Delete
$templates[] = "taxonomy-$taxonomy-{$term->slug}.php";
[358] Fix | Delete
$templates[] = "taxonomy-$taxonomy.php";
[359] Fix | Delete
}
[360] Fix | Delete
$templates[] = 'taxonomy.php';
[361] Fix | Delete
[362] Fix | Delete
return get_query_template( 'taxonomy', $templates );
[363] Fix | Delete
}
[364] Fix | Delete
[365] Fix | Delete
/**
[366] Fix | Delete
* Retrieves path of date template in current or parent template.
[367] Fix | Delete
*
[368] Fix | Delete
* The template hierarchy and template path are filterable via the {@see '$type_template_hierarchy'}
[369] Fix | Delete
* and {@see '$type_template'} dynamic hooks, where `$type` is 'date'.
[370] Fix | Delete
*
[371] Fix | Delete
* @since 1.5.0
[372] Fix | Delete
*
[373] Fix | Delete
* @see get_query_template()
[374] Fix | Delete
*
[375] Fix | Delete
* @return string Full path to date template file.
[376] Fix | Delete
*/
[377] Fix | Delete
function get_date_template() {
[378] Fix | Delete
return get_query_template( 'date' );
[379] Fix | Delete
}
[380] Fix | Delete
[381] Fix | Delete
/**
[382] Fix | Delete
* Retrieves path of home template in current or parent template.
[383] Fix | Delete
*
[384] Fix | Delete
* The template hierarchy and template path are filterable via the {@see '$type_template_hierarchy'}
[385] Fix | Delete
* and {@see '$type_template'} dynamic hooks, where `$type` is 'home'.
[386] Fix | Delete
*
[387] Fix | Delete
* @since 1.5.0
[388] Fix | Delete
*
[389] Fix | Delete
* @see get_query_template()
[390] Fix | Delete
*
[391] Fix | Delete
* @return string Full path to home template file.
[392] Fix | Delete
*/
[393] Fix | Delete
function get_home_template() {
[394] Fix | Delete
$templates = array( 'home.php', 'index.php' );
[395] Fix | Delete
[396] Fix | Delete
return get_query_template( 'home', $templates );
[397] Fix | Delete
}
[398] Fix | Delete
[399] Fix | Delete
/**
[400] Fix | Delete
* Retrieves path of front page template in current or parent template.
[401] Fix | Delete
*
[402] Fix | Delete
* The template hierarchy and template path are filterable via the {@see '$type_template_hierarchy'}
[403] Fix | Delete
* and {@see '$type_template'} dynamic hooks, where `$type` is 'frontpage'.
[404] Fix | Delete
*
[405] Fix | Delete
* @since 3.0.0
[406] Fix | Delete
*
[407] Fix | Delete
* @see get_query_template()
[408] Fix | Delete
*
[409] Fix | Delete
* @return string Full path to front page template file.
[410] Fix | Delete
*/
[411] Fix | Delete
function get_front_page_template() {
[412] Fix | Delete
$templates = array( 'front-page.php' );
[413] Fix | Delete
[414] Fix | Delete
return get_query_template( 'frontpage', $templates );
[415] Fix | Delete
}
[416] Fix | Delete
[417] Fix | Delete
/**
[418] Fix | Delete
* Retrieves path of Privacy Policy page template in current or parent template.
[419] Fix | Delete
*
[420] Fix | Delete
* The template hierarchy and template path are filterable via the {@see '$type_template_hierarchy'}
[421] Fix | Delete
* and {@see '$type_template'} dynamic hooks, where `$type` is 'privacypolicy'.
[422] Fix | Delete
*
[423] Fix | Delete
* @since 5.2.0
[424] Fix | Delete
*
[425] Fix | Delete
* @see get_query_template()
[426] Fix | Delete
*
[427] Fix | Delete
* @return string Full path to privacy policy template file.
[428] Fix | Delete
*/
[429] Fix | Delete
function get_privacy_policy_template() {
[430] Fix | Delete
$templates = array( 'privacy-policy.php' );
[431] Fix | Delete
[432] Fix | Delete
return get_query_template( 'privacypolicy', $templates );
[433] Fix | Delete
}
[434] Fix | Delete
[435] Fix | Delete
/**
[436] Fix | Delete
* Retrieves path of page template in current or parent template.
[437] Fix | Delete
*
[438] Fix | Delete
* Note: For block themes, use locate_block_template() function instead.
[439] Fix | Delete
*
[440] Fix | Delete
* The hierarchy for this template looks like:
[441] Fix | Delete
*
[442] Fix | Delete
* 1. {Page Template}.php
[443] Fix | Delete
* 2. page-{page_name}.php
[444] Fix | Delete
* 3. page-{id}.php
[445] Fix | Delete
* 4. page.php
[446] Fix | Delete
*
[447] Fix | Delete
* An example of this is:
[448] Fix | Delete
*
[449] Fix | Delete
* 1. page-templates/full-width.php
[450] Fix | Delete
* 2. page-about.php
[451] Fix | Delete
* 3. page-4.php
[452] Fix | Delete
* 4. page.php
[453] Fix | Delete
*
[454] Fix | Delete
* The template hierarchy and template path are filterable via the {@see '$type_template_hierarchy'}
[455] Fix | Delete
* and {@see '$type_template'} dynamic hooks, where `$type` is 'page'.
[456] Fix | Delete
*
[457] Fix | Delete
* @since 1.5.0
[458] Fix | Delete
* @since 4.7.0 The decoded form of `page-{page_name}.php` was added to the top of the
[459] Fix | Delete
* template hierarchy when the page name contains multibyte characters.
[460] Fix | Delete
*
[461] Fix | Delete
* @see get_query_template()
[462] Fix | Delete
*
[463] Fix | Delete
* @return string Full path to page template file.
[464] Fix | Delete
*/
[465] Fix | Delete
function get_page_template() {
[466] Fix | Delete
$id = get_queried_object_id();
[467] Fix | Delete
$template = get_page_template_slug();
[468] Fix | Delete
$pagename = get_query_var( 'pagename' );
[469] Fix | Delete
[470] Fix | Delete
if ( ! $pagename && $id ) {
[471] Fix | Delete
/*
[472] Fix | Delete
* If a static page is set as the front page, $pagename will not be set.
[473] Fix | Delete
* Retrieve it from the queried object.
[474] Fix | Delete
*/
[475] Fix | Delete
$post = get_queried_object();
[476] Fix | Delete
if ( $post ) {
[477] Fix | Delete
$pagename = $post->post_name;
[478] Fix | Delete
}
[479] Fix | Delete
}
[480] Fix | Delete
[481] Fix | Delete
$templates = array();
[482] Fix | Delete
if ( $template && 0 === validate_file( $template ) ) {
[483] Fix | Delete
$templates[] = $template;
[484] Fix | Delete
}
[485] Fix | Delete
if ( $pagename ) {
[486] Fix | Delete
$pagename_decoded = urldecode( $pagename );
[487] Fix | Delete
if ( $pagename_decoded !== $pagename ) {
[488] Fix | Delete
$templates[] = "page-{$pagename_decoded}.php";
[489] Fix | Delete
}
[490] Fix | Delete
$templates[] = "page-{$pagename}.php";
[491] Fix | Delete
}
[492] Fix | Delete
if ( $id ) {
[493] Fix | Delete
$templates[] = "page-{$id}.php";
[494] Fix | Delete
}
[495] Fix | Delete
$templates[] = 'page.php';
[496] Fix | Delete
[497] Fix | Delete
return get_query_template( 'page', $templates );
[498] Fix | Delete
}
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function