-
wp plugin create {plugin-folder-name}Should invoke
FatPanda\WordPress\PluginWorkbench::createPluginto start interactive plugin wizard -
wp plugin create-controller {plugin-folder-name} {ControllerName} [{PhpNamespace}]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // in your plugin's src/routes.php file | |
| $router->rewrite('/some/arbitrary/url/{slug}', function($slug) { | |
| // you can do anything here | |
| update_option('option_name', $slug); | |
| // if you return false, the request is over | |
| //return false; | |
| // if you return a string, WordPress will try to load a template by that name | |
| return 'my-custom-template'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace YourPlugin; | |
| use YourPlugin\Notifications\PostSaved; | |
| /** | |
| * Your plugin inherits everything that a Laravel container can do. | |
| * Like, sending messages on Slack using Laravel's Notification framework. | |
| */ | |
| class YourPlugin extends \FatPanda\Illuminate\WordPress\Plugin | |
| { | |
| /** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace YourPlugin; | |
| /** | |
| * Your plugin inherits everything that a Laravel container can do. | |
| * Like, querying a database, which is useless, but illustrative. | |
| */ | |
| class YourPlugin extends \FatPanda\Illuminate\WordPress\Plugin | |
| { | |
| /** | |
| * This function is automatically discovered and hooked |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $app->get('/author/{id}', function($id) { | |
| $posts = get_posts( array( | |
| 'author' => $id, | |
| ) ); | |
| if ( empty( $posts ) ) { | |
| return null; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Grab latest post title by an author! | |
| * | |
| * @param array $data Options for the function. | |
| * @return string|null Post title for the latest, * or null if none. | |
| */ | |
| function my_awesome_func( $data ) { | |
| $posts = get_posts( array( | |
| 'author' => $data['id'], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $app->get('/foo/{var}', function($var) { | |
| // do something with $var | |
| return 'result'; | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [2016-11-14 16:43:08] lumen.ERROR: BadMethodCallException: Method shuffle does not exist. in /home/forge/giftedhire.com/releases/20161114164047/vendor/illuminate/support/Traits/Macroable.php:52 | |
| Stack trace: | |
| #0 /home/forge/giftedhire.com/releases/20161114164047/vendor/illuminate/database/Connectors/ConnectionFactory.php(123): Illuminate\Support\Arr::__callStatic('shuffle', Array) | |
| #1 [internal function]: Illuminate\Database\Connectors\ConnectionFactory->Illuminate\Database\Connectors\{closure}() | |
| #2 /home/forge/giftedhire.com/releases/20161114164047/vendor/illuminate/database/Connection.php(964): call_user_func(Object(Closure)) | |
| #3 /home/forge/giftedhire.com/releases/20161114164047/vendor/illuminate/database/Connection.php(832): Illuminate\Database\Connection->getPdo() | |
| #4 /home/forge/giftedhire.com/releases/20161114164047/vendor/illuminate/database/Connection.php(717): Illuminate\Database\Connection->reconnectIfMissingConnection() | |
| #5 /home/forge/giftedhire.com/releases/20161114164047/vendor/illuminate/database/Co |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [2016-11-14 16:43:08] lumen.ERROR: BadMethodCallException: Method shuffle does not exist. in /home/forge/giftedhire.com/releases/20161114164047/vendor/illuminate/support/Traits/Macroable.php:52 | |
| Stack trace: | |
| #0 /home/forge/giftedhire.com/releases/20161114164047/vendor/illuminate/database/Connectors/ConnectionFactory.php(123): Illuminate\Support\Arr::__callStatic('shuffle', Array) | |
| #1 [internal function]: Illuminate\Database\Connectors\ConnectionFactory->Illuminate\Database\Connectors\{closure}() | |
| #2 /home/forge/giftedhire.com/releases/20161114164047/vendor/illuminate/database/Connection.php(964): call_user_func(Object(Closure)) | |
| #3 /home/forge/giftedhire.com/releases/20161114164047/vendor/illuminate/database/Connection.php(832): Illuminate\Database\Connection->getPdo() | |
| #4 /home/forge/giftedhire.com/releases/20161114164047/vendor/illuminate/database/Connection.php(717): Illuminate\Database\Connection->reconnectIfMissingConnection() | |
| #5 /home/forge/giftedhire.com/releases/20161114164047/vendor/illuminate/database/Co |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace App\Exceptions; | |
| use Exception; | |
| use Illuminate\Validation\ValidationException; | |
| use Illuminate\Auth\Access\AuthorizationException; | |
| use Illuminate\Database\Eloquent\ModelNotFoundException; | |
| use Symfony\Component\HttpKernel\Exception\HttpException; | |
| use Laravel\Lumen\Exceptions\Handler as ExceptionHandler; |