Reveal the theme template file used to render the displayed page, via the admin bar, footer, widget, shortcode, and/or template tag.
Designers and developers know that it can sometimes be confusing and frustrating to determine the exact template being utilized to render the currently displayed page in WordPress. Sometimes page or category specific templates exist, or a page/post has been set by the post author to use a particular template, or the current theme doesn’t employ certain templates causing WordPress to fall back to others.
This plugin relieves that aggravation by assisting designers and developers by displaying the template being used to render the currently displayed page in WordPress. This can be shown in one or more of the following methods:
By default, the theme-relative path to the theme template file used to render the page is shown in the admin bar. The settings page for the plugin, at ‘Design’ -> ‘Reveal Template’, allows you to control and configure this particular method. Note: even if enabled by the setting, the admin bar entry also only appears if the admin bar is showing and if the user has the ability to see the revealed template.
By default, the theme-relative path to the theme template file used to render the page is shown in the site’s footer. The settings page for the plugin, at ‘Design’ -> ‘Reveal Template’, allows you to control and configure this particular method. Note: even if enabled by the setting, the footer output only appears if the theme follows the recommended practice of calling the wp_footer()
template tag at some point and the user has the ability to see the revealed template.
A widget named “Reveal Template” is made available which can be used to display the theme template file used to render the page in any widget location.
A shortcode called ‘revealtemplate’ is made available which can be used in post/page content to display the theme template file used to render the page. Currently it supports two possible attributes:
Examples: [revealtemplate type="absolute"]
, [revealtemplate type="filename" admin="0"]
A template tag is also provided which can be used to display the theme template file used to render the page.
<?php c2c_reveal_template(); ?>
By default, c2c_reveal_template()
will echo the template name. To simply retrieve the template filename rather than displaying it:
<?php $template = c2c_reveal_template( false ); ?>
The template tag also takes a second argument which be can be one of the following: absolute, relative, theme-relative, filename. This determines the path style you’d like reported. If not specified, it uses the default defined in the plugin’s settings page.
Examples of path types:
This plugin is primarily intended to be activated on an as-needed basis.
Links: Plugin Homepage | Plugin Directory Page | GitHub | Author Homepage
The plugin provides one template tag for use in your theme templates, functions.php, or plugins.
<?php function c2c_reveal_template( $echo = true, $template_path_type = '' ) ?>
$echo
(bool)
Optional. Echo the template info? Default is true.
$template_path_type
(string)
Optional. The style of the template’s path for return. Accepts: ‘absolute’, ‘relative’, ‘theme-relative’, ‘filename’. Default is ”, which causes the function to use the template path type configured via the plugin’s settings page.
<?php //Output the current template
c2c_reveal_template( true, 'theme-relative' );
?>
<?php // Retrieve the value for use in code, so don't display/echo it.
$current_template = c2c_reveal_template( false, 'filename' );
if ( $current_template == 'category-12.php' ) {
// Do something here
}
?>
/wp-content/plugins/
).Highlights:
This minor release updates the plugin framework, notes compatibility through WP 5.8+, and reorganizes unit tests.
Details:
'admin_enqueue_scripts'
action instead of during 'init'
is_plugin_admin_page()
in help_tabs()
instead of reproducing its functionalityis_plugin_admin_page()
is used before 'admin_init'
action is firedis_plugin_admin_page()
to use get_current_screen()
when availablestyle
tagtests/
into tests/phpunit/tests/
tests/bootstrap.php
to tests/phpunit/
bin/
into phpunit/
phpunit.xml
to phpunit.xml.dist
per best practicesHighlights:
Details:
c2c_{PluginName}_Plugin_051
to c2c_Plugin_060
get_c2c_string()
as a getter for translated stringsget_c2c_string()
whitelist_options()
to allowed_options()
add_allowed_options()
instead of deprecated add_option_whitelist()
for WP 5.5+allowed_options
filter instead of deprecated whitelist_options
for WP 5.5+is_wp_version_cmp()
and get_c2c_string()
)is_wp_version_cmp()
as a utility to compare current WP version against a given WP versioncontextual_help()
to be easier to read, and correct function docblocksnumber_format_i18n()
to format integer value within input fieldreadme_url()
to refer to plugin’s readme.txt on plugins.svn.wordpress.orgFull changelog is available in CHANGELOG.md.