From 57b2d29b98b20cfc7e302a0cad771418c69f10ae Mon Sep 17 00:00:00 2001 From: Toni Suomalainen Date: Sun, 1 Jul 2018 14:03:41 +0300 Subject: [PATCH] updated docs and fixed small typos --- README.md | 118 +++++++++++++++++- composer.json | 2 +- composer.lock | 217 +++++---------------------------- src/Luna.php | 2 +- src/templates/menu-page.php | 7 +- src/templates/submenu-page.php | 5 +- 6 files changed, 161 insertions(+), 190 deletions(-) diff --git a/README.md b/README.md index dc54e4a..7b14b46 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,118 @@ # LUNA CLI -> Command-line interface for Base Camp theme. \ No newline at end of file +> Command-line interface for Base Camp theme. + +## Commands + +* [Make Custom Post Type](#make-custom-post-type) +* [Make Route](#make-route) +* [Make Shortcode](#make-shortcode) +* [Make Menu Page](#make-menu-page) + +#### 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 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 + +

This is my lucky number: {{ number }}

+ +****************************************************************** + +// 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` + diff --git a/composer.json b/composer.json index 5a857bb..07821d9 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ ], "require": { "php": "^7.0", - "symfony/console": "^3.3", + "symfony/console": "^4.1", "league/flysystem": "^1.0" }, "autoload": { diff --git a/composer.lock b/composer.lock index 364b356..389246b 100644 --- a/composer.lock +++ b/composer.lock @@ -1,23 +1,23 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "86720af401aa5039f7771153f965d10c", + "content-hash": "97f13f318d6eaab51aa1c5d273b31538", "packages": [ { "name": "league/flysystem", - "version": "1.0.41", + "version": "1.0.45", "source": { "type": "git", "url": "https://github.com/thephpleague/flysystem.git", - "reference": "f400aa98912c561ba625ea4065031b7a41e5a155" + "reference": "a99f94e63b512d75f851b181afcdf0ee9ebef7e6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/f400aa98912c561ba625ea4065031b7a41e5a155", - "reference": "f400aa98912c561ba625ea4065031b7a41e5a155", + "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/a99f94e63b512d75f851b181afcdf0ee9ebef7e6", + "reference": "a99f94e63b512d75f851b181afcdf0ee9ebef7e6", "shasum": "" }, "require": { @@ -28,12 +28,13 @@ }, "require-dev": { "ext-fileinfo": "*", - "mockery/mockery": "~0.9", - "phpspec/phpspec": "^2.2", - "phpunit/phpunit": "~4.8" + "phpspec/phpspec": "^3.4", + "phpunit/phpunit": "^5.7" }, "suggest": { "ext-fileinfo": "Required for MimeType", + "ext-ftp": "Allows you to use FTP server storage", + "ext-openssl": "Allows you to use FTPS server storage", "league/flysystem-aws-s3-v2": "Allows you to use S3 storage with AWS SDK v2", "league/flysystem-aws-s3-v3": "Allows you to use S3 storage with AWS SDK v3", "league/flysystem-azure": "Allows you to use Windows Azure Blob storage", @@ -87,95 +88,48 @@ "sftp", "storage" ], - "time": "2017-08-06T17:41:04+00:00" - }, - { - "name": "psr/log", - "version": "1.0.2", - "source": { - "type": "git", - "url": "https://github.com/php-fig/log.git", - "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", - "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Log\\": "Psr/Log/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common interface for logging libraries", - "homepage": "https://github.com/php-fig/log", - "keywords": [ - "log", - "psr", - "psr-3" - ], - "time": "2016-10-10T12:19:37+00:00" + "time": "2018-05-07T08:44:23+00:00" }, { "name": "symfony/console", - "version": "v3.3.8", + "version": "v4.1.1", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "d6596cb5022b6a0bd940eae54a1de78646a5fda6" + "reference": "70591cda56b4b47c55776ac78e157c4bb6c8b43f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/d6596cb5022b6a0bd940eae54a1de78646a5fda6", - "reference": "d6596cb5022b6a0bd940eae54a1de78646a5fda6", + "url": "https://api.github.com/repos/symfony/console/zipball/70591cda56b4b47c55776ac78e157c4bb6c8b43f", + "reference": "70591cda56b4b47c55776ac78e157c4bb6c8b43f", "shasum": "" }, "require": { - "php": "^5.5.9|>=7.0.8", - "symfony/debug": "~2.8|~3.0", + "php": "^7.1.3", "symfony/polyfill-mbstring": "~1.0" }, "conflict": { - "symfony/dependency-injection": "<3.3" + "symfony/dependency-injection": "<3.4", + "symfony/process": "<3.3" }, "require-dev": { "psr/log": "~1.0", - "symfony/config": "~3.3", - "symfony/dependency-injection": "~3.3", - "symfony/event-dispatcher": "~2.8|~3.0", - "symfony/filesystem": "~2.8|~3.0", - "symfony/process": "~2.8|~3.0" + "symfony/config": "~3.4|~4.0", + "symfony/dependency-injection": "~3.4|~4.0", + "symfony/event-dispatcher": "~3.4|~4.0", + "symfony/lock": "~3.4|~4.0", + "symfony/process": "~3.4|~4.0" }, "suggest": { - "psr/log": "For using the console logger", + "psr/log-implementation": "For using the console logger", "symfony/event-dispatcher": "", - "symfony/filesystem": "", + "symfony/lock": "", "symfony/process": "" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.3-dev" + "dev-master": "4.1-dev" } }, "autoload": { @@ -202,125 +156,20 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2017-08-27T14:52:21+00:00" - }, - { - "name": "symfony/debug", - "version": "v3.3.8", - "source": { - "type": "git", - "url": "https://github.com/symfony/debug.git", - "reference": "084d804fe35808eb2ef596ec83d85d9768aa6c9d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/debug/zipball/084d804fe35808eb2ef596ec83d85d9768aa6c9d", - "reference": "084d804fe35808eb2ef596ec83d85d9768aa6c9d", - "shasum": "" - }, - "require": { - "php": "^5.5.9|>=7.0.8", - "psr/log": "~1.0" - }, - "conflict": { - "symfony/http-kernel": ">=2.3,<2.3.24|~2.4.0|>=2.5,<2.5.9|>=2.6,<2.6.2" - }, - "require-dev": { - "symfony/http-kernel": "~2.8|~3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.3-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Debug\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Debug Component", - "homepage": "https://symfony.com", - "time": "2017-08-27T14:52:21+00:00" - }, - { - "name": "symfony/finder", - "version": "v3.3.8", - "source": { - "type": "git", - "url": "https://github.com/symfony/finder.git", - "reference": "b2260dbc80f3c4198f903215f91a1ac7fe9fe09e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/b2260dbc80f3c4198f903215f91a1ac7fe9fe09e", - "reference": "b2260dbc80f3c4198f903215f91a1ac7fe9fe09e", - "shasum": "" - }, - "require": { - "php": "^5.5.9|>=7.0.8" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.3-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Finder\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Finder Component", - "homepage": "https://symfony.com", - "time": "2017-07-29T21:54:42+00:00" + "time": "2018-05-31T10:17:53+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.5.0", + "version": "v1.8.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "7c8fae0ac1d216eb54349e6a8baa57d515fe8803" + "reference": "3296adf6a6454a050679cde90f95350ad604b171" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/7c8fae0ac1d216eb54349e6a8baa57d515fe8803", - "reference": "7c8fae0ac1d216eb54349e6a8baa57d515fe8803", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/3296adf6a6454a050679cde90f95350ad604b171", + "reference": "3296adf6a6454a050679cde90f95350ad604b171", "shasum": "" }, "require": { @@ -332,7 +181,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.5-dev" + "dev-master": "1.8-dev" } }, "autoload": { @@ -366,7 +215,7 @@ "portable", "shim" ], - "time": "2017-06-14T15:44:48+00:00" + "time": "2018-04-26T10:06:28+00:00" } ], "packages-dev": [], diff --git a/src/Luna.php b/src/Luna.php index 8e2973b..b8fc495 100644 --- a/src/Luna.php +++ b/src/Luna.php @@ -9,7 +9,7 @@ class Luna { - public static $version = '1.2.0'; + public static $version = '1.2.1'; public static function commands() { diff --git a/src/templates/menu-page.php b/src/templates/menu-page.php index 02b6877..1e15262 100644 --- a/src/templates/menu-page.php +++ b/src/templates/menu-page.php @@ -42,7 +42,7 @@ class {PLACEHOLDER} extends MenuPage protected $option_group = ''; /** - * @var string An array of options with args. + * @var array An array of options with args. * See $args here https://developer.wordpress.org/reference/functions/register_setting/ */ protected $options = [ @@ -50,7 +50,10 @@ class {PLACEHOLDER} extends MenuPage ]; /** - * Print template of Menu Page + * Print template of Menu Page. + * It is also possible to use Timber. + * + * \Timber::render(); * * @return void */ diff --git a/src/templates/submenu-page.php b/src/templates/submenu-page.php index 65041ba..4c7da4c 100644 --- a/src/templates/submenu-page.php +++ b/src/templates/submenu-page.php @@ -37,7 +37,7 @@ class {PLACEHOLDER} extends SubmenuPage protected $option_group = ''; /** - * @var string An array of options with args. + * @var array An array of options with args. * See $args here https://developer.wordpress.org/reference/functions/register_setting/ */ protected $options = [ @@ -46,6 +46,9 @@ class {PLACEHOLDER} extends SubmenuPage /** * Print template of Submenu Page + * It is also possible to use Timber. + * + * \Timber::render(); * * @return void */