PluginProbe
Extendify / 3.1.5
Extendify v3.1.5
3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 0.6.0 0.7.0 All 126 releases
extendify / app / Assist / Controllers / TasksController.php

TasksController.php in Extendify 3.1.5, at app/Assist/Controllers/TasksController.php

60 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Controls Tasks
5 */
6
7 namespace Extendify\Assist\Controllers;
8
9 defined('ABSPATH') || die('No direct access.');
10
11 use Extendify\Shared\Services\Sanitizer;
12
13 /**
14 * The controller for plugin dependency checking, etc
15 */
16
17 class TasksController
18 {
19 /**
20 * Return the data
21 *
22 * @return \WP_REST_Response
23 */
24 public static function get()
25 {
26 $data = get_option('extendify_assist_tasks', []);
27 return new \WP_REST_Response($data);
28 }
29
30 /**
31 * Persist the data
32 *
33 * @param \WP_REST_Request $request - The request.
34 * @return \WP_REST_Response
35 */
36 public static function store($request)
37 {
38 $data = json_decode($request->get_param('state'), true);
39 update_option('extendify_assist_tasks', Sanitizer::sanitizeArray($data));
40 return new \WP_REST_Response($data);
41 }
42
43 /**
44 * Returns remaining incomplete tasks.
45 *
46 * @return int
47 */
48 public function getRemainingCount()
49 {
50 $tasks = get_option('extendify_assist_tasks', []);
51 if (!isset($tasks['state']['seenTasks'])) {
52 return 0;
53 }
54
55 $seenTasks = count($tasks['state']['seenTasks']);
56 $completedTasks = count($tasks['state']['completedTasks']);
57 return max(($seenTasks - $completedTasks), 0);
58 }
59 }
60