Created
January 14, 2018 13:25
-
-
Save obiPlabon/c2f6200893331a4509fc5fa259d48f42 to your computer and use it in GitHub Desktop.
WordPress list utility functions and class tutorial
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 | |
$tasks = array( | |
array( | |
'id' => 1, | |
'name' => 'Write down some tasks', | |
'priority' => 1, | |
'completed' => true, | |
), | |
array( | |
'id' => 2, | |
'name' => 'Add one more task', | |
'priority' => 3, | |
'completed' => false, | |
), | |
array( | |
'id' => 3, | |
'name' => 'Check spelling mistakes', | |
'priority' => 7, | |
'completed' => false, | |
), | |
array( | |
'id' => 5, | |
'name' => 'Fix spelling mistakes', | |
'priority' => 10, | |
'completed' => false, | |
), | |
array( | |
'id' => 6, | |
'name' => 'Add one more task', | |
'priority' => 11, | |
'completed' => false, | |
), | |
array( | |
'id' => 7, | |
'name' => 'Run some tests', | |
'priority' => 13, | |
'completed' => false, | |
), | |
array( | |
'id' => 8, | |
'name' => 'Write an article on this', | |
'priority' => 15, | |
'completed' => false, | |
), | |
); |
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 Task { | |
public function __construct( $id, $name, $priority = 10, $completed = false) { | |
$this->id = $id; | |
$this->name = $name; | |
$this->priority = $priority; // Less == More, More != More :P | |
$this->completed = $completed; | |
} | |
} | |
$tasks = array( | |
new Task( 1, 'Write down some tasks', 1, true ), | |
new Task( 2, 'Add one more task', 3, false ), | |
new Task( 3, 'Check spelling mistakes', 7, false ), | |
new Task( 5, 'Fix spelling mistakes', 10, false ), | |
new Task( 6, 'Add one more task', 11, false ), | |
new Task( 7, 'Run some tests', 13, false ), | |
new Task( 8, 'Write an article on this', 15, false ), | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment