-
wp plugin create {plugin-folder-name}
Should invoke
FatPanda\WordPress\PluginWorkbench::createPlugin
to 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 | |
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; |
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 | |
// open the JSON file | |
$json = json_decode(file_get_contents('cleveland-film-festival-2016.json')); | |
// open a file to put the CSV into | |
$outfile = fopen('cleveland-film-festival-2016.csv', 'w'); | |
// loop over the JSON file, one film at a time | |
foreach($json as $film) { | |
// build an array from the film content | |
$out = [ | |
$film->title, |
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
/* | |
To use this script, open Chrome and browse to | |
http://www.clevelandfilm.org/schedule | |
Open the JavaScript console (CMD + ALT + J on Mac), and | |
paste the whole script into the command line. | |
The script is asynchronous, meaning that when you run it, | |
it will appear to finish immediately, but in fact the | |
script makes one request for each film-like thing it finds | |
on the schedule page. You can see it running by clicking | |
on the Network tab of the debugger window (already open |