PHP code example of morningtrain / wp-view
1. Go to this page and download the library: Download morningtrain/wp-view library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
morningtrain / wp-view example snippets
\Morningtrain\WP\View\View::setup(__DIR__ . "/resources/views");
echo \Morningtrain\WP\View\View::render('person',['name' => 'John','email' => '[email protected] ']);
echo \Morningtrain\WP\View\View::addNamespace('myPlugin', __DIR__ . "/resources/views");
echo \Morningtrain\WP\View\View::render('myPlugin::person',['name' => 'John','email' => '[email protected] ']);
<div>
@wpauth()
Hello @username!
@else
<a>Login</a>
@endwpauth
</div>
@header()
@header('small')
@footer()
@footer('dark')
@script('swiper')
<section id="my-cool-slider">
...
</section>
@style('employees')
<section id="employees" class="employees list">
...
</section>
<div>
<h3>Cache test for post: {!! $postId !!}</h3>
@if(!empty($postId))
@cache("post_card_{$postId}")
<aside @class(['post-card', "post-card__".get_post_type($postId)])>
<h3>{!! get_the_title($postId) !!}</h3>
<p>{{ get_the_excerpt($postId) }}</p>
<span>Yes</span>
<a href="{!! get_permalink($postId) !!}">{{__('Read more','domain')}}</a>
</aside>
@endcache
@else
<p>{{__('This is not a post','domain')}}</p>
@endif
</div>
@react('myComponent', [
'someData' => 'someValue'
])
@react('myComponent', [
'someData' => 'someValue'
],
'my-skeleton-view'),
['skeletonProp' => 'skeletonValue']