A Wordpress Plugin allowing the usage of PlatesPHP in themes. I got frustrated with WordPress' use of get_header()
and get_footer()
and having my IDE tell me I had unclosed / extraneous html tags. I prefer nesting my templates rather than progressively building the template, like how Wordpress does.
This plugin works fine with normal themes and will not disrupt those themes. However, it really shines when writing themes because it allows for conventional type code, such as what you find in most MVC frameworks.
layouts/application.php
<!DOCTYPE html>
<html>
<head>
<title><?php wp_title() ?></title>
<?php wp_head() ?>
</head>
<body>
<?= $this->section("content") ?>
<?php wp_footer() ?>
</body>
</html>
single.php
<?php // this replaces 'get_header();' and 'get_footer();' ?>
<?php $this->layout("layouts/application") ?>
<!-- content body -->
<!-- the following replaces `<?= $this->section("content") ?>` when rendered -->
<?php if( have_posts() ): while( have_posts() ): the_post(); ?>
<h2><?php the_title() ?></h2>
<?php the_content() ?>
<?php endwhile; endif; ?>
- I eventually plan to add more providers for common templating libraries, such as Twig
- Testcases to make sure it doesn't interfere with default themes
Huge shoutout to @reinink for the league/plates package, and to @philipobenito for the league/container package.
Use those packages. :) Seriously. The League is Awesome.