-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Final version of a fully functional todo app
- Loading branch information
1 parent
e279c1d
commit c30856a
Showing
18 changed files
with
3,061 additions
and
214 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
node_modules | ||
build | ||
build | ||
.DS_Store |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace TodoApp; | ||
|
||
add_action('admin_enqueue_scripts', __NAMESPACE__ . '\\styles'); | ||
|
||
function styles() { | ||
$screen = get_current_screen(); | ||
|
||
if ($screen->id !== 'toplevel_page_todoapp') { | ||
return; | ||
} | ||
|
||
wp_enqueue_style( | ||
'wpappointments-admin-css', | ||
TODOAPP_PLUGIN_DIR_URL . '/build/index.css', | ||
array('wp-edit-blocks') | ||
); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
add_filter('rest_todoitem_query', function ($args, $request) { | ||
$meta_key = $request->get_param('metaKey'); | ||
$meta_value = $request->get_param('metaValue'); | ||
|
||
if (empty($meta_key)) { | ||
return $args; | ||
} | ||
|
||
$args['meta_query'] = [ | ||
'relation' => 'OR', | ||
[ | ||
'key' => $meta_key, | ||
'value' => $meta_value, | ||
], | ||
]; | ||
|
||
if ($meta_value === "") { | ||
$args['meta_query'][] = [ | ||
'key' => $meta_key, | ||
'compare' => 'NOT EXISTS', | ||
]; | ||
} | ||
|
||
return $args; | ||
}, 10, 2); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
add_action('init', function () { | ||
register_post_type('todoitem', [ | ||
'supports' => ['title', 'custom-fields'], | ||
'show_in_rest' => true, | ||
]); | ||
|
||
register_post_meta('todoitem', 'completed', [ | ||
'single' => true, | ||
'type' => 'boolean', | ||
'show_in_rest' => true, | ||
]); | ||
}); |
Oops, something went wrong.