2017 © Pedro Pelรกez
 

library wp-view-controller

A library for WordPress theme view controller.

image

inc2734/wp-view-controller

A library for WordPress theme view controller.

  • Friday, July 27, 2018
  • by inc2734
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1,680 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 25 Versions
  • 21 % Grown

The README.md

WP View Controller

CILatest Stable Version License, (*1)

Install

$ composer require inc2734/wp-view-controller

How to use

<?php
// in functions.php
new Inc2734\WP_View_Controller\Bootstrap();
view(); ?>`.

## View templates

### In singular page

Loading `/templates/view/content-{post-type}.php` for the view template.
Loading `/templates/view/content.php` when `/templates/view/content-{post-type}.php` isn't exists.

### In archive page

Loading `/templates/view/archive-{post-type}.php` for the view template.
Loading `/templates/view/archive.php` when `/templates/view/archive-{post-type}.php` isn't exists.

### Static view templates

Tries to load the view template according to the URL. For example when URL is http://example.com/foo/bar, tries to laod from `/templates/static/foo/bar.php` or `/templates/static/foo/bar/index.php`.

## Using view controller

use Inc2734\WP_View_Controller\Bootstrap;, (*2)

Bootstrap::layout( 'right-sidebar' ); Bootstrap::render( 'content', 'news' );, (*3)


## Template tags ### \\Inc2734\\WP_View_Controller\\Helper::get_template_part() This method is an extension to `get_template_part()`. ## Filter hooks ### inc2734_wp_view_controller_config_path

/** * Change config path * * @param string $path * @return string $path */ add_filter( 'inc2734_wp_view_controller_config_path', function( $path ) { return $path; } );, (*4)


### inc2734_wp_view_controller_pre_template_part_render

/** * Define and return the content before loading the template. * If a string is returned, the template will not load. * * @param null $html * @param string $slug * @param string $name * @param array $vars * @return string */ add_filter( 'inc2734_wp_view_controller_pre_template_part_render', function( $html, $slug, $name, $vars ) { return $html; }, 10, 4 );, (*5)


### inc2734_wp_view_controller_template_part_render

/** * Customize the rendered HTML * * @param string $html * @param string $slug * @param string $name * @param array $vars * @return string */ add_filter( 'inc2734_wp_view_controller_template_part_render', function( $html, $slug, $name, $vars ) { return $html; }, 10, 4 );, (*6)


### inc2734_wp_view_controller_layout

/** * Change layout file * * @param string $layout The layout file template slug * @return string */ add_filter( 'inc2734_wp_view_controller_layout', function( $layout ) { return $layout; } );, (*7)


### inc2734_wp_view_controller_view

/** * Change view file * * @param string $view The view file template slug * @return string */ add_filter( 'inc2734_wp_view_controller_view', function( $view ) { return $view; } );, (*8)


### inc2734_wp_view_controller_config

/** * Customize config values * * @param array $values * @return array */ add_filter( 'inc2734_wp_view_controller_config', function( $values ) { return $values; } );, (*9)


### inc2734_wp_view_controller_controller

/** * Change controller * * @param string $template * @return string */ add_filter( 'inc2734_wp_view_controller_controller', function( $template ) { return $template; } );, (*10)


### inc2734_wp_view_controller_get_template_part_args

/** * Customize template part args * * @param array $args * @var string $slug * @var string $name * @var array $vars * @return array */ add_filter( 'inc2734_wp_view_controller_get_template_part_args', function( $args ) { return $args; } );, (*11)


### inc2734_wp_view_controller_template_part_root_hierarchy

/** * Customize root hierarchy * * @param array $hierarchy * @param string $slug * @param string $name * @param array $vars * @return array */ add_filter( 'inc2734_wp_view_controller_template_part_root_hierarchy', function( $hierarchy, $slug, $name, $vars ) { return $hierarchy; }, 10, 4 );, (*12)


### inc2734_wp_view_controller_located_template_slug_fallback

/** * You can specify a template for fallback * * @param string|null $fallback_slug * @param array $relative_dir_paths * @param string $slug * @param string $name * @return string|null */ add_filter( 'inc2734_wp_view_controller_located_template_slug_fallback', function( $fallback_slug, $relative_dir_paths, $slug, $name ) { return $fallback_slug; }, 10, 4 );, (*13)


### inc2734_wp_view_controller_render_type

/** * Change rendered type. * * loop ... Loading in the WordPress loop * direct ... Simply loading * * @param string $render_type loop or direct * @return string */ add_filter( 'inc2734_wp_view_controller_render_type', function( $render_type ) { return $render_type; } );, (*14)


## Action hooks ### inc2734_wp_view_controller_get_template_part_&lt;slug&gt;-&lt;name&gt;

/** * Define template * * @deprecated * * @param array $vars * @return void */ add_action( 'inc2734_wp_view_controller_get_template_part_-', function( $vars ) { ?> HTML <?php } );, (*15)


### inc2734_wp_view_controller_get_template_part_&lt;slug&gt;

/** * Define template * * @deprecated * * @param string $name * @param array $vars * @return void */ add_action( 'inc2734_wp_view_controller_get_template_part_', function( $name, $vars ) { ?> HTML <?php }, 10, 2 );, (*16)


### inc2734_wp_view_controller_get_template_part_pre_render

/** * Fire before template rendering * * @param array $args */ add_action( 'inc2734_wp_view_controller_get_template_part_pre_render', function( $args ) { // Do something } );, (*17)


### inc2734_wp_view_controller_get_template_part_post_render

/** * Fire after template rendering * * @param array $args */ add_action( 'inc2734_wp_view_controller_get_template_part_post_render', function( $args ) { // Do something } ); ```, (*18)

