pages/
directory,
.php
file extension
plugin_page()
should be used. Our Example plugin will create a page named foo.php
, which can then be accessed via plugin_page.php?page=Example/foo
:
Example/pages/foo.php
<?php
layout_page_header();
layout_page_begin();
?>
<p>
Here is a link to <a href="<?php echo plugin_page( 'foo' ) ?>">page foo</a>.
</p>
<?php
layout_page_end();
Note
layout_page_begin()
and layout_page_end()
trigger the standard MantisBT header and footer portions, respectively, which also displays things such as the menus and triggers other layout-related events. layout_page_header()
pulls in the CSS classes for alternating row colors in the table, amongst other things.
files/
directory, the path to this directory can be retrieved by plugin_file_path()
function. The file's URI is generated with the plugin_file()
function.
Example/files/foo.css
p.foo {
color: red;
}
Example/pages/foo.php
...
<link
rel="stylesheet"
type="text/css"
href="<?php echo plugin_file( 'foo.css' ) ?>"
/>
<p class="foo">
Our custom stylesheet paints this text red.
</p>
Note
plugin_page()
expects only the page's name without the extension, plugin_file()
on the other hand requires the entire filename, so that it can distinguish e.g. between foo.css
and a potential image file called foo.png
.
Example/ Example.php pages/ foo.php files/ foo.css