PHP code example of suomato / luna

1. Go to this page and download the library: Download suomato/luna 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/ */

    

suomato / luna example snippets


php luna make:custom-post-type person --plural=people

php luna make:custom-taxonomy country --plural=countries

php luna make:shortcode LuckyNumber

    /**
     * @var string Shortcode name
     */
    protected $shortcode = 'lucky_number';

    /**
     * @var array|string An associative array of attributes
     */
    protected $attributes = [
        'number' => 7,
    ];

    /**
     * Return template of shortcode
     *
     * @param $attr An associative array of attributes
     * @param $content Enclosed content
     *
     * @return mixed
     */
    protected function template($attr, $content)
    {
        return 'This is my lucky number: ' . $attr['number'];
    }

// resources/views/shortcodes/lucky-number.twig

<p>This is my lucky number: {{ number }}</p>

******************************************************************

// app/config/wp/shortcodes/LuckyNumber.php

protected function template($attr, $content)
{
    return \Timber::compile('shortcodes/lucky-number.twig', $attr);
}

php luna make:menu-page {name} --submenu