diff --git a/templates/404.php b/404.php similarity index 56% rename from templates/404.php rename to 404.php index d2f1da848..aa692bc64 100644 --- a/templates/404.php +++ b/404.php @@ -4,4 +4,4 @@ $context = Timber::get_context(); -Timber::render('twig/404.twig', $context); +Timber::render('templates/404.twig', $context); diff --git a/README.md b/README.md index 9898ea9e4..335e92551 100644 --- a/README.md +++ b/README.md @@ -71,13 +71,13 @@ For organisation, `./inc` has three subfolders. We recommend using these three f After the files from './lib' and './inc' are loaded, all [components](#components) from the `./Components` folder are loaded. ### Page Templates -All template files can be found in the `./templates` directory. Flynt uses [Timber](https://www.upstatement.com/timber/) to structure its page templates and [Twig](https://twig.symfony.com/) for rendering them. [Timber's documentation](https://timber.github.io/docs/) is extensive and up to date, so be sure to get familiar with it. +Flynt uses [Timber](https://www.upstatement.com/timber/) to structure its page templates and [Twig](https://twig.symfony.com/) for rendering them. [Timber's documentation](https://timber.github.io/docs/) is extensive and up to date, so be sure to get familiar with it. There are two Twig functions added in Flynt to render components into templates: -* `renderComponent(componentName, data)` renders a single component. [For example, in the `index.twig` template](https://github.com/flyntwp/flynt/tree/master/templates/twig/index.twig). -* `renderFlexibleContent(flexibleContentField)` renders all components passed from an Advanced Custom Fields *Flexible Content* field. [For example, in the `single.twig` template.](https://github.com/flyntwp/flynt/tree/master/templates/twig/single.twig) +* `renderComponent(componentName, data)` renders a single component. [For example, in the `index.twig` template](https://github.com/flyntwp/flynt/tree/master/templates/index.twig). +* `renderFlexibleContent(flexibleContentField)` renders all components passed from an Advanced Custom Fields *Flexible Content* field. [For example, in the `single.twig` template.](https://github.com/flyntwp/flynt/tree/master/templates/single.twig) -Besides the main document structure (in `./templates/twig/_document.twig`), everything else is a component. +Besides the main document structure (in `./templates/_document.twig`), everything else is a component. ### Components A component is a self-contained building-block. Each component contains its own layout, its ACF fields, PHP logic, scripts, and styles. @@ -275,7 +275,7 @@ Flynt includes several utility functions for creating Advanced Custom Fields opt ### WPML -If you are using Flynt and [WPML](https://wpml.org/), you will need to create a Must-Use (MU) Plugin in order to load Twig from Timber before the WPML code is executed. This is because WPML includes an outdated version of Twig. +If you are using Flynt and [WPML](https://wpml.org/), you will need to create a Must-Use (MU) Plugin in order to load Twig from Timber before the WPML code is executed. This is because WPML includes an outdated version of Twig. To do this, create `/wp-content/mu-plugins/flynt-wpml-compat.php` and add this code: diff --git a/templates/basestyle.php b/basestyle.php similarity index 92% rename from templates/basestyle.php rename to basestyle.php index ac9582bdb..6b9fa8cea 100644 --- a/templates/basestyle.php +++ b/basestyle.php @@ -24,4 +24,4 @@ $context = Timber::get_context(); -Timber::render('twig/basestyle.twig', $context); +Timber::render('templates/basestyle.twig', $context); diff --git a/build-config.js b/build-config.js index 854709d82..5ec743b75 100644 --- a/build-config.js +++ b/build-config.js @@ -33,6 +33,7 @@ module.exports = { reloadDebounce: 1000, ui: false, files: [ + '*.php', 'templates/**/*', 'lib/**/*', 'inc/**/*', diff --git a/functions.php b/functions.php index ba3c130af..25ee41468 100644 --- a/functions.php +++ b/functions.php @@ -10,12 +10,6 @@ define('WP_ENV', 'production'); } -// This needs to happen first. -// Reason: In case the theme was just activated and the plugin is not active, -// we still need to run the after_switch_theme action, which is -// defined here. -Init::setTemplateDirectory(); - // Check if the required plugins are installed and activated. // If they aren't, this function redirects the template rendering to use // plugin-inactive.php instead and shows a warning in the admin backend. diff --git a/inc/baseStyle.php b/inc/baseStyle.php index fe23e2577..74f79234b 100644 --- a/inc/baseStyle.php +++ b/inc/baseStyle.php @@ -1,7 +1,7 @@ query_vars['BaseStyle'])) { - return get_template_directory() . '/templates/basestyle.php'; + return get_template_directory() . '/basestyle.php'; } return $template; diff --git a/inc/theContentFix.php b/inc/theContentFix.php index 635279b91..bd7710760 100644 --- a/inc/theContentFix.php +++ b/inc/theContentFix.php @@ -17,5 +17,5 @@ $postId = $attrs['id']; $context = Timber::get_context(); $context['post'] = $post = new Post($postId); - return Timber::fetch('templates/twig/theContentFix.twig', $context); + return Timber::fetch('templates/theContentFix.twig', $context); }); diff --git a/index.php b/index.php index 5509d4ce4..132cf9b70 100644 --- a/index.php +++ b/index.php @@ -1,7 +1,15 @@ diff --git a/templates/index.php b/templates/index.php deleted file mode 100644 index d9848b777..000000000 --- a/templates/index.php +++ /dev/null @@ -1,15 +0,0 @@ - diff --git a/templates/twig/theContentFix.twig b/templates/theContentFix.twig similarity index 100% rename from templates/twig/theContentFix.twig rename to templates/theContentFix.twig