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 | |
WP_Route::get('/', function(){ | |
return "Hello World." | |
}); | |
WP_Route::get('/flights', 'flights'); // flights() | |
WP_Route::post('/flights/{flight}', 'singleFlight'); // singleFlight($flight) | |
WP_Route::put('/flights/{flight}/book/{date}', 'bookFlight'); | |
WP_Route::delete('/flights/{flight}/delete', 'deleteFlight'); |
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
public static function fieldsCallback(){ | |
$this_ = Self::newWithoutConstructor(); | |
if(method_exists($this_, 'cmb2Fields')){ | |
$fields = $this_->cmb2Fields(); | |
if(function_exists('new_cmb2_box') && is_array($fields)){ | |
if(!isset($fields['meta_box'])){ | |
$fields['meta_box'] = [ | |
'id' => get_called_class(), |
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 | |
WP_Route::redirect('open-google', 'https://google.com', 301); | |
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 | |
WP_Route::match(['get', 'post'], 'flights/{flight}/confirm', 'confirmFlight'); | |
function confirmFlight($flight){ | |
// Your Code Here | |
} |
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 | |
WP_Route::get('flights', 'listFlights'); | |
WP_Route::post('flights/{flight}', array('FlightController', 'singleFlight')); | |
function listFlights(){ | |
// Your Code Here | |
} | |
Class FlightController{ |
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 | |
WP_Route::get('flights/{flight}', 'singleFlight'); | |
// http://example.com/flights/1 | |
function singleFlight($flight){ | |
echo $flight; // 1 | |
// Your Code Here! |
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 | |
WP_Route::get('flights', 'listFlights'); | |
// http://example.com/flights | |
function listFlights(){ | |
// Your Code Here! | |
} |
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 | |
Class ExampleCronEvent extends WP_Cron{ | |
public $every = [ | |
'seconds' => 30, | |
'minutes' => 15, | |
'hours' => 1, | |
]; | |
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 | |
Class ExampleAction extends WP_AJAX{ | |
protected $action = 'example-action'; | |
protected function run(){ | |
if($this->has('name')){ | |
update_option('name', $this->get('name')); |
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 | |
Class Product extends WP_Model{ | |
public $postType = 'product'; | |
public $attributes = [ | |
'color', | |
'weight' | |
]; | |
} | |
Product::register(); |