| @@ 118-134 (lines=17) @@ | ||
| 115 | } |
|
| 116 | ||
| 117 | ||
| 118 | public function register_get_sync_state_endpoint() { |
|
| 119 | $that = $this; |
|
| 120 | register_rest_route( |
|
| 121 | WL_REST_ROUTE_DEFAULT_NAMESPACE, |
|
| 122 | '/videos/background/get_state', |
|
| 123 | array( |
|
| 124 | 'methods' => WP_REST_Server::CREATABLE, |
|
| 125 | 'callback' => function () use ( $that ) { |
|
| 126 | return $that->background_process->get_state()->get_array(); |
|
| 127 | }, |
|
| 128 | 'permission_callback' => function () { |
|
| 129 | return current_user_can( 'manage_options' ); |
|
| 130 | }, |
|
| 131 | ) |
|
| 132 | ); |
|
| 133 | ||
| 134 | } |
|
| 135 | ||
| 136 | public function register_background_process_start_endpoint() { |
|
| 137 | $that = $this; |
|
| @@ 136-153 (lines=18) @@ | ||
| 133 | ||
| 134 | } |
|
| 135 | ||
| 136 | public function register_background_process_start_endpoint() { |
|
| 137 | $that = $this; |
|
| 138 | register_rest_route( |
|
| 139 | WL_REST_ROUTE_DEFAULT_NAMESPACE, |
|
| 140 | '/videos/background/start', |
|
| 141 | array( |
|
| 142 | 'methods' => WP_REST_Server::CREATABLE, |
|
| 143 | 'callback' => function () use ( $that ) { |
|
| 144 | $that->background_process->start(); |
|
| 145 | }, |
|
| 146 | 'permission_callback' => function () { |
|
| 147 | return current_user_can( 'manage_options' ); |
|
| 148 | }, |
|
| 149 | ) |
|
| 150 | ); |
|
| 151 | ||
| 152 | ||
| 153 | } |
|
| 154 | ||
| 155 | public function register_background_process_stop_endpoint() { |
|
| 156 | $that = $this; |
|
| @@ 155-171 (lines=17) @@ | ||
| 152 | ||
| 153 | } |
|
| 154 | ||
| 155 | public function register_background_process_stop_endpoint() { |
|
| 156 | $that = $this; |
|
| 157 | register_rest_route( |
|
| 158 | WL_REST_ROUTE_DEFAULT_NAMESPACE, |
|
| 159 | '/videos/background/stop', |
|
| 160 | array( |
|
| 161 | 'methods' => WP_REST_Server::CREATABLE, |
|
| 162 | 'callback' => function () use ( $that ) { |
|
| 163 | $that->background_process->cancel(); |
|
| 164 | }, |
|
| 165 | 'permission_callback' => function () { |
|
| 166 | return current_user_can( 'manage_options' ); |
|
| 167 | }, |
|
| 168 | ) |
|
| 169 | ); |
|
| 170 | ||
| 171 | } |
|
| 172 | ||
| 173 | ||
| 174 | } |
|