Skip to content

Commit 1590520

Browse files
committed
readme update, autoload filters
1 parent 2fd131a commit 1590520

File tree

3 files changed

+21
-24
lines changed

3 files changed

+21
-24
lines changed

composer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
],
1212
"minimum-stability": "stable",
1313
"autoload": {
14-
"psr-4": {"NetteLatteEngine\\": "src/"}
14+
"psr-4": {"NetteLatteEngine\\": "src/"},
15+
"files": ["wp-latte.php"]
1516
},
1617
"require": {
1718
"latte/latte": "^2.5"

readme.md

+18-7
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,17 @@ PHP: 5.6.0+
99
License: GPLv2 or later
1010
License URI: http://www.gnu.org/licenses/gpl-2.0.html
1111

12-
## Usage
12+
## Instalation with Composer
13+
14+
1. Go to `wp-content/mu-plugins` folder and require wp-latte with `composer require mejta/wp-latte` command.
15+
1. Don't forget to load composer dependencies in your loader (e.g. `wp-content/mu-plugins/load.php`):
16+
17+
```php
18+
<?php // wp-content/mu-plugins/load.php
19+
require WPMU_PLUGIN_DIR . '/vendor/autoload.php';
20+
```
21+
22+
## Instalation with Git
1323

1424
1. Go to `wp-content/mu-plugins` folder and clone the repository with `git clone [email protected]:mejta/wp-latte.git` command.
1525
1. Go to plugin folder with `cd wp-latte`
@@ -21,6 +31,8 @@ License URI: http://www.gnu.org/licenses/gpl-2.0.html
2131
require WPMU_PLUGIN_DIR . '/wp-latte/wp-latte.php';
2232
```
2333

34+
## Usage
35+
2436
After plugin activation, you can use Nette Latte templates in your theme. Just use `.latte` file extension instead of `.php`. Template files with `.php` extension will continue to work, but that templates will have lower priority in template resolution.
2537

2638
There are limitations with `header.php` and `footer.php`. You should use instead `{php wp_head()}` and `{php wp_footer()}` macro inside layout file. If you need to use header.php and footer.php file (e.g. for WooCommerce plugin), leave that files blank.
@@ -30,15 +42,14 @@ If you want to have a fallback for a case when the plugin is not activated, add
3042
You can also define your custom filters and macros. Use the following code in your `functions.php` file.
3143

3244
```php
45+
<?php // wp-content/themes/my-theme/functions.php
3346
use NetteLatteEngine\NetteLatteEngine;
3447

35-
if (class_exists('NetteLatteEngine\NetteLatteEngine')) {
36-
// https://latte.nette.org/en/guide#toc-user-defined-macros
37-
NetteLatteEngine::addMacro('test', $start_php_code, $end_php_code);
48+
// https://latte.nette.org/en/guide#toc-user-defined-macros
49+
NetteLatteEngine::addMacro('test', $start_php_code, $end_php_code);
3850

39-
// https://latte.nette.org/en/guide#toc-custom-filters
40-
NetteLatteEngine::addFilter('test', $callback_function);
41-
}
51+
// https://latte.nette.org/en/guide#toc-custom-filters
52+
NetteLatteEngine::addFilter('test', $callback_function);
4253
```
4354

4455
If you want define custom post template, create a template file in theme root directory and put the comment block at the begining of the file like this:

wp-latte.php

+1-16
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,2 @@
11
<?php
2-
/*
3-
Plugin Name: Nette Latte Engine
4-
Description: Nette Latte template engine support for WordPress.
5-
Author: Daniel Mejta
6-
Version: 1.0.0
7-
Author URI: https://www.mejta.net
8-
*/
9-
10-
if (!function_exists('add_action')) {
11-
exit;
12-
}
13-
14-
if(!class_exists('NetteLatteEngine\NetteLatteEngine')) {
15-
require __DIR__ . '/vendor/autoload.php';
16-
NetteLatteEngine\NetteLatteEngine::initialize();
17-
}
2+
NetteLatteEngine\NetteLatteEngine::initialize();

0 commit comments

Comments
 (0)