2017 © Pedro Peláez
 

library iguana-theme

image

dxw/iguana-theme

  • Friday, August 4, 2017
  • by tomdxw
  • Repository
  • 7 Watchers
  • 0 Stars
  • 4,626 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 4 Versions
  • 6 % Grown

The README.md

iguana-theme

Helper functions and template layouts for iguana-based themes., (*1)

\Dxw\Iguana\Theme\Helpers

Helper functions., (*2)

Installation

Add the following to app/di.php:, (*3)

$registrar->addInstance(new \Dxw\Iguana\Theme\Helpers());

Usage

Your classes can declare helper functions:, (*4)

helpers = $helpers;        
    }

    public function register()
    {
        $this->helpers->registerFunction('myFunc', [$this, 'myFunc']);
    }

    public function myFunc($a)
    {
        echo esc_html($a + 1);
    }
}
```

To call this function from a template:

```
myFunc(4) ?>

Using h() means that you only need to pollute the global namespace with one function. And h() is a lot shorter than typing out the full namespace., (*5)

All you need to do is pass the Helpers instance to your class during instantiation. Example:, (*6)

$registrar->addInstance(new \Dxw\MyTheme\MyClass(
    $registrar->getInstance(\Dxw\Iguana\Theme\Helpers::class)
));

\Dxw\Iguana\Theme\Layout and \Dxw\Iguana\Theme\LayoutRegister

Layout templates., (*7)

Installation

Add the following to app/di.php:, (*8)

$registrar->addInstance(new \Dxw\Iguana\Theme\Helpers());
$registrar->addInstance(new \Dxw\Iguana\Theme\LayoutRegister(
    $registrar->getInstance(\Dxw\Iguana\Theme\Helpers::class)
));

Usage

Add something like this to layouts/main.php (within your theme directory):, (*9)

<!doctype html>
<html>
  <head>
    ...
  </head>
  <body>
    <?php h()->w_requested_template() ?>
  </body>
</html>

And remove the calls to get_header()/get_footer() from all your templates., (*10)

Licence

MIT, (*11)

The Versions

04/08 2017
04/08 2017

dev-fix/register-helpers-in-register

dev-fix/register-helpers-in-register https://github.com/dxw/iguana-theme

  Sources   Download

MIT

The Requires

 

The Development Requires

08/07 2016

dev-feature/singleton-fix

dev-feature/singleton-fix https://github.com/dxw/iguana-theme

  Sources   Download

MIT

The Requires

 

The Development Requires

23/05 2016

v1.0.0

1.0.0.0 https://github.com/dxw/iguana-theme

  Sources   Download

MIT

The Requires

 

The Development Requires