Download the PHP package morningtrain/wp-view without Composer
On this page you can find all versions of the php package morningtrain/wp-view. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download morningtrain/wp-view
More information about morningtrain/wp-view
Files in morningtrain/wp-view
Package wp-view
Short Description Laravel views and blade for WordPress
License MIT
Informations about the package wp-view
Views
Laravel blade and view for WordPress with custom directives.
Table of Contents
- Introduction
- Getting Started
- Installation
- Dependencies
- illuminate/view
- morningtrain/php-loader
- Usage
- View directory
- Render a view
- Working with namespaces
- Registering a namespace
- Using a namespace
- Custom @directives
- @wpauth()
- @header()
- @footer()
- @script()
- @style()
- @username()
- @cache()
- @react()
- Credits
- License
Introduction
Getting Started
To get started install the package as described below in Installation.
To use the tool have a look at Usage
Installation
Install with composer
Dependencies
illuminate/view
morningtrain/php-loader
PHP Loader is used to load and initialize all Hooks
Usage
For an overview see the official Laravel documentation
View directory
To set the main directory for views
Render a view
Working with namespaces
You may register a namespaced for a set of views. This is especially useful when writing plugins as you may group all
your plugin views and not worry about duplicate naming. Views in a namespace may be overwritten in the main namespace as
long as you use first()
instead of render()
.
Eg. View::first(['vendor/myPlugin/myview','myPlugin::myview])
will render from the vendor dir first if the view
exists, thereby allowing theme authors to overwrite this view when necessary.
Registering a namespace
Using a namespace
Custom @directives
This package contains some custom blade directives that you may use:
@wpauth()
@header()
Acts the same as : https://developer.wordpress.org/reference/functions/get_header/
The following will render the header.blade.php
view or header-small.blade.php
@footer()
Acts the same as : https://developer.wordpress.org/reference/functions/get_footer/
The following will render the footer.blade.php
view or footer-dark.blade.php
@script()
An easy way to enqueue an already registered script.
Using this directive is the same as calling wp_enqueue_script()
with only the handle.
@style()
An easy way to enqueue an already registered stylesheet.
Using this directive is the same as calling wp_enqueue_style()
with only the handle.
@username()
Prints the username of the currently logged in user or an empty string if no one is logged in.
@cache()
Caches content in a transient and uses the cached data if it exists
@react()
Prints a Morningtrain ReactRenderer compatible element with optional props. This makes it easy to prepare components for react to handle in the client.
The @react directive also supports a child view that will be rendered inside the component-wrapper until the react component is rendered. This is especially useful for skeletons and to avoid popping ins.
Credits
- Mathias Munk
- Martin Schadegg Brønniche
- All Contributors
License
The MIT License (MIT). Please see License File for more information.