PHP code example of dawidurbanski / sage-directives
1. Go to this page and download the library: Download dawidurbanski/sage-directives 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/ */
dawidurbanski / sage-directives example snippets
@query([
'post_type' => 'post'
])
@query([
'post_type' => 'post'
])
@posts
<h2 class="entry-title">@title</h2>
<div class="entry-content">
@content
</div>
@endposts
@php
$My_Query = new WP_Query([
'post_type' => 'post'
]);
@endphp
@posts($My_Query)
<h2 class="entry-title">@title</h2>
<div class="entry-content">
@content
</div>
@endposts
@title
@title(123)
@content
@excerpt
@shortcode('[my-shortcode]')
@user
You are logged in!
@enduser
@guest
You must be <a href="/wp-login.php">logged in</a> to view this content.
@endguest
@field('text')
@field('text', 123) // Returns the text field from post ID 123.
@field('image', 'url') // If image is an array, returns the url value.
@field('image', 'url', 123) // If image is an array, returns the url value for post ID 123.
@hasfield('list')
<ul>
@fields('list')
<li>@sub('item')</li>
@fields
</ul>
@endfield
@hasfield('image', 'url')
<figure class="image">
<img src="@field('image', 'url')" alt="@field('image', 'alt')" />
</figure>
@endfield
@isfield('cta_type', 'phone')
<i class="fa fa-phone"></i>
@endfield
@isfield('cta_type', 'phone', 123)
<i class="fa fa-phone"></i>
@endfield
<ul>
@fields('list')
<li>@sub('item')</li>
@endfields
</ul>
@fields('list', 123)
[...]
@endfields
<ul>
@fields('list')
<li>@sub('item')</li>
@endfields
</ul>
<ul class="slider">
@fields('slides')
<li class="slide">
<img src="@sub('image', 'url')" alt="@sub('image', 'alt')" />
</li>
@endfields
</ul>
@hassub('icon')
<i class="fa @sub('icon')"></i>
@endsub
@hassub('image', 'url')
<img src="@sub('image', 'url')" alt="@sub('image', 'alt')" />
@endsub
@issub('icon', 'arrow')
<i class="fa fa-arrow-up fa-rotate-90"></i>
@endsub
@layouts('components')
[...]
@endlayouts
@layouts('components', 123)
[...]
@endlayouts
@layouts('components')
@layout('card')
<div class="card">
@hassub('image')
<div class="card-image">
<img src="@sub('image', 'url')" alt="@sub('image', 'alt')" />
</div>
@endsub
<div class="card-content">
<h2>@sub('title')</h2>
@sub('description')
</div>
</div>
@endlayout
@layout('button')
@hassub('url')
<a href="@sub('url')" class="button button--@sub('color') button--@sub('size')">
@hassub('icon')
<i class="fa fa-@sub('icon')"></i>
@endsub
<span>@sub('label')</span>
</a>
@endsub
@endlayout
@layout('content')
@hassub('content')
<div class="content">
@sub('content')
</div>
@endsub
@endlayout
@endlayouts
@group('button')
@hassub('url')
<a href="@sub('url')" class="button button--@sub('color')">
@sub('label')
</a>
@endsub
@endgroup
Find us on <a href="@option('facebook_url')" target="_blank">Facebook</a>
<div class="navbar-brand">
<a class="navbar-item" href="{{ home_url() }}">
<img src="@option('logo', 'url')" alt="{{ get_bloginfo('name', 'display') }}" />
</a>
</div>
@hasoption('facebook_url')
Find us on <a href="@option('facebook_url')" target="_blank">Facebook</a>
@endoption
@isoption('logo_type', 'svg')
[...]
@endoption
@hasoption('social')
<ul class="social">
@options('social')
<li>
<a href="@sub('url')" target="_blank">
@hassub('icon')
<i class="icon fa-@sub('icon')"></i>
@endsub
<span>@sub('platform')</span>
</a>
</li>
@endoptions
</ul>
@endoption
@if ($phone = App::phone())
Call us at <a href="#">{{ App::phone() }}</a>
@endif
<a href="#" class="text @condition($phone, 'is-hidden-mobile')">
Visit our website
</a>
@global($post)
@set($hello, 'world')
@unset($hello)
// single.blade.php
@
'date' => true,
])
// entry-meta.blade.php
@extract([
'author' => $author ?? true,
'date' => $date ?? true
])
@if ($author)
[...]
@endif
@if ($date)
[...]
@endif
@implode(', ' ['dog', 'cat', 'mouse', 'snake'])
// dog, cat, mouse, snake