The Versions

08/07 2018

5.0.0

5.0.0.0

A library for WordPress theme view controller.

  Sources   Download

GPL-2.0-or-later

The Requires

  • php >=5.6

 

The Development Requires

25/04 2018

4.0.6

4.0.6.0

A library for WordPress theme view controller.

  Sources   Download

GPL-2.0-or-later

The Requires

  • php >=5.6

 

The Development Requires

04/03 2018

4.0.5

4.0.5.0

A library for WordPress theme view controller.

  Sources   Download

GPL-2.0-or-later

The Requires

  • php >=5.6

 

The Development Requires

04/03 2018

4.0.4

4.0.4.0

A library for WordPress theme view controller.

  Sources   Download

GPL-2.0-or-later

The Requires

  • php >=5.6

 

The Development Requires

14/02 2018

4.0.3

4.0.3.0

A library for WordPress theme view controller.

  Sources   Download

GPL-2.0-or-later

The Requires

  • php >=5.6

 

The Development Requires

14/02 2018

4.0.2

4.0.2.0

A library for WordPress theme view controller.

  Sources   Download

GPL-2.0-or-later

The Requires

  • php >=5.6

 

The Development Requires

28/01 2018

4.0.1

4.0.1.0

A library for WordPress theme view controller.

  Sources   Download

GPL-2.0-or-later

The Requires

  • php >=5.6

 

The Development Requires

28/01 2018

4.0.0

4.0.0.0

A library for WordPress theme view controller.

  Sources   Download

GPL-2.0-or-later

The Requires

  • php >=5.6

 

The Development Requires

27/12 2017

3.0.0

3.0.0.0

A library for WordPress theme view controller.

  Sources   Download

GPL-2.0+

The Requires

  • php >=5.6

 

The Development Requires

12/10 2017

2.2.0

2.2.0.0

A library for WordPress theme view controller.

  Sources   Download

GPL-2.0+

The Requires

  • php >=5.6

 

The Development Requires

30/09 2017

2.1.4

2.1.4.0

A library for WordPress theme view controller.

  Sources   Download

GPL-2.0+

The Requires

  • php >=5.6

 

The Development Requires

30/08 2017

2.1.3

2.1.3.0

A library for WordPress theme view controller.

  Sources   Download

GPL-2.0+

The Requires

  • php >=5.6

 

The Development Requires

01/08 2017

2.1.2

2.1.2.0

A library for WordPress theme view controller.

  Sources   Download

GPL-2.0+

The Requires

  • php >=5.6

 

The Development Requires

31/07 2017

2.1.1

2.1.1.0

A library for WordPress theme view controller.

  Sources   Download

GPL-2.0+

The Requires

  • php >=5.6

 

The Development Requires

30/07 2017

2.1.0

2.1.0.0

A library for WordPress theme view controller.

  Sources   Download

GPL-2.0+

The Requires

  • php >=5.6

 

The Development Requires

30/07 2017

2.0.0

2.0.0.0

A library for WordPress theme view controller.

  Sources   Download

GPL-2.0+

The Requires

  • php >=5.6

 

The Development Requires

28/07 2017

1.0.0

1.0.0.0

A library for WordPress theme view controller.

  Sources   Download

GPL-2.0+

The Requires

  • php >=5.6

 

The Development Requires

23/07 2017

0.1.4

0.1.4.0

A library for WordPress theme view controller.

  Sources   Download

GPL-2.0+

The Requires

  • php >=5.6

 

The Development Requires

16/07 2017

0.1.3

0.1.3.0

A library for WordPress theme view controller.

  Sources   Download

GPL-2.0+

The Requires

  • php >=5.6

 

The Development Requires

02/07 2017

0.1.2

0.1.2.0

A library for WordPress theme view controller.

  Sources   Download

GPL-2.0+

The Requires

  • php >=5.6

 

The Development Requires

29/06 2017

dev-develop

dev-develop

A library for WordPress theme view controller.

  Sources   Download

GPL-2.0+

The Requires

  • php >=5.6

 

The Development Requires

29/06 2017

0.1.1

0.1.1.0

A library for WordPress theme view controller.

  Sources   Download

GPL-2.0+

The Requires

  • php >=5.6

 

The Development Requires

16/06 2017

0.1.0

0.1.0.0

A library for WordPress theme view controller.

  Sources   Download

GPL-2.0+

The Requires

  • php >=5.3

 

The Development Requires