Giter Site home page Giter Site logo

luna's Introduction

LUNA CLI

Command-line interface for Base Camp theme.

Commands

Make Custom Post Type

This Command helps you to create a new Custom Post Type very fast.

php luna make:custom-post-type {name}

The argument is singular form. if noun have irregular plural which do not behave in standard way(singular+s), exception can be defined by plural option e.g.

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

The new file is created to /app/config/wp/custom-post-types/{name}.php

Make Custom Taxonomy

This Command helps you to create a new Custom Taxonomy very fast.

php luna make:custom-taxonomy {name}

The argument is singular form. if noun have irregular plural which do not behave in standard way(singular+s), exception can be defined by plural option e.g.

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

The new file is created to /app/config/wp/custom-taxonomies/{name}.php

Make Route

This Command helps you to create a new route for WordPress API clearer and faster way.

php luna make:route {name}

The new file is created to /app/config/wp/routes/{name}.php. The created file comes with the well documented boilerplate.

Make Shortcode

This Command helps you to create a new shortcode with very clean boilerplate.

php luna make:shortcode {name}

The new file is created to /app/config/wp/shortcodes/{name}.php.

Example

Run command:

php luna make:shortcode LuckyNumber

Then define some data

    /**
     * @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'];
    }

Now shortcode [lucky_number] generates This is my lucky number: 7 and [lucky_number number="13"] generates This is my lucky number: 13

It is also possible to use power of Timber. In template function you can return Timber view instead of string like this:

// 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);
}

Make Menu Page

This Command helps you to create a new Menu Page or Submenu Page to wp-admin navigation.

php luna make:menu-page {name}

This command will create a new MenuPage class in /app/config/wp/menu-pages/{name}.php. The generated file will include the Menu Page properties. Submenu Page could be created by:

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

A new SubMenuPage class will be generated in /app/config/wp/submenu-pages/{name}.php

luna's People

Contributors

suomato avatar vincentpeters avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

luna's Issues

register_rest_route was called incorrectly

in luna/src/Utils/Router.php
there is an error that causes this Notice

register_rest_route($route['namespace'] . '/', $route['base'], [

there is a malformed piece of code there.
The $route['namespace'] cannot end with a / so if we move it to the route parameter the Notice disappeares..

register_rest_route($route['namespace'], '/' . $route['base'], [

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.