Skip to content

kkeiper1103/plates-for-wordpress

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Plates for Wordpress

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.

Basic Example:

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; ?>

TODO

  • 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

Miscellaneous

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.

About

A WordPress Plugin for using Template Inheritance rather than Progressive Composition

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages