inc2734 / wp-plugin-view-controller
Installs: 5 165
Dependents: 2
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: >=5.6
Requires (Dev)
README
Install
$ composer require inc2734/wp-plugin-view-controller
How to use
use Inc2734\WP_Plugin_View_Controller\Bootstrap;
$bootstrap = new Bootstrap(
[
'prefix' => 'prefix_',
'path' => __DIR__ . '/templates/',
]
);
$bootstrap->render( $slug, $name, $args );
Filter hooks
<prefix>view_args
/**
* @param array $args
* @var string $slug
* @var string $name
* @var array $vars
* @param array
*/
add_filter(
'<prefix>view_args',
function( $args ) {
return $args;
}
);
<prefix>view_render_definition
/**
* @param null|string $html
* @param string $slug
* @param string $name
* @param array $vars
* @return string
*/
add_filter(
'<prefix>view_render_definition',
function( $html, $slug, $name, $vars ) {
return 'YOUR HTML';
},
10,
4
);
<prefix>view_render
/**
* @param string $html
* @param string $slug
* @param string $name
* @param array $vars
* @return string
*/
add_filter(
'<prefix>view_render',
function( $html, $slug, $name, $vars ) {
return $html;
},
10,
4
);
Action hooks
<prefix>view_pre_render
/**
* @param array $args
* @var string $slug
* @var string $name
* @var array $vars
*/
add_action(
'<prefix>view_pre_render',
function( $args ) {
}
);
<prefix>view_post_render
/**
* @param array $args
* @var string $slug
* @var string $name
* @var array $vars
*/
add_action(
'<prefix>view_post_render',
function( $args ) {
}
);
<prefix>view_<slug>
/**
* @param string $name
* @param array $vars
*/
add_action(
'<prefix>view_<slug>',
function( $name, $vars ) {
?>
HTML
<?php
},
10,
2
);
<prefix>view_<slug>-<name>
/**
* @param array $vars
*/
add_action(
'<prefix>view_<slug>-<name>',
function( $vars ) {
?>
HTML
<?php
}
);