The core building block of the Flynt Framework.
Switch branches/tags
Clone or download
Qakulukiam feat(BuildConstructionPlan, Render): add before & after actions (#46)
Added before and after actions to BuildConstructionPlan and Render. We can use this for logging and performance monitoring (and maybe more) in the future.
Latest commit 19efd48 Jul 19, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github docs(README.md, .github): add community pages and add links in README ( Jun 19, 2017
lib feat(BuildConstructionPlan, Render): add before & after actions (#46) Jul 19, 2018
tests
.coveralls.yml ci(coveralls): add config Mar 21, 2017
.distignore
.editorconfig build(setup): initial commit Oct 31, 2016
.gitignore
.scrutinizer.yml
.styleci.yml
.travis.yml ci(travis): update php coveralls dependency and constrain version (#47) Jul 19, 2018
CHANGELOG.md
LICENSE.md docs(readme): add standard readme and license file Mar 24, 2017
README.md docs(README.md, .github): add community pages and add links in README ( Jun 19, 2017
composer.json
composer.lock feat(composer): add composer installers and type wordpress plugin Jan 12, 2017
flynt-core.php
humbug.json.dist
package.json chore(release): 1.0.0 Mar 27, 2017
phpcs.ruleset.xml style(PSR-2): change coding style to PSR-2 Mar 20, 2017
phpunit.xml.dist

README.md

flynt-core

standard-readme compliant Build Status Code Quality Coverage Status

The core building block of the Flynt Framework.

The Flynt Core WordPress plugin provides a small public interface, combined with several WordPress hooks, to achieve the main principles of the Flynt Framework.

Table of Contents

Background

This plugin essentially functions as a HTML generator with two key steps:

  1. Given a minimal configuration, the Flynt Core plugin creates a hierarchical plan for how the site will be constructed (the Construction Plan).
  2. The Construction Plan is parsed and rendered into HTML.

Each configuration passed to the plugin represents a single component. This configuration can also contain additional, nested component configurations, which are contained within "areas".

Install

To install via composer, run:

composer require flyntwp/flynt-core

Activate the plugin in the WordPress back-end and you're good to go.

Usage

Hello World

To see the simplest way of using Flynt Core, add the following code to your theme's functions.php:

$componentManager = Flynt\ComponentManager::getInstance();
$componentManager->registerComponent('HelloWorld');

add_filter('Flynt/renderComponent?name=HelloWorld', function () {
  return 'Hello, world!';
});

This defines a new component ('HelloWorld'), which when rendered, will output the text 'Hello, world!'.

To render the component, add the following code to your theme's index.php:

Flynt\echoHtmlFromConfig([
  'name' => 'HelloWorld'
]);

Initialize Default Settings

We recommend initializing the plugin's default settings. Do this by adding the following line of code to your theme's functions.php:

Flynt\initDefaults();

This will:

  • Implement the component structure.
  • Load component scripts.
  • Enable PHP file rendering.

This also adds the following hooks:

// Set the config path to './config'.
add_filter('Flynt/configPath', ['Flynt\Defaults', 'setConfigPath'], 999, 2);

// Parse `.json` config files.
add_filter('Flynt/configFileLoader', ['Flynt\Defaults', 'loadConfigFile'], 999, 3);

// Set the component path to `./Components`.
add_filter('Flynt/componentPath', ['Flynt\Defaults', 'setComponentPath'], 999, 2);

// Load ./Components/{$componentName}/functions.php from every registered component.
add_action('Flynt/registerComponent', ['Flynt\Defaults', 'loadFunctionsFile']);

// Render `./Components/{$componentName}/index.php` and make view helper functions `$data` and `$area` available (see explanation below).
add_filter('Flynt/renderComponent', ['Flynt\Defaults', 'renderComponent'], 999, 4);

With the 'Flynt/renderComponent' filter added above you can now use the following helper functions in your template files:

  • $data is used to access the component's data in the view template.
  • $area is used to include the HTML of an area's components into the components template itself.

You can read the full documentation here.

Maintainers

This project is maintained by bleech.

The main people in charge of this repo are:

Contribute

To contribute, please use GitHub issues. Pull requests are accepted. Please also take a moment to read the Contributing Guidelines and Code of Conduct.

If editing the README, please conform to the standard-readme specification.

License

MIT © bleech