| | 115 | * Determines whether a template part exists. |
| | 116 | * |
| | 117 | * Checks the named template part for a theme or, if a name is specified, a |
| | 118 | * specialized part will be checked. If the theme contains no {slug}.php file |
| | 119 | * then this returns false. |
| | 120 | * |
| | 121 | * For the $name parameter, if the file is called "{slug}-special.php" then specify |
| | 122 | * "special". |
| | 123 | * |
| | 124 | * For more information on similar theme functions, check out |
| | 125 | * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ |
| | 126 | * Conditional Tags} article in the Theme Developer Handbook. |
| | 127 | * |
| | 128 | * @since 5.2.0 |
| | 129 | * |
| | 130 | * @param string $slug The slug name for the generic template. |
| | 131 | * @param string|null $name Optional. The name of the specialized template. Default null. |
| | 132 | * |
| | 133 | * @return bool Whether the template part exists. |
| | 134 | */ |
| | 135 | function has_template_part( $slug, $name = null ) { |
| | 136 | $templates = array(); |
| | 137 | $name = (string) $name; |
| | 138 | if ( '' !== $name ) { |
| | 139 | $templates[] = "{$slug}-{$name}.php"; |
| | 140 | } |
| | 141 | $templates[] = "{$slug}.php"; |
| | 142 | |
| | 143 | return (bool) locate_template( $templates, false, false ); |
| | 144 | } |
| | 145 | |
| | 146 | /** |