Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 1368 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
||
| 1 | <?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName |
| 2 | |
| 3 | if ( ! defined( 'ABSPATH' ) ) { |
| 4 | exit( 0 ); |
| 5 | } |
| 6 | |
| 7 | $json_jetpack_endpoints_dir = __DIR__ . '/'; |
| 8 | |
| 9 | require_once $json_jetpack_endpoints_dir . 'class.jetpack-json-api-endpoint.php'; |
| 10 | |
| 11 | // THEMES |
| 12 | require_once $json_jetpack_endpoints_dir . 'class.jetpack-json-api-themes-endpoint.php'; |
| 13 | require_once $json_jetpack_endpoints_dir . 'class.jetpack-json-api-themes-active-endpoint.php'; |
| 14 | |
| 15 | new Jetpack_JSON_API_Themes_Active_Endpoint( |
| 16 | array( |
| 17 | 'description' => 'Get the active theme of your blog', |
| 18 | 'stat' => 'themes:mine', |
| 19 | 'method' => 'GET', |
| 20 | 'path' => '/sites/%s/themes/mine', |
| 21 | 'path_labels' => array( |
| 22 | '$site' => '(int|string) The site ID, The site domain', |
| 23 | ), |
| 24 | 'response_format' => Jetpack_JSON_API_Themes_Endpoint::$_response_format, |
| 25 | 'allow_jetpack_site_auth' => true, |
| 26 | 'example_request_data' => array( |
| 27 | 'headers' => array( |
| 28 | 'authorization' => 'Bearer YOUR_API_TOKEN', |
| 29 | ), |
| 30 | ), |
| 31 | 'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/example.wordpress.org/themes/mine', |
| 32 | ) |
| 33 | ); |
| 34 | |
| 35 | new Jetpack_JSON_API_Themes_Active_Endpoint( |
| 36 | array( |
| 37 | 'description' => 'Change the active theme of your blog', |
| 38 | 'method' => 'POST', |
| 39 | 'path' => '/sites/%s/themes/mine', |
| 40 | 'stat' => 'themes:mine', |
| 41 | 'path_labels' => array( |
| 42 | '$site' => '(int|string) The site ID, The site domain', |
| 43 | ), |
| 44 | 'query_parameters' => array( |
| 45 | 'context' => false, |
| 46 | ), |
| 47 | 'request_format' => array( |
| 48 | 'theme' => '(string) The ID of the theme that should be activated', |
| 49 | 'dont_change_homepage' => '(bool) Whether the homepage of the site should be replaced with the theme homepage', |
| 50 | ), |
| 51 | 'response_format' => Jetpack_JSON_API_Themes_Endpoint::$_response_format, |
| 52 | 'allow_jetpack_site_auth' => true, |
| 53 | 'example_request_data' => array( |
| 54 | 'headers' => array( |
| 55 | 'authorization' => 'Bearer YOUR_API_TOKEN', |
| 56 | ), |
| 57 | 'body' => array( |
| 58 | 'theme' => 'twentytwelve', |
| 59 | ), |
| 60 | ), |
| 61 | 'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/example.wordpress.org/themes/mine', |
| 62 | ) |
| 63 | ); |
| 64 | |
| 65 | require_once $json_jetpack_endpoints_dir . 'class.jetpack-json-api-themes-list-endpoint.php'; |
| 66 | |
| 67 | new Jetpack_JSON_API_Themes_List_Endpoint( |
| 68 | array( |
| 69 | 'description' => 'Get WordPress.com Themes allowed on your blog', |
| 70 | 'group' => '__do_not_document', |
| 71 | 'stat' => 'themes', |
| 72 | 'method' => 'GET', |
| 73 | 'path' => '/sites/%s/themes', |
| 74 | 'path_labels' => array( |
| 75 | '$site' => '(int|string) The site ID, The site domain', |
| 76 | ), |
| 77 | 'response_format' => array( |
| 78 | 'found' => '(int) The total number of themes found.', |
| 79 | 'themes' => '(array) An array of theme objects.', |
| 80 | ), |
| 81 | 'allow_jetpack_site_auth' => true, |
| 82 | 'example_request_data' => array( |
| 83 | 'headers' => array( |
| 84 | 'authorization' => 'Bearer YOUR_API_TOKEN', |
| 85 | ), |
| 86 | ), |
| 87 | 'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/example.wordpress.org/themes', |
| 88 | ) |
| 89 | ); |
| 90 | |
| 91 | require_once $json_jetpack_endpoints_dir . 'class-jetpack-json-api-attachment-ownership-trait.php'; |
| 92 | |
| 93 | require_once $json_jetpack_endpoints_dir . 'class.jetpack-json-api-themes-get-endpoint.php'; |
| 94 | require_once $json_jetpack_endpoints_dir . 'class.jetpack-json-api-themes-new-endpoint.php'; |
| 95 | require_once $json_jetpack_endpoints_dir . 'class.jetpack-json-api-themes-replace-endpoint.php'; |
| 96 | |
| 97 | // POST /sites/%s/themes/%new |
| 98 | new Jetpack_JSON_API_Themes_New_Endpoint( |
| 99 | array( |
| 100 | 'description' => 'Install a theme to your jetpack blog', |
| 101 | 'group' => '__do_not_document', |
| 102 | 'stat' => 'themes:new', |
| 103 | 'method' => 'POST', |
| 104 | 'path' => '/sites/%s/themes/new', |
| 105 | 'path_labels' => array( |
| 106 | '$site' => '(int|string) The site ID, The site domain', |
| 107 | ), |
| 108 | 'request_format' => array( |
| 109 | 'zip' => '(array) Reference to an uploaded theme package zip file.', |
| 110 | ), |
| 111 | 'response_format' => Jetpack_JSON_API_Themes_Endpoint::$_response_format, |
| 112 | 'allow_jetpack_site_auth' => true, |
| 113 | 'example_request_data' => array( |
| 114 | 'headers' => array( |
| 115 | 'authorization' => 'Bearer YOUR_API_TOKEN', |
| 116 | ), |
| 117 | ), |
| 118 | 'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/example.wordpress.org/themes/new', |
| 119 | ) |
| 120 | ); |
| 121 | |
| 122 | new Jetpack_JSON_API_Themes_Get_Endpoint( |
| 123 | array( |
| 124 | 'description' => 'Get a single theme on a jetpack blog', |
| 125 | 'group' => '__do_not_document', |
| 126 | 'stat' => 'themes:get:1', |
| 127 | 'method' => 'GET', |
| 128 | 'path' => '/sites/%s/themes/%s', |
| 129 | 'path_labels' => array( |
| 130 | '$site' => '(int|string) The site ID, The site domain', |
| 131 | '$theme' => '(string) The theme slug', |
| 132 | ), |
| 133 | 'response_format' => Jetpack_JSON_API_Themes_Endpoint::$_response_format, |
| 134 | 'allow_jetpack_site_auth' => true, |
| 135 | 'example_request_data' => array( |
| 136 | 'headers' => array( |
| 137 | 'authorization' => 'Bearer YOUR_API_TOKEN', |
| 138 | ), |
| 139 | ), |
| 140 | 'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/example.wordpress.org/themes/twentyfourteen', |
| 141 | ) |
| 142 | ); |
| 143 | |
| 144 | require_once $json_jetpack_endpoints_dir . 'class.jetpack-json-api-themes-modify-endpoint.php'; |
| 145 | new Jetpack_JSON_API_Themes_Modify_Endpoint( |
| 146 | array( |
| 147 | 'description' => 'Modify a single theme on a jetpack blog', |
| 148 | 'group' => '__do_not_document', |
| 149 | 'stat' => 'themes:modify:1', |
| 150 | 'method' => 'POST', |
| 151 | 'path' => '/sites/%s/themes/%s', |
| 152 | 'path_labels' => array( |
| 153 | '$site' => '(int|string) The site ID, The site domain', |
| 154 | '$theme' => '(string) The theme slug', |
| 155 | ), |
| 156 | 'request_format' => array( |
| 157 | 'action' => '(string) Only possible value is \'update\'. More to follow.', |
| 158 | 'autoupdate' => '(bool) Whether or not to automatically update the theme.', |
| 159 | ), |
| 160 | 'response_format' => Jetpack_JSON_API_Themes_Endpoint::$_response_format, |
| 161 | 'allow_jetpack_site_auth' => true, |
| 162 | 'example_request_data' => array( |
| 163 | 'headers' => array( |
| 164 | 'authorization' => 'Bearer YOUR_API_TOKEN', |
| 165 | ), |
| 166 | 'body' => array( |
| 167 | 'action' => 'update', |
| 168 | ), |
| 169 | ), |
| 170 | 'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/example.wordpress.org/themes/twentyfourteen', |
| 171 | ) |
| 172 | ); |
| 173 | |
| 174 | new Jetpack_JSON_API_Themes_Modify_Endpoint( |
| 175 | array( |
| 176 | 'description' => 'Modify a list of themes on a jetpack blog', |
| 177 | 'group' => '__do_not_document', |
| 178 | 'stat' => 'themes:modify', |
| 179 | 'method' => 'POST', |
| 180 | 'path' => '/sites/%s/themes', |
| 181 | 'path_labels' => array( |
| 182 | '$site' => '(int|string) The site ID, The site domain', |
| 183 | ), |
| 184 | 'request_format' => array( |
| 185 | 'action' => '(string) Only possible value is \'update\'. More to follow.', |
| 186 | 'autoupdate' => '(bool) Whether or not to automatically update the theme.', |
| 187 | 'themes' => '(array) A list of theme slugs', |
| 188 | ), |
| 189 | 'response_format' => array( |
| 190 | 'themes' => '(array:theme) A list of theme objects', |
| 191 | ), |
| 192 | 'allow_jetpack_site_auth' => true, |
| 193 | 'example_request_data' => array( |
| 194 | 'headers' => array( |
| 195 | 'authorization' => 'Bearer YOUR_API_TOKEN', |
| 196 | ), |
| 197 | 'body' => array( |
| 198 | 'action' => 'autoupdate_on', |
| 199 | 'themes' => array( |
| 200 | 'twentytwelve', |
| 201 | 'twentyfourteen', |
| 202 | ), |
| 203 | ), |
| 204 | ), |
| 205 | 'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/example.wordpress.org/themes', |
| 206 | ) |
| 207 | ); |
| 208 | |
| 209 | require_once $json_jetpack_endpoints_dir . 'class.jetpack-json-api-themes-install-endpoint.php'; |
| 210 | // POST /sites/%s/themes/%s/install |
| 211 | new Jetpack_JSON_API_Themes_Install_Endpoint( |
| 212 | array( |
| 213 | 'description' => 'Install a theme to your jetpack blog', |
| 214 | 'group' => '__do_not_document', |
| 215 | 'stat' => 'themes:1:install', |
| 216 | 'method' => 'POST', |
| 217 | 'path' => '/sites/%s/themes/%s/install', |
| 218 | 'path_labels' => array( |
| 219 | '$site' => '(int|string) The site ID, The site domain', |
| 220 | '$theme' => '(int|string) The theme slug to install', |
| 221 | ), |
| 222 | 'response_format' => Jetpack_JSON_API_Themes_Endpoint::$_response_format, |
| 223 | 'allow_jetpack_site_auth' => true, |
| 224 | 'example_request_data' => array( |
| 225 | 'headers' => array( |
| 226 | 'authorization' => 'Bearer YOUR_API_TOKEN', |
| 227 | ), |
| 228 | ), |
| 229 | 'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/example.wordpress.org/themes/twentyfourteen/install', |
| 230 | ) |
| 231 | ); |
| 232 | |
| 233 | require_once $json_jetpack_endpoints_dir . 'class.jetpack-json-api-themes-delete-endpoint.php'; |
| 234 | // POST /sites/%s/themes/%s/delete |
| 235 | new Jetpack_JSON_API_Themes_Delete_Endpoint( |
| 236 | array( |
| 237 | 'description' => 'Delete/Uninstall a theme from your jetpack blog', |
| 238 | 'group' => '__do_not_document', |
| 239 | 'stat' => 'themes:1:delete', |
| 240 | 'method' => 'POST', |
| 241 | 'path' => '/sites/%s/themes/%s/delete', |
| 242 | 'path_labels' => array( |
| 243 | '$site' => '(int|string) The site ID, The site domain', |
| 244 | '$theme' => '(string) The slug of the theme to delete', |
| 245 | ), |
| 246 | 'response_format' => Jetpack_JSON_API_Themes_Endpoint::$_response_format, |
| 247 | 'allow_jetpack_site_auth' => true, |
| 248 | 'example_request_data' => array( |
| 249 | 'headers' => array( |
| 250 | 'authorization' => 'Bearer YOUR_API_TOKEN', |
| 251 | ), |
| 252 | ), |
| 253 | 'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/example.wordpress.org/themes/twentyfourteen/delete', |
| 254 | ) |
| 255 | ); |
| 256 | |
| 257 | // PLUGINS |
| 258 | require_once $json_jetpack_endpoints_dir . 'class.jetpack-json-api-plugins-endpoint.php'; |
| 259 | require_once $json_jetpack_endpoints_dir . 'class.jetpack-json-api-plugins-get-endpoint.php'; |
| 260 | require_once $json_jetpack_endpoints_dir . 'class.jetpack-json-api-plugins-list-endpoint.php'; |
| 261 | require_once $json_jetpack_endpoints_dir . 'class.jetpack-json-api-plugins-new-endpoint.php'; |
| 262 | require_once $json_jetpack_endpoints_dir . 'class.jetpack-json-api-plugins-replace-endpoint.php'; |
| 263 | require_once $json_jetpack_endpoints_dir . 'class.jetpack-json-api-plugins-install-endpoint.php'; |
| 264 | require_once $json_jetpack_endpoints_dir . 'class.jetpack-json-api-plugins-delete-endpoint.php'; |
| 265 | require_once $json_jetpack_endpoints_dir . 'class.jetpack-json-api-plugins-modify-endpoint.php'; |
| 266 | |
| 267 | // PLUGINS V1.2 |
| 268 | require_once $json_jetpack_endpoints_dir . 'class.jetpack-json-api-plugins-modify-v1-2-endpoint.php'; |
| 269 | |
| 270 | // Jetpack Modules |
| 271 | require_once $json_jetpack_endpoints_dir . 'class.jetpack-json-api-modules-endpoint.php'; |
| 272 | require_once $json_jetpack_endpoints_dir . 'class.jetpack-json-api-modules-get-endpoint.php'; |
| 273 | |
| 274 | new Jetpack_JSON_API_Modules_Get_Endpoint( |
| 275 | array( |
| 276 | 'description' => 'Get the info about a Jetpack Module on your Jetpack Site', |
| 277 | 'method' => 'GET', |
| 278 | 'path' => '/sites/%s/jetpack/modules/%s/', |
| 279 | 'stat' => 'jetpack:modules:1', |
| 280 | 'path_labels' => array( |
| 281 | '$site' => '(int|string) The site ID, The site domain', |
| 282 | '$module' => '(string) The module name', |
| 283 | ), |
| 284 | 'response_format' => Jetpack_JSON_API_Modules_Endpoint::$_response_format, |
| 285 | 'allow_jetpack_site_auth' => true, |
| 286 | 'example_request_data' => array( |
| 287 | 'headers' => array( |
| 288 | 'authorization' => 'Bearer YOUR_API_TOKEN', |
| 289 | ), |
| 290 | ), |
| 291 | 'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/example.wordpress.org/jetpack/modules/stats', |
| 292 | ) |
| 293 | ); |
| 294 | |
| 295 | require_once $json_jetpack_endpoints_dir . 'class.jetpack-json-api-modules-modify-endpoint.php'; |
| 296 | |
| 297 | new Jetpack_JSON_API_Modules_Modify_Endpoint( |
| 298 | array( |
| 299 | 'description' => 'Modify the status of a Jetpack Module on your Jetpack Site', |
| 300 | 'method' => 'POST', |
| 301 | 'path' => '/sites/%s/jetpack/modules/%s/', |
| 302 | 'stat' => 'jetpack:modules:1', |
| 303 | 'path_labels' => array( |
| 304 | '$site' => '(int|string) The site ID, The site domain', |
| 305 | '$module' => '(string) The module name', |
| 306 | ), |
| 307 | 'request_format' => array( |
| 308 | 'active' => '(bool) The module activation status', |
| 309 | ), |
| 310 | 'response_format' => Jetpack_JSON_API_Modules_Endpoint::$_response_format, |
| 311 | 'allow_jetpack_site_auth' => true, |
| 312 | 'example_request_data' => array( |
| 313 | 'headers' => array( |
| 314 | 'authorization' => 'Bearer YOUR_API_TOKEN', |
| 315 | ), |
| 316 | 'body' => array( |
| 317 | 'active' => true, |
| 318 | ), |
| 319 | ), |
| 320 | 'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/example.wordpress.org/jetpack/modules/stats', |
| 321 | ) |
| 322 | ); |
| 323 | |
| 324 | require_once $json_jetpack_endpoints_dir . 'class.jetpack-json-api-modules-list-endpoint.php'; |
| 325 | |
| 326 | new Jetpack_JSON_API_Modules_List_Endpoint( |
| 327 | array( |
| 328 | 'description' => 'Get the list of available Jetpack modules on your site', |
| 329 | 'method' => 'GET', |
| 330 | 'path' => '/sites/%s/jetpack/modules', |
| 331 | 'stat' => 'jetpack:modules', |
| 332 | 'min_version' => '1', |
| 333 | 'max_version' => '1.1', |
| 334 | 'path_labels' => array( |
| 335 | '$site' => '(int|string) The site ID, The site domain', |
| 336 | ), |
| 337 | 'response_format' => array( |
| 338 | 'found' => '(int) The total number of modules found.', |
| 339 | 'modules' => '(array) An array of module objects.', |
| 340 | ), |
| 341 | 'allow_jetpack_site_auth' => true, |
| 342 | 'example_request_data' => array( |
| 343 | 'headers' => array( |
| 344 | 'authorization' => 'Bearer YOUR_API_TOKEN', |
| 345 | ), |
| 346 | ), |
| 347 | 'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/example.wordpress.org/jetpack/modules', |
| 348 | ) |
| 349 | ); |
| 350 | |
| 351 | require_once $json_jetpack_endpoints_dir . 'class-jetpack-json-api-modules-list-v1-2-endpoint.php'; |
| 352 | |
| 353 | new Jetpack_JSON_API_Modules_List_V1_2_Endpoint( |
| 354 | array( |
| 355 | 'description' => 'Get the list of available Jetpack modules on your site', |
| 356 | 'method' => 'GET', |
| 357 | 'path' => '/sites/%s/jetpack/modules', |
| 358 | 'stat' => 'jetpack:modules', |
| 359 | 'min_version' => '1.2', |
| 360 | 'path_labels' => array( |
| 361 | '$site' => '(int|string) The site ID, The site domain', |
| 362 | ), |
| 363 | 'response_format' => array( |
| 364 | 'modules' => '(array) An array of module objects.', |
| 365 | ), |
| 366 | 'allow_jetpack_site_auth' => true, |
| 367 | 'example_request_data' => array( |
| 368 | 'headers' => array( |
| 369 | 'authorization' => 'Bearer YOUR_API_TOKEN', |
| 370 | ), |
| 371 | ), |
| 372 | 'example_request' => 'https://public-api.wordpress.com/rest/v1.2/sites/example.wordpress.org/jetpack/modules', |
| 373 | ) |
| 374 | ); |
| 375 | |
| 376 | require_once $json_jetpack_endpoints_dir . 'class.jetpack-json-api-updates-status-endpoint.php'; |
| 377 | |
| 378 | new Jetpack_JSON_API_Updates_Status( |
| 379 | array( |
| 380 | 'description' => 'Get counts for available updates', |
| 381 | 'method' => 'GET', |
| 382 | 'path' => '/sites/%s/updates', |
| 383 | 'stat' => 'updates', |
| 384 | 'path_labels' => array( |
| 385 | '$site' => '(int|string) The site ID, The site domain', |
| 386 | ), |
| 387 | 'response_format' => array( |
| 388 | 'plugins' => '(int) The total number of plugins updates.', |
| 389 | 'themes' => '(int) The total number of themes updates.', |
| 390 | 'wordpress' => '(int) The total number of core updates.', |
| 391 | 'translations' => '(int) The total number of translation updates.', |
| 392 | 'total' => '(int) The total number of updates.', |
| 393 | 'wp_version' => '(safehtml) The wp_version string.', |
| 394 | 'wp_update_version' => '(safehtml) The wp_version to update string.', |
| 395 | 'jp_version' => '(safehtml) The site Jetpack version.', |
| 396 | ), |
| 397 | 'example_request_data' => array( |
| 398 | 'headers' => array( |
| 399 | 'authorization' => 'Bearer YOUR_API_TOKEN', |
| 400 | ), |
| 401 | ), |
| 402 | 'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/example.wordpress.org/updates', |
| 403 | ) |
| 404 | ); |
| 405 | |
| 406 | // Jetpack Extras |
| 407 | |
| 408 | require_once $json_jetpack_endpoints_dir . 'class.jetpack-json-api-check-capabilities-endpoint.php'; |
| 409 | |
| 410 | new Jetpack_JSON_API_Check_Capabilities_Endpoint( |
| 411 | array( |
| 412 | 'description' => 'Check if the current user has a certain capability over a Jetpack site', |
| 413 | 'method' => 'GET', |
| 414 | 'path' => '/sites/%s/me/capability', |
| 415 | 'stat' => 'me:capabulity', |
| 416 | 'path_labels' => array( |
| 417 | '$site' => '(int|string) The site ID, The site domain', |
| 418 | ), |
| 419 | 'response_format' => '(bool) True if the user has the queried capability.', |
| 420 | 'example_request_data' => array( |
| 421 | 'headers' => array( |
| 422 | 'authorization' => 'Bearer YOUR_API_TOKEN', |
| 423 | ), |
| 424 | 'body' => array( |
| 425 | 'capability' => 'A single capability or an array of capabilities', |
| 426 | ), |
| 427 | ), |
| 428 | 'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/example.wordpress.org/me/capability', |
| 429 | ) |
| 430 | ); |
| 431 | |
| 432 | // CORE |
| 433 | require_once $json_jetpack_endpoints_dir . 'class.jetpack-json-api-core-endpoint.php'; |
| 434 | require_once $json_jetpack_endpoints_dir . 'class.jetpack-json-api-core-modify-endpoint.php'; |
| 435 | |
| 436 | new Jetpack_JSON_API_Core_Endpoint( |
| 437 | array( |
| 438 | 'description' => 'Gets info about a Jetpack blog\'s core installation', |
| 439 | 'method' => 'GET', |
| 440 | 'path' => '/sites/%s/core', |
| 441 | 'stat' => 'core', |
| 442 | 'path_labels' => array( |
| 443 | '$site' => '(int|string) The site ID, The site domain', |
| 444 | ), |
| 445 | 'response_format' => array( |
| 446 | 'version' => '(string) The current version', |
| 447 | 'autoupdate' => '(bool) Whether or not we automatically update core', |
| 448 | ), |
| 449 | 'example_request_data' => array( |
| 450 | 'headers' => array( |
| 451 | 'authorization' => 'Bearer YOUR_API_TOKEN', |
| 452 | ), |
| 453 | ), |
| 454 | 'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/example.wordpress.org/core', |
| 455 | ) |
| 456 | ); |
| 457 | |
| 458 | new Jetpack_JSON_API_Core_Modify_Endpoint( |
| 459 | array( |
| 460 | 'description' => 'Update WordPress installation on a Jetpack blog', |
| 461 | 'method' => 'POST', |
| 462 | 'path' => '/sites/%s/core/update', |
| 463 | 'stat' => 'core:update', |
| 464 | 'path_labels' => array( |
| 465 | '$site' => '(int|string) The site ID, The site domain', |
| 466 | ), |
| 467 | 'request_format' => array( |
| 468 | 'version' => '(string) The core version to update', |
| 469 | ), |
| 470 | 'response_format' => array( |
| 471 | 'version' => '(string) The core version after the upgrade has run.', |
| 472 | 'log' => '(array:safehtml) An array of log strings.', |
| 473 | ), |
| 474 | 'example_request_data' => array( |
| 475 | 'headers' => array( |
| 476 | 'authorization' => 'Bearer YOUR_API_TOKEN', |
| 477 | ), |
| 478 | ), |
| 479 | 'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/example.wordpress.org/core/update', |
| 480 | ) |
| 481 | ); |
| 482 | |
| 483 | new Jetpack_JSON_API_Core_Endpoint( |
| 484 | array( |
| 485 | 'description' => 'Toggle automatic core updates for a Jetpack blog', |
| 486 | 'method' => 'POST', |
| 487 | 'path' => '/sites/%s/core', |
| 488 | 'stat' => 'core', |
| 489 | 'path_labels' => array( |
| 490 | '$site' => '(int|string) The site ID, The site domain', |
| 491 | ), |
| 492 | 'request_format' => array( |
| 493 | 'autoupdate' => '(bool) Whether or not we automatically update core', |
| 494 | ), |
| 495 | 'response_format' => array( |
| 496 | 'version' => '(string) The current version', |
| 497 | 'autoupdate' => '(bool) Whether or not we automatically update core', |
| 498 | ), |
| 499 | 'example_request_data' => array( |
| 500 | 'headers' => array( |
| 501 | 'authorization' => 'Bearer YOUR_API_TOKEN', |
| 502 | ), |
| 503 | 'body' => array( |
| 504 | 'autoupdate' => true, |
| 505 | ), |
| 506 | ), |
| 507 | 'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/example.wordpress.org/core', |
| 508 | ) |
| 509 | ); |
| 510 | |
| 511 | require_once $json_jetpack_endpoints_dir . 'class.jetpack-json-api-sync-endpoint.php'; |
| 512 | |
| 513 | // POST /sites/%s/sync |
| 514 | new Jetpack_JSON_API_Sync_Endpoint( |
| 515 | array( |
| 516 | 'description' => 'Force sync of all options and constants', |
| 517 | 'method' => 'POST', |
| 518 | 'path' => '/sites/%s/sync', |
| 519 | 'stat' => 'sync', |
| 520 | 'allow_jetpack_site_auth' => true, |
| 521 | 'path_labels' => array( |
| 522 | '$site' => '(int|string) The site ID, The site domain', |
| 523 | ), |
| 524 | 'request_format' => array( |
| 525 | 'modules' => '(string) Comma-delimited set of sync modules to use (default: all of them)', |
| 526 | 'posts' => '(string) Comma-delimited list of post IDs to sync', |
| 527 | 'comments' => '(string) Comma-delimited list of comment IDs to sync', |
| 528 | 'users' => '(string) Comma-delimited list of user IDs to sync', |
| 529 | ), |
| 530 | 'response_format' => array( |
| 531 | 'scheduled' => '(bool) Whether or not the synchronisation was started', |
| 532 | ), |
| 533 | 'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/example.wordpress.org/sync', |
| 534 | ) |
| 535 | ); |
| 536 | |
| 537 | // GET /sites/%s/sync/status |
| 538 | new Jetpack_JSON_API_Sync_Status_Endpoint( |
| 539 | array( |
| 540 | 'description' => 'Status of the current full sync or the previous full sync', |
| 541 | 'method' => 'GET', |
| 542 | 'path' => '/sites/%s/sync/status', |
| 543 | 'stat' => 'sync-status', |
| 544 | 'allow_jetpack_site_auth' => true, |
| 545 | 'path_labels' => array( |
| 546 | '$site' => '(int|string) The site ID, The site domain', |
| 547 | ), |
| 548 | 'query_parameters' => array( |
| 549 | 'fields' => '(string|null) List of comma-separated fields to return (see `response_format`).', |
| 550 | ), |
| 551 | 'response_format' => array( |
| 552 | 'posts_checksum' => '(string|null) Posts checksum. Needs to be requested using the filter parameter.', |
| 553 | 'comments_checksum' => '(string|null) Comments checksum. Needs to be requested using the filter parameter.', |
| 554 | 'post_meta_checksum' => '(string|null) Post Meta checksum. Needs to be requested using the filter parameter.', |
| 555 | 'comment_meta_checksum' => '(string|null) Comment Meta checksum. Needs to be requested using the filter parameter.', |
| 556 | 'started' => '(int|null) The unix timestamp when the last sync started', |
| 557 | 'queue_finished' => '(int|null) The unix timestamp when the enqueuing was done for the last sync', |
| 558 | 'send_started' => '(int|null) The unix timestamp when the last send process started', |
| 559 | 'finished' => '(int|null) The unix timestamp when the last sync finished', |
| 560 | 'total' => '(array) Count of actions that could be sent', |
| 561 | 'queue' => '(array) Count of actions that have been added to the queue', |
| 562 | 'sent' => '(array) Count of actions that have been sent', |
| 563 | 'config' => '(array) Configuration of the last full sync', |
| 564 | 'queue_size' => '(int) Number of items in the sync queue', |
| 565 | 'queue_lag' => '(float) Time delay of the oldest item in the sync queue', |
| 566 | 'queue_next_sync' => '(float) Time in seconds before trying to sync again', |
| 567 | 'full_queue_size' => '(int) Number of items in the full sync queue', |
| 568 | 'full_queue_lag' => '(float) Time delay of the oldest item in the full sync queue', |
| 569 | 'full_queue_next_sync' => '(float) Time in seconds before trying to sync the full sync queue again', |
| 570 | 'cron_size' => '(int) Size of the current cron array', |
| 571 | 'next_cron' => '(int) The number of seconds till the next item in cron.', |
| 572 | 'progress' => '(array) Full Sync status by module', |
| 573 | 'debug_details' => '(array) Details as to why Sync is disabled.', |
| 574 | ), |
| 575 | 'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/example.wordpress.org/sync/status', |
| 576 | ) |
| 577 | ); |
| 578 | |
| 579 | // GET /sites/%s/data-checksums |
| 580 | new Jetpack_JSON_API_Sync_Check_Endpoint( |
| 581 | array( |
| 582 | 'description' => 'Check that cacheable data on the site is in sync with wordpress.com', |
| 583 | 'group' => '__do_not_document', |
| 584 | 'method' => 'GET', |
| 585 | 'path' => '/sites/%s/data-checksums', |
| 586 | 'stat' => 'data-checksums', |
| 587 | 'allow_jetpack_site_auth' => true, |
| 588 | 'path_labels' => array( |
| 589 | '$site' => '(int|string) The site ID, The site domain', |
| 590 | ), |
| 591 | 'response_format' => array( |
| 592 | 'posts' => '(string) Posts checksum', |
| 593 | 'comments' => '(string) Comments checksum', |
| 594 | ), |
| 595 | 'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/example.wordpress.org/data-checksums', |
| 596 | ) |
| 597 | ); |
| 598 | |
| 599 | // GET /sites/%s/data-histogram |
| 600 | new Jetpack_JSON_API_Sync_Histogram_Endpoint( |
| 601 | array( |
| 602 | 'description' => 'Get a histogram of checksums for certain synced data', |
| 603 | 'group' => '__do_not_document', |
| 604 | 'method' => 'GET', |
| 605 | 'path' => '/sites/%s/data-histogram', |
| 606 | 'stat' => 'data-histogram', |
| 607 | 'allow_jetpack_site_auth' => true, |
| 608 | 'path_labels' => array( |
| 609 | '$site' => '(int|string) The site ID, The site domain', |
| 610 | ), |
| 611 | 'query_parameters' => array( |
| 612 | 'object_type' => '(string=posts) The type of object to checksum - posts, comments or options', |
| 613 | 'buckets' => '(int=10) The number of buckets for the checksums', |
| 614 | 'start_id' => '(int=0) Starting ID for the range', |
| 615 | 'end_id' => '(int=null) Ending ID for the range', |
| 616 | 'columns' => '(string) Columns to checksum', |
| 617 | 'strip_non_ascii' => '(bool=true) Strip non-ascii characters from all columns', |
| 618 | 'shared_salt' => '(string) Salt to reduce the collision and improve validation', |
| 619 | 'only_range_edges' => '(bool=false) Only return the edges of the specified range', |
| 620 | 'detailed_drilldown' => '(bool=false) Return a detailed drilldown in `key => checksum` format', |
| 621 | ), |
| 622 | 'response_format' => array( |
| 623 | 'histogram' => '(array) Associative array of histograms by ID range, e.g. "500-999" => "abcd1234"', |
| 624 | 'type' => '(string) Type of checksum algorithm', |
| 625 | ), |
| 626 | 'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/example.wordpress.org/data-histogram', |
| 627 | ) |
| 628 | ); |
| 629 | |
| 630 | // POST /sites/%s/sync/health . |
| 631 | new Jetpack_JSON_API_Sync_Modify_Health_Endpoint( |
| 632 | array( |
| 633 | 'description' => 'Update sync health', |
| 634 | 'method' => 'POST', |
| 635 | 'group' => '__do_not_document', |
| 636 | 'path' => '/sites/%s/sync/health', |
| 637 | 'stat' => 'write-sync-health', |
| 638 | 'allow_jetpack_site_auth' => true, |
| 639 | 'path_labels' => array( |
| 640 | '$site' => '(int|string) The site ID, The site domain', |
| 641 | ), |
| 642 | 'request_format' => array( |
| 643 | 'status' => '(string) Sync Health Status of site', |
| 644 | ), |
| 645 | 'response_format' => array( |
| 646 | 'response' => '(string) Current Sync Health ', |
| 647 | ), |
| 648 | 'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/example.wordpress.org/sync/health', |
| 649 | ) |
| 650 | ); |
| 651 | |
| 652 | $sync_settings_response = array( |
| 653 | 'dequeue_max_bytes' => '(int|bool=false) Maximum bytes to read from queue in a single request', |
| 654 | 'sync_wait_time' => '(int|bool=false) Wait time between requests in seconds if sync threshold exceeded', |
| 655 | 'sync_wait_threshold' => '(int|bool=false) If a request to WPCOM exceeds this duration, wait sync_wait_time seconds before sending again', |
| 656 | 'upload_max_bytes' => '(int|bool=false) Maximum bytes to send in a single request', |
| 657 | 'upload_max_rows' => '(int|bool=false) Maximum rows to send in a single request', |
| 658 | 'max_queue_size' => '(int|bool=false) Maximum queue size that that the queue is allowed to expand to in DB rows to prevent the DB from filling up. Needs to also meet the max_queue_lag limit.', |
| 659 | 'max_queue_lag' => '(int|bool=false) Maximum queue lag in seconds used to prevent the DB from filling up. Needs to also meet the max_queue_size limit.', |
| 660 | 'queue_max_writes_sec' => '(int|bool=false) Maximum writes per second to allow to the queue during full sync.', |
| 661 | 'post_types_blacklist' => '(array|string|bool=false) List of post types to exclude from sync. Send "empty" to unset.', |
| 662 | 'post_meta_whitelist' => '(array|string|bool=false) List of post meta to be included in sync. Send "empty" to unset.', |
| 663 | 'comment_meta_whitelist' => '(array|string|bool=false) List of comment meta to be included in sync. Send "empty" to unset.', |
| 664 | 'disable' => '(int|bool=false) Set to 1 or true to disable sync entirely.', |
| 665 | 'checksum_disable' => '(int|bool=false) Set to 1 or true to disable checksums entirely.', |
| 666 | 'render_filtered_content' => '(int|bool=true) Set to 1 or true to render filtered content.', |
| 667 | 'max_enqueue_full_sync' => '(int|bool=false) Maximum number of rows to enqueue during each full sync process', |
| 668 | 'max_queue_size_full_sync' => '(int|bool=false) Maximum queue size that full sync is allowed to use', |
| 669 | 'full_sync_send_duration' => '(float) Max full sync duration per request', |
| 670 | 'sync_via_cron' => '(int|bool=false) Set to 1 or true to avoid using cron for sync.', |
| 671 | 'cron_sync_time_limit' => '(int|bool=false) Limit cron jobs to number of seconds', |
| 672 | 'enqueue_wait_time' => '(int|bool=false) Wait time in seconds between attempting to continue a full sync, via requests', |
| 673 | 'sync_sender_enabled' => '(int|bool=false) Set to 1 or true to enable the default sender for the incremental queue.', |
| 674 | 'full_sync_sender_enabled' => '(int|bool=false) Set to 1 or true to enable the default sender for the "full sync" queue.', |
| 675 | ); |
| 676 | |
| 677 | // GET /sites/%s/sync/settings |
| 678 | new Jetpack_JSON_API_Sync_Get_Settings_Endpoint( |
| 679 | array( |
| 680 | 'description' => 'Update sync settings', |
| 681 | 'method' => 'GET', |
| 682 | 'group' => '__do_not_document', |
| 683 | 'path' => '/sites/%s/sync/settings', |
| 684 | 'stat' => 'write-sync-settings', |
| 685 | 'allow_jetpack_site_auth' => true, |
| 686 | 'path_labels' => array( |
| 687 | '$site' => '(int|string) The site ID, The site domain', |
| 688 | ), |
| 689 | 'response_format' => $sync_settings_response, |
| 690 | 'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/example.wordpress.org/sync/settings', |
| 691 | ) |
| 692 | ); |
| 693 | |
| 694 | // POST /sites/%s/sync/settings |
| 695 | new Jetpack_JSON_API_Sync_Modify_Settings_Endpoint( |
| 696 | array( |
| 697 | 'description' => 'Update sync settings', |
| 698 | 'method' => 'POST', |
| 699 | 'group' => '__do_not_document', |
| 700 | 'path' => '/sites/%s/sync/settings', |
| 701 | 'stat' => 'write-sync-settings', |
| 702 | 'allow_jetpack_site_auth' => true, |
| 703 | 'path_labels' => array( |
| 704 | '$site' => '(int|string) The site ID, The site domain', |
| 705 | ), |
| 706 | 'request_format' => $sync_settings_response, |
| 707 | 'response_format' => $sync_settings_response, |
| 708 | 'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/example.wordpress.org/sync/settings', |
| 709 | ) |
| 710 | ); |
| 711 | |
| 712 | // GET /sites/%s/sync/object |
| 713 | new Jetpack_JSON_API_Sync_Object( |
| 714 | array( |
| 715 | 'description' => 'Get an object by ID from one of the sync modules, in the format it would be synced in', |
| 716 | 'group' => '__do_not_document', |
| 717 | 'method' => 'GET', |
| 718 | 'path' => '/sites/%s/sync/object', |
| 719 | 'stat' => 'sync-object', |
| 720 | 'allow_jetpack_site_auth' => true, |
| 721 | 'path_labels' => array( |
| 722 | '$site' => '(int|string) The site ID, The site domain', |
| 723 | ), |
| 724 | 'query_parameters' => array( |
| 725 | 'module_name' => '(string) The sync module ID, e.g. "posts"', |
| 726 | 'object_type' => '(string) An identified for the object type, e.g. "post"', |
| 727 | 'object_ids' => '(array) The IDs of the objects', |
| 728 | ), |
| 729 | 'response_format' => array( |
| 730 | 'objects' => '(string) The encoded objects', |
| 731 | 'codec' => '(string) The codec used to encode the objects, deflate-json-array or simple', |
| 732 | ), |
| 733 | 'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/example.wordpress.org/sync/object?module_name=posts&object_type=post&object_ids[]=1&object_ids[]=2&object_ids[]=3', |
| 734 | ) |
| 735 | ); |
| 736 | |
| 737 | // POST /sites/%s/sync/now |
| 738 | new Jetpack_JSON_API_Sync_Now_Endpoint( |
| 739 | array( |
| 740 | 'description' => 'Force immediate sync of top items on a queue', |
| 741 | 'method' => 'POST', |
| 742 | 'path' => '/sites/%s/sync/now', |
| 743 | 'stat' => 'sync-now', |
| 744 | 'allow_jetpack_site_auth' => true, |
| 745 | 'path_labels' => array( |
| 746 | '$site' => '(int|string) The site ID, The site domain', |
| 747 | ), |
| 748 | 'request_format' => array( |
| 749 | 'queue' => '(string) sync or full_sync', |
| 750 | ), |
| 751 | 'response_format' => array( |
| 752 | 'response' => '(array) The response from the server', |
| 753 | ), |
| 754 | 'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/example.wordpress.org/sync/now?queue=full_sync', |
| 755 | ) |
| 756 | ); |
| 757 | |
| 758 | // POST /sites/%s/sync/unlock |
| 759 | new Jetpack_JSON_API_Sync_Unlock_Endpoint( |
| 760 | array( |
| 761 | 'description' => 'Unlock the queue in case it gets locked by a process.', |
| 762 | 'method' => 'POST', |
| 763 | 'path' => '/sites/%s/sync/unlock', |
| 764 | 'group' => '__do_not_document', |
| 765 | 'stat' => 'sync-unlock', |
| 766 | 'allow_jetpack_site_auth' => true, |
| 767 | 'path_labels' => array( |
| 768 | '$site' => '(int|string) The site ID, The site domain', |
| 769 | ), |
| 770 | 'request_format' => array( |
| 771 | 'queue' => '(string) sync or full_sync', |
| 772 | ), |
| 773 | 'response_format' => array( |
| 774 | 'success' => '(bool) Unlocking the queue successful?', |
| 775 | ), |
| 776 | 'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/example.wordpress.org/sync/unlock', |
| 777 | ) |
| 778 | ); |
| 779 | |
| 780 | // GET /sites/%s/sync/object-id-range |
| 781 | new Jetpack_JSON_API_Sync_Object_Id_Range( |
| 782 | array( |
| 783 | 'description' => 'Gets minimum and maximum object ids for each batch of given batch size.', |
| 784 | 'method' => 'GET', |
| 785 | 'path' => '/sites/%s/sync/object-id-range', |
| 786 | 'group' => '__do_not_document', |
| 787 | 'stat' => 'sync-object-id-range', |
| 788 | 'allow_jetpack_site_auth' => true, |
| 789 | 'path_labels' => array( |
| 790 | '$site' => '(int|string) The site ID, The site domain', |
| 791 | ), |
| 792 | 'query_parameters' => array( |
| 793 | 'batch_size' => '(int=1000) The amount of objects per batch.', |
| 794 | 'sync_module' => '(string=posts) The sync module used to enumerate the ranges.', |
| 795 | ), |
| 796 | 'response_format' => array( |
| 797 | 'ranges' => '(array) An array of range objects with min and max properties for each batch.', |
| 798 | ), |
| 799 | 'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/example.wordpress.org/sync/object-id-range?batch_size=100&sync_module=comments', |
| 800 | ) |
| 801 | ); |
| 802 | |
| 803 | // POST /sites/%s/sync/checkout |
| 804 | new Jetpack_JSON_API_Sync_Checkout_Endpoint( |
| 805 | array( |
| 806 | 'description' => 'Locks the queue and returns items and the buffer ID.', |
| 807 | 'method' => 'POST', |
| 808 | 'path' => '/sites/%s/sync/checkout', |
| 809 | 'group' => '__do_not_document', |
| 810 | 'stat' => 'sync-checkout', |
| 811 | 'allow_jetpack_site_auth' => true, |
| 812 | 'path_labels' => array( |
| 813 | '$site' => '(int|string) The site ID, The site domain', |
| 814 | ), |
| 815 | 'request_format' => array( |
| 816 | 'queue' => '(string) sync or full_sync', |
| 817 | 'number_of_items' => '(int=10) Maximum number of items from the queue to be returned', |
| 818 | 'encode' => '(bool=true) Use the default encode method', |
| 819 | 'force' => '(bool=false) Force unlock the queue', |
| 820 | 'pop' => '(bool=false) Pop from the queue without checkout, use carefully 😱', |
| 821 | ), |
| 822 | 'response_format' => array( |
| 823 | 'buffer_id' => '(string) Buffer ID that we are using', |
| 824 | 'items' => '(array) Items from the queue that are ready to be processed by the sync server', |
| 825 | 'skipped_items' => '(array) Skipped item ids', |
| 826 | 'codec' => '(string) The name of the codec used to encode the data', |
| 827 | 'sent_timestamp' => '(int) Current timestamp of the server', |
| 828 | ), |
| 829 | 'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/example.wordpress.org/sync/checkout', |
| 830 | ) |
| 831 | ); |
| 832 | |
| 833 | // POST /sites/%s/sync/close |
| 834 | new Jetpack_JSON_API_Sync_Close_Endpoint( |
| 835 | array( |
| 836 | 'description' => 'Closes the buffer and delete the processed items from the queue.', |
| 837 | 'method' => 'POST', |
| 838 | 'path' => '/sites/%s/sync/close', |
| 839 | 'group' => '__do_not_document', |
| 840 | 'stat' => 'sync-close', |
| 841 | 'allow_jetpack_site_auth' => true, |
| 842 | 'path_labels' => array( |
| 843 | '$site' => '(int|string) The site ID, The site domain', |
| 844 | ), |
| 845 | 'request_format' => array( |
| 846 | 'item_ids' => '(array) Item IDs to delete from the queue.', |
| 847 | 'queue' => '(string) sync or full_sync', |
| 848 | 'buffer_id' => '(string) buffer ID that was opened during the checkout step.', |
| 849 | 'continue' => '(bool=false) Perform another checkout from queue.', |
| 850 | ), |
| 851 | 'response_format' => array( |
| 852 | 'success' => '(bool) Closed the buffer successfully?', |
| 853 | ), |
| 854 | 'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/example.wordpress.org/sync/close', |
| 855 | ) |
| 856 | ); |
| 857 | |
| 858 | require_once $json_jetpack_endpoints_dir . 'class.jetpack-json-api-log-endpoint.php'; |
| 859 | |
| 860 | new Jetpack_JSON_API_Jetpack_Log_Endpoint( |
| 861 | array( |
| 862 | 'description' => 'Get the Jetpack log', |
| 863 | 'method' => 'GET', |
| 864 | 'path' => '/sites/%s/jetpack-log', |
| 865 | 'stat' => 'log', |
| 866 | 'path_labels' => array( |
| 867 | '$site' => '(int|string) The site ID, The site domain', |
| 868 | ), |
| 869 | 'request_format' => array( |
| 870 | 'event' => '(string) The event to filter by, by default all entries are returned', |
| 871 | 'num' => '(int) The number of entries to get, by default all entries are returned', |
| 872 | ), |
| 873 | 'response_format' => array( |
| 874 | 'log' => '(array) An array of jetpack log entries', |
| 875 | ), |
| 876 | 'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/example.wordpress.org/jetpack-log', |
| 877 | ) |
| 878 | ); |
| 879 | |
| 880 | require_once $json_jetpack_endpoints_dir . 'class.jetpack-json-api-maybe-auto-update-endpoint.php'; |
| 881 | |
| 882 | new Jetpack_JSON_API_Maybe_Auto_Update_Endpoint( |
| 883 | array( |
| 884 | 'description' => 'Maybe Auto Update Core, Plugins, Themes and Languages', |
| 885 | 'method' => 'POST', |
| 886 | 'path' => '/sites/%s/maybe-auto-update', |
| 887 | 'stat' => 'maybe-auto-update', |
| 888 | 'path_labels' => array( |
| 889 | '$site' => '(int|string) The site ID, The site domain', |
| 890 | ), |
| 891 | 'response_format' => array( |
| 892 | 'log' => '(array) Results of running the update job', |
| 893 | ), |
| 894 | 'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/example.wordpress.org/maybe-auto-update', |
| 895 | |
| 896 | ) |
| 897 | ); |
| 898 | |
| 899 | require_once $json_jetpack_endpoints_dir . 'class.jetpack-json-api-translations-endpoint.php'; |
| 900 | require_once $json_jetpack_endpoints_dir . 'class.jetpack-json-api-translations-modify-endpoint.php'; |
| 901 | |
| 902 | new Jetpack_JSON_API_Translations_Endpoint( |
| 903 | array( |
| 904 | 'description' => 'Gets info about a Jetpack blog\'s core installation', |
| 905 | 'method' => 'GET', |
| 906 | 'path' => '/sites/%s/translations', |
| 907 | 'stat' => 'translations', |
| 908 | 'path_labels' => array( |
| 909 | '$site' => '(int|string) The site ID, The site domain', |
| 910 | ), |
| 911 | 'response_format' => array( |
| 912 | 'translations' => '(array) A list of translations that are available', |
| 913 | 'autoupdate' => '(bool) Whether or not we automatically update translations', |
| 914 | 'log' => '(array:safehtml) An array of log strings.', |
| 915 | ), |
| 916 | 'example_request_data' => array( |
| 917 | 'headers' => array( |
| 918 | 'authorization' => 'Bearer YOUR_API_TOKEN', |
| 919 | ), |
| 920 | ), |
| 921 | 'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/example.wordpress.org/translations', |
| 922 | ) |
| 923 | ); |
| 924 | |
| 925 | new Jetpack_JSON_API_Translations_Modify_Endpoint( |
| 926 | array( |
| 927 | 'description' => 'Toggle automatic core updates for a Jetpack blog', |
| 928 | 'method' => 'POST', |
| 929 | 'path' => '/sites/%s/translations', |
| 930 | 'stat' => 'translations', |
| 931 | 'path_labels' => array( |
| 932 | '$site' => '(int|string) The site ID, The site domain', |
| 933 | ), |
| 934 | 'request_format' => array( |
| 935 | 'autoupdate' => '(bool) Whether or not we automatically update translations', |
| 936 | ), |
| 937 | 'response_format' => array( |
| 938 | 'translations' => '(array) A list of translations that are available', |
| 939 | 'autoupdate' => '(bool) Whether or not we automatically update translations', |
| 940 | ), |
| 941 | 'example_request_data' => array( |
| 942 | 'headers' => array( |
| 943 | 'authorization' => 'Bearer YOUR_API_TOKEN', |
| 944 | ), |
| 945 | 'body' => array( |
| 946 | 'autoupdate' => true, |
| 947 | ), |
| 948 | ), |
| 949 | 'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/example.wordpress.org/translations', |
| 950 | ) |
| 951 | ); |
| 952 | |
| 953 | new Jetpack_JSON_API_Translations_Modify_Endpoint( |
| 954 | array( |
| 955 | 'description' => 'Update All Translations installation on a Jetpack blog', |
| 956 | 'method' => 'POST', |
| 957 | 'path' => '/sites/%s/translations/update', |
| 958 | 'stat' => 'translations:update', |
| 959 | 'path_labels' => array( |
| 960 | '$site' => '(int|string) The site ID, The site domain', |
| 961 | ), |
| 962 | 'response_format' => array( |
| 963 | 'log' => '(array:safehtml) An array of log strings.', |
| 964 | 'success' => '(bool) Was the operation successful', |
| 965 | ), |
| 966 | 'example_request_data' => array( |
| 967 | 'headers' => array( |
| 968 | 'authorization' => 'Bearer YOUR_API_TOKEN', |
| 969 | ), |
| 970 | ), |
| 971 | 'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/example.wordpress.org/translations/update', |
| 972 | ) |
| 973 | ); |
| 974 | |
| 975 | // Options |
| 976 | require_once $json_jetpack_endpoints_dir . 'class.wpcom-json-api-get-option-endpoint.php'; |
| 977 | |
| 978 | new WPCOM_JSON_API_Get_Option_Endpoint( |
| 979 | array( |
| 980 | 'method' => 'GET', |
| 981 | 'description' => 'Fetches an option.', |
| 982 | 'group' => '__do_not_document', |
| 983 | 'stat' => 'option', |
| 984 | 'allow_jetpack_site_auth' => true, |
| 985 | 'path' => '/sites/%s/option', |
| 986 | 'path_labels' => array( |
| 987 | '$site' => '(int|string) Site ID or domain', |
| 988 | ), |
| 989 | 'query_parameters' => array( |
| 990 | 'option_name' => '(string) The name of the option to fetch.', |
| 991 | 'site_option' => '(bool=false) True if the option is a site option.', |
| 992 | ), |
| 993 | 'response_format' => array( |
| 994 | 'option_value' => '(string|object) The value of the option.', |
| 995 | ), |
| 996 | 'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/82974409/option?option_name=blogname', |
| 997 | 'example_request_data' => array( |
| 998 | 'headers' => array( 'authorization' => 'Bearer YOUR_API_TOKEN' ), |
| 999 | ), |
| 1000 | ) |
| 1001 | ); |
| 1002 | |
| 1003 | require_once $json_jetpack_endpoints_dir . 'class.wpcom-json-api-update-option-endpoint.php'; |
| 1004 | |
| 1005 | new WPCOM_JSON_API_Update_Option_Endpoint( |
| 1006 | array( |
| 1007 | 'method' => 'POST', |
| 1008 | 'description' => 'Updates an option.', |
| 1009 | 'group' => '__do_not_document', |
| 1010 | 'stat' => 'option:update', |
| 1011 | 'allow_jetpack_site_auth' => true, |
| 1012 | 'path' => '/sites/%s/option', |
| 1013 | 'path_labels' => array( |
| 1014 | '$site' => '(int|string) Site ID or domain', |
| 1015 | ), |
| 1016 | 'query_parameters' => array( |
| 1017 | 'option_name' => '(string) The name of the option to fetch.', |
| 1018 | 'site_option' => '(bool=false) True if the option is a site option.', |
| 1019 | 'is_array' => '(bool=false) True if the value should be converted to an array before saving.', |
| 1020 | ), |
| 1021 | 'request_format' => array( |
| 1022 | 'option_value' => '(string|object) The new value of the option.', |
| 1023 | ), |
| 1024 | 'response_format' => array( |
| 1025 | 'option_value' => '(string|object) The value of the updated option.', |
| 1026 | ), |
| 1027 | 'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/82974409/option', |
| 1028 | 'example_request_data' => array( |
| 1029 | 'headers' => array( 'authorization' => 'Bearer YOUR_API_TOKEN' ), |
| 1030 | 'body' => array( |
| 1031 | 'option_value' => 'My new blog name', |
| 1032 | ), |
| 1033 | ), |
| 1034 | ) |
| 1035 | ); |
| 1036 | |
| 1037 | require_once $json_jetpack_endpoints_dir . 'class.jetpack-json-api-cron-endpoint.php'; |
| 1038 | |
| 1039 | // GET /sites/%s/cron |
| 1040 | new Jetpack_JSON_API_Cron_Endpoint( |
| 1041 | array( |
| 1042 | 'description' => 'Fetches the cron array', |
| 1043 | 'group' => '__do_not_document', |
| 1044 | 'method' => 'GET', |
| 1045 | 'path' => '/sites/%s/cron', |
| 1046 | 'stat' => 'cron-get', |
| 1047 | 'path_labels' => array( |
| 1048 | '$site' => '(int|string) The site ID, The site domain', |
| 1049 | ), |
| 1050 | 'response_format' => array( |
| 1051 | 'cron_array' => '(array) The cron array', |
| 1052 | 'current_timestamp' => '(int) Current server timestamp', |
| 1053 | ), |
| 1054 | 'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/example.wordpress.org/cron', |
| 1055 | 'example_request_data' => array( |
| 1056 | 'headers' => array( 'authorization' => 'Bearer YOUR_API_TOKEN' ), |
| 1057 | ), |
| 1058 | ) |
| 1059 | ); |
| 1060 | |
| 1061 | // POST /sites/%s/cron |
| 1062 | new Jetpack_JSON_API_Cron_Post_Endpoint( |
| 1063 | array( |
| 1064 | 'description' => 'Process items in the cron', |
| 1065 | 'group' => '__do_not_document', |
| 1066 | 'method' => 'POST', |
| 1067 | 'path' => '/sites/%s/cron', |
| 1068 | 'stat' => 'cron-run', |
| 1069 | 'path_labels' => array( |
| 1070 | '$site' => '(int|string) The site ID, The site domain', |
| 1071 | ), |
| 1072 | 'request_format' => array( |
| 1073 | 'hooks' => '(array) List of hooks to run if they have been scheduled (optional)', |
| 1074 | ), |
| 1075 | 'response_format' => array( |
| 1076 | 'success' => '(array) Of processed hooks with their arguments', |
| 1077 | ), |
| 1078 | 'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/example.wordpress.org/cron', |
| 1079 | 'example_request_data' => array( |
| 1080 | 'headers' => array( 'authorization' => 'Bearer YOUR_API_TOKEN' ), |
| 1081 | 'body' => array( |
| 1082 | 'hooks' => array( 'jetpack_sync_cron' ), |
| 1083 | ), |
| 1084 | ), |
| 1085 | ) |
| 1086 | ); |
| 1087 | |
| 1088 | // POST /sites/%s/cron/schedule |
| 1089 | new Jetpack_JSON_API_Cron_Schedule_Endpoint( |
| 1090 | array( |
| 1091 | 'description' => 'Schedule one or a recurring hook to fire at a particular time', |
| 1092 | 'group' => '__do_not_document', |
| 1093 | 'method' => 'POST', |
| 1094 | 'path' => '/sites/%s/cron/schedule', |
| 1095 | 'stat' => 'cron-schedule', |
| 1096 | 'path_labels' => array( |
| 1097 | '$site' => '(int|string) The site ID, The site domain', |
| 1098 | ), |
| 1099 | 'request_format' => array( |
| 1100 | 'hook' => '(string) Hook name that should run when the event is scheduled', |
| 1101 | 'timestamp' => '(int) Timestamp when the event should take place, has to be in the future', |
| 1102 | 'arguments' => '(string) JSON Object of arguments that the hook will use (optional)', |
| 1103 | 'recurrence' => '(string) How often the event should take place. If empty only one event will be scheduled. Possible values 1min, hourly, twicedaily, daily (optional) ', |
| 1104 | ), |
| 1105 | 'response_format' => array( |
| 1106 | 'success' => '(bool) Was the event scheduled?', |
| 1107 | ), |
| 1108 | 'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/example.wordpress.org/cron/schedule', |
| 1109 | 'example_request_data' => array( |
| 1110 | 'headers' => array( 'authorization' => 'Bearer YOUR_API_TOKEN' ), |
| 1111 | 'body' => array( |
| 1112 | 'hook' => 'jetpack_sync_cron', |
| 1113 | 'arguments' => '[]', |
| 1114 | 'recurrence' => '1min', |
| 1115 | 'timestamp' => 1476385523, |
| 1116 | ), |
| 1117 | ), |
| 1118 | ) |
| 1119 | ); |
| 1120 | |
| 1121 | // POST /sites/%s/cron/unschedule |
| 1122 | new Jetpack_JSON_API_Cron_Unschedule_Endpoint( |
| 1123 | array( |
| 1124 | 'description' => 'Unschedule one or all events with a particular hook and arguments', |
| 1125 | 'group' => '__do_not_document', |
| 1126 | 'method' => 'POST', |
| 1127 | 'path' => '/sites/%s/cron/unschedule', |
| 1128 | 'stat' => 'cron-unschedule', |
| 1129 | 'path_labels' => array( |
| 1130 | '$site' => '(int|string) The site ID, The site domain', |
| 1131 | ), |
| 1132 | 'request_format' => array( |
| 1133 | 'hook' => '(string) Name of the hook that should be unscheduled', |
| 1134 | 'timestamp' => '(int) Timestamp of the hook that you want to unschedule. This will unschedule only 1 event. (optional)', |
| 1135 | 'arguments' => '(string) JSON Object of arguments that the hook has been scheduled with (optional)', |
| 1136 | ), |
| 1137 | 'response_format' => array( |
| 1138 | 'success' => '(bool) Was the event unscheduled?', |
| 1139 | ), |
| 1140 | 'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/example.wordpress.org/cron/unschedule', |
| 1141 | 'example_request_data' => array( |
| 1142 | 'headers' => array( 'authorization' => 'Bearer YOUR_API_TOKEN' ), |
| 1143 | 'body' => array( |
| 1144 | 'hook' => 'jetpack_sync_cron', |
| 1145 | 'arguments' => '[]', |
| 1146 | 'timestamp' => 1476385523, |
| 1147 | ), |
| 1148 | ), |
| 1149 | ) |
| 1150 | ); |
| 1151 | |
| 1152 | // BACKUPS |
| 1153 | |
| 1154 | // GET /sites/%s/database-object/backup |
| 1155 | require_once $json_jetpack_endpoints_dir . 'class.jetpack-json-api-get-database-object-backup-endpoint.php'; |
| 1156 | new Jetpack_JSON_API_Get_Database_Object_Backup_Endpoint( |
| 1157 | array( |
| 1158 | 'description' => 'Fetch a backup of a database object, along with all of its metadata', |
| 1159 | 'group' => '__do_not_document', |
| 1160 | 'method' => 'GET', |
| 1161 | 'path' => '/sites/%s/database-object/backup', |
| 1162 | 'stat' => 'database-objects:1:backup', |
| 1163 | 'allow_jetpack_site_auth' => true, |
| 1164 | 'path_labels' => array( |
| 1165 | '$site' => '(int|string) The site ID, The site domain', |
| 1166 | ), |
| 1167 | 'query_parameters' => array( |
| 1168 | 'object_type' => '(string) Type of object to fetch from the database', |
| 1169 | 'object_id' => '(int) ID of the database object to fetch', |
| 1170 | ), |
| 1171 | 'response_format' => array( |
| 1172 | 'object' => '(array) Database object row', |
| 1173 | 'meta' => '(array) Associative array of key/value metadata associated with the row', |
| 1174 | 'children' => '(array) Where appropriate, child records associated with the object. eg: Woocommerce tax rate locations', |
| 1175 | ), |
| 1176 | 'example_request_data' => array( |
| 1177 | 'headers' => array( |
| 1178 | 'authorization' => 'Bearer YOUR_API_TOKEN', |
| 1179 | ), |
| 1180 | ), |
| 1181 | 'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/example.wordpress.org/database-object/backup', |
| 1182 | ) |
| 1183 | ); |
| 1184 | |
| 1185 | // GET /sites/%s/comments/%d/backup |
| 1186 | require_once $json_jetpack_endpoints_dir . 'class.jetpack-json-api-get-comment-backup-endpoint.php'; |
| 1187 | new Jetpack_JSON_API_Get_Comment_Backup_Endpoint( |
| 1188 | array( |
| 1189 | 'description' => 'Fetch a backup of a comment, along with all of its metadata', |
| 1190 | 'group' => '__do_not_document', |
| 1191 | 'method' => 'GET', |
| 1192 | 'path' => '/sites/%s/comments/%d/backup', |
| 1193 | 'stat' => 'comments:1:backup', |
| 1194 | 'allow_jetpack_site_auth' => true, |
| 1195 | 'path_labels' => array( |
| 1196 | '$site' => '(int|string) The site ID, The site domain', |
| 1197 | '$post' => '(int) The comment ID', |
| 1198 | ), |
| 1199 | 'response_format' => array( |
| 1200 | 'comment' => '(array) Comment table row', |
| 1201 | 'meta' => '(array) Associative array of key/value commentmeta data', |
| 1202 | ), |
| 1203 | 'example_request_data' => array( |
| 1204 | 'headers' => array( |
| 1205 | 'authorization' => 'Bearer YOUR_API_TOKEN', |
| 1206 | ), |
| 1207 | ), |
| 1208 | 'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/example.wordpress.org/comments/1/backup', |
| 1209 | ) |
| 1210 | ); |
| 1211 | |
| 1212 | // GET /sites/%s/options/backup |
| 1213 | require_once $json_jetpack_endpoints_dir . 'class.jetpack-json-api-get-option-backup-endpoint.php'; |
| 1214 | new Jetpack_JSON_API_Get_Option_Backup_Endpoint( |
| 1215 | array( |
| 1216 | 'description' => 'Fetch a backup of an option', |
| 1217 | 'group' => '__do_not_document', |
| 1218 | 'method' => 'GET', |
| 1219 | 'path' => '/sites/%s/options/backup', |
| 1220 | 'stat' => 'options:backup', |
| 1221 | 'allow_jetpack_site_auth' => true, |
| 1222 | 'path_labels' => array( |
| 1223 | '$site' => '(int|string) The site ID, The site domain', |
| 1224 | ), |
| 1225 | 'query_parameters' => array( |
| 1226 | 'name' => '(string|array) One or more option names to include in the backup', |
| 1227 | ), |
| 1228 | 'response_format' => array( |
| 1229 | 'options' => '(array) Associative array of option_name => option_value entries', |
| 1230 | ), |
| 1231 | 'example_request_data' => array( |
| 1232 | 'headers' => array( |
| 1233 | 'authorization' => 'Bearer YOUR_API_TOKEN', |
| 1234 | ), |
| 1235 | ), |
| 1236 | 'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/example.wordpress.org/options/backup', |
| 1237 | ) |
| 1238 | ); |
| 1239 | |
| 1240 | // GET /sites/%s/posts/%d/backup |
| 1241 | require_once $json_jetpack_endpoints_dir . 'class.jetpack-json-api-get-post-backup-endpoint.php'; |
| 1242 | new Jetpack_JSON_API_Get_Post_Backup_Endpoint( |
| 1243 | array( |
| 1244 | 'description' => 'Fetch a backup of a post, along with all of its metadata', |
| 1245 | 'group' => '__do_not_document', |
| 1246 | 'method' => 'GET', |
| 1247 | 'path' => '/sites/%s/posts/%d/backup', |
| 1248 | 'stat' => 'posts:1:backup', |
| 1249 | 'allow_jetpack_site_auth' => true, |
| 1250 | 'path_labels' => array( |
| 1251 | '$site' => '(int|string) The site ID, The site domain', |
| 1252 | '$post' => '(int) The post ID', |
| 1253 | ), |
| 1254 | 'response_format' => array( |
| 1255 | 'post' => '(array) Post table row', |
| 1256 | 'meta' => '(array) Associative array of key/value postmeta data', |
| 1257 | 'terms' => '(array) List of terms attached to the post object', |
| 1258 | ), |
| 1259 | 'example_request_data' => array( |
| 1260 | 'headers' => array( |
| 1261 | 'authorization' => 'Bearer YOUR_API_TOKEN', |
| 1262 | ), |
| 1263 | ), |
| 1264 | 'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/example.wordpress.org/posts/1/backup', |
| 1265 | ) |
| 1266 | ); |
| 1267 | |
| 1268 | // GET /sites/%s/terms/%d/backup |
| 1269 | require_once $json_jetpack_endpoints_dir . 'class.jetpack-json-api-get-term-backup-endpoint.php'; |
| 1270 | new Jetpack_JSON_API_Get_Term_Backup_Endpoint( |
| 1271 | array( |
| 1272 | 'description' => 'Fetch a backup of a term, along with all of its metadata', |
| 1273 | 'group' => '__do_not_document', |
| 1274 | 'method' => 'GET', |
| 1275 | 'path' => '/sites/%s/terms/%d/backup', |
| 1276 | 'stat' => 'terms:1:backup', |
| 1277 | 'allow_jetpack_site_auth' => true, |
| 1278 | 'path_labels' => array( |
| 1279 | '$site' => '(int|string) The site ID, The site domain', |
| 1280 | '$term' => '(int) The term ID', |
| 1281 | ), |
| 1282 | 'response_format' => array( |
| 1283 | 'term' => '(array) Term table row', |
| 1284 | 'meta' => '(array) Metadata associated with the term', |
| 1285 | ), |
| 1286 | 'example_request_data' => array( |
| 1287 | 'headers' => array( |
| 1288 | 'authorization' => 'Bearer YOUR_API_TOKEN', |
| 1289 | ), |
| 1290 | ), |
| 1291 | 'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/example.wordpress.org/terms/1/backup', |
| 1292 | ) |
| 1293 | ); |
| 1294 | |
| 1295 | // GET /sites/%s/users/%d/backup |
| 1296 | require_once $json_jetpack_endpoints_dir . 'class.jetpack-json-api-get-user-backup-endpoint.php'; |
| 1297 | new Jetpack_JSON_API_Get_User_Backup_Endpoint( |
| 1298 | array( |
| 1299 | 'description' => 'Fetch a backup of a user, along with all of its metadata', |
| 1300 | 'group' => '__do_not_document', |
| 1301 | 'method' => 'GET', |
| 1302 | 'path' => '/sites/%s/users/%d/backup', |
| 1303 | 'stat' => 'users:1:backup', |
| 1304 | 'allow_jetpack_site_auth' => true, |
| 1305 | 'path_labels' => array( |
| 1306 | '$site' => '(int|string) The site ID, The site domain', |
| 1307 | '$user' => '(int) The user ID', |
| 1308 | ), |
| 1309 | 'response_format' => array( |
| 1310 | 'user' => '(array) User table row', |
| 1311 | 'meta' => '(array) Associative array of key/value usermeta data', |
| 1312 | ), |
| 1313 | 'example_request_data' => array( |
| 1314 | 'headers' => array( |
| 1315 | 'authorization' => 'Bearer YOUR_API_TOKEN', |
| 1316 | ), |
| 1317 | ), |
| 1318 | 'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/example.wordpress.org/users/1/backup', |
| 1319 | ) |
| 1320 | ); |
| 1321 | |
| 1322 | // USERS |
| 1323 | |
| 1324 | require_once $json_jetpack_endpoints_dir . 'class.jetpack-json-api-user-connect-endpoint.php'; |
| 1325 | |
| 1326 | // POST /sites/%s/users/%d/connect |
| 1327 | new Jetpack_JSON_API_User_Connect_Endpoint( |
| 1328 | array( |
| 1329 | 'description' => 'Creates or returns a new user given profile data', |
| 1330 | 'group' => '__do_not_document', |
| 1331 | 'method' => 'POST', |
| 1332 | 'path' => '/sites/%s/users/%d/connect', |
| 1333 | 'stat' => 'users:connect', |
| 1334 | 'allow_jetpack_site_auth' => true, |
| 1335 | 'path_labels' => array( |
| 1336 | '$site' => '(int|string) The site ID, The site domain', |
| 1337 | '$user_id' => '(int) The site user ID to connect', |
| 1338 | ), |
| 1339 | 'request_format' => array( |
| 1340 | 'user_token' => '(string) The user token', |
| 1341 | ), |
| 1342 | 'response_format' => array( |
| 1343 | 'success' => '(bool) Was the user connected', |
| 1344 | ), |
| 1345 | 'example_request_data' => array( |
| 1346 | 'headers' => array( |
| 1347 | 'authorization' => 'Bearer YOUR_API_TOKEN', |
| 1348 | ), |
| 1349 | 'body' => array( |
| 1350 | 'user_token' => 'XDH55jndskjf3klh3', |
| 1351 | ), |
| 1352 | ), |
| 1353 | 'example_response' => '{ |
| 1354 | "success" => true |
| 1355 | }', |
| 1356 | 'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/example.wordpress.org/users/6/connect', |
| 1357 | ) |
| 1358 | ); |
| 1359 | |
| 1360 | require_once $json_jetpack_endpoints_dir . 'class.jetpack-json-api-user-create-endpoint.php'; |
| 1361 | |
| 1362 | // POST /sites/%s/users/create |
| 1363 | new Jetpack_JSON_API_User_Create_Endpoint( |
| 1364 | array( |
| 1365 | 'description' => 'Creates or returns a new user given profile data', |
| 1366 | 'group' => '__do_not_document', |
| 1367 | 'method' => 'POST', |
| 1368 | 'path' => '/sites/%s/users/create', |
| 1369 | 'stat' => 'users:create', |
| 1370 | 'allow_jetpack_site_auth' => true, |
| 1371 | 'path_labels' => array( |
| 1372 | '$site' => '(int|string) The site ID, The site domain', |
| 1373 | ), |
| 1374 | 'query_parameters' => array( |
| 1375 | 'invite_accepted' => '(bool=false) If the user is being created in the invite context', |
| 1376 | ), |
| 1377 | 'request_format' => WPCOM_JSON_API_Site_User_Endpoint::$user_format, |
| 1378 | 'response_format' => WPCOM_JSON_API_Site_User_Endpoint::$user_format, |
| 1379 | 'example_request_data' => array( |
| 1380 | 'headers' => array( |
| 1381 | 'authorization' => 'Bearer YOUR_API_TOKEN', |
| 1382 | ), |
| 1383 | 'body' => array( |
| 1384 | 'roles' => array( |
| 1385 | array( |
| 1386 | 'administrator', |
| 1387 | ), |
| 1388 | ), |
| 1389 | 'first_name' => 'John', |
| 1390 | 'last_name' => 'Doe', |
| 1391 | 'email' => 'john.doe@example.wordpress.org', |
| 1392 | ), |
| 1393 | ), |
| 1394 | 'example_response' => '{ |
| 1395 | "ID": 18342963, |
| 1396 | "login": "binarysmash" |
| 1397 | "email": false, |
| 1398 | "name": "binarysmash", |
| 1399 | "URL": "http:\/\/binarysmash.wordpress.com", |
| 1400 | "avatar_URL": "http:\/\/0.gravatar.com\/avatar\/a178ebb1731d432338e6bb0158720fcc?s=96&d=identicon&r=G", |
| 1401 | "profile_URL": "http:\/\/gravatar.com\/binarysmash", |
| 1402 | "roles": [ "administrator" ] |
| 1403 | }', |
| 1404 | 'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/example.wordpress.org/users/create', |
| 1405 | |
| 1406 | ) |
| 1407 | ); |
| 1408 | |
| 1409 | require_once $json_jetpack_endpoints_dir . 'class.jetpack-json-api-jps-woocommerce-connect-endpoint.php'; |
| 1410 | |
| 1411 | // POST /sites/%s/jps/woo-connect |
| 1412 | new Jetpack_JSON_API_JPS_WooCommerce_Connect_Endpoint( |
| 1413 | array( |
| 1414 | 'description' => 'Attempts to connect the WooCommerce plugin for this site to WooCommerce.com.', |
| 1415 | 'group' => '__do_not_document', |
| 1416 | 'method' => 'POST', |
| 1417 | 'path' => '/sites/%s/jps/woo-connect', |
| 1418 | 'stat' => 'jps:woo-connect', |
| 1419 | 'allow_jetpack_site_auth' => true, |
| 1420 | 'path_labels' => array( |
| 1421 | '$site' => '(int|string) The site ID, The site domain', |
| 1422 | ), |
| 1423 | 'request_format' => array( |
| 1424 | 'access_token' => '(string) The access token for WooCommerce to connect to WooCommerce.com', |
| 1425 | 'access_token_secret' => '(string) The access token secret for WooCommerce to connect to WooCommerce.com', |
| 1426 | 'user_id' => '(int) The user\'s ID after registering for a host plan', |
| 1427 | 'site_id' => '(int) The site\'s ID after registering for a host plan', |
| 1428 | ), |
| 1429 | 'response_format' => array( |
| 1430 | 'success' => '(bool) Setting access token and access token secret successful?', |
| 1431 | ), |
| 1432 | 'example_request_data' => array( |
| 1433 | 'headers' => array( |
| 1434 | 'authorization' => 'Bearer YOUR_API_TOKEN', |
| 1435 | ), |
| 1436 | 'body' => array( |
| 1437 | 'access_token' => '123456789', |
| 1438 | 'access_token_secret' => 'abcdefghiklmnop', |
| 1439 | 'user_id' => 1, |
| 1440 | 'site_id' => 2, |
| 1441 | ), |
| 1442 | ), |
| 1443 | 'example_response' => '{ "success": true }', |
| 1444 | 'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/example.wordpress.org/jps/woo-connect', |
| 1445 | ) |
| 1446 | ); |
| 1447 | |
| 1448 | // POST /sites/%s/install-backup-helper-script |
| 1449 | require_once $json_jetpack_endpoints_dir . 'class-jetpack-json-api-install-backup-helper-script-endpoint.php'; |
| 1450 | new Jetpack_JSON_API_Install_Backup_Helper_Script_Endpoint( |
| 1451 | array( |
| 1452 | 'description' => 'Setup a Helper Script, to allow Jetpack Backup to connect to this site', |
| 1453 | 'group' => '__do_not_document', |
| 1454 | 'method' => 'POST', |
| 1455 | 'stat' => 'install-backup-helper-script', |
| 1456 | 'path' => '/sites/%s/install-backup-helper-script', |
| 1457 | 'allow_jetpack_site_auth' => true, |
| 1458 | 'path_labels' => array( |
| 1459 | '$site' => '(int|string) The site ID, The site domain', |
| 1460 | ), |
| 1461 | 'request_format' => array( |
| 1462 | 'helper' => '(string) Base64-encoded Helper Script contents', |
| 1463 | ), |
| 1464 | 'response_format' => array( |
| 1465 | 'abspath' => '(string) WordPress install path', |
| 1466 | 'path' => '(string) Path of the helper script', |
| 1467 | 'url' => '(string) URL to access the helper script', |
| 1468 | ), |
| 1469 | 'example_request_data' => array( |
| 1470 | 'headers' => array( |
| 1471 | 'authorization' => 'Bearer YOUR_API_TOKEN', |
| 1472 | ), |
| 1473 | ), |
| 1474 | 'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/example.wordpress.org/install-backup-helper-script', |
| 1475 | ) |
| 1476 | ); |
| 1477 | |
| 1478 | // POST /sites/%s/delete-backup-helper-script |
| 1479 | require_once $json_jetpack_endpoints_dir . 'class-jetpack-json-api-delete-backup-helper-script-endpoint.php'; |
| 1480 | new Jetpack_JSON_API_Delete_Backup_Helper_Script_Endpoint( |
| 1481 | array( |
| 1482 | 'description' => 'Delete a Helper Script', |
| 1483 | 'group' => '__do_not_document', |
| 1484 | 'method' => 'POST', |
| 1485 | 'stat' => 'delete-backup-helper-script', |
| 1486 | 'path' => '/sites/%s/delete-backup-helper-script', |
| 1487 | 'allow_jetpack_site_auth' => true, |
| 1488 | 'path_labels' => array( |
| 1489 | '$site' => '(int|string) The site ID, The site domain', |
| 1490 | ), |
| 1491 | 'response_format' => array( |
| 1492 | 'success' => '(bool) Deleted the Helper Script successfully?', |
| 1493 | ), |
| 1494 | 'request_format' => array( |
| 1495 | 'path' => '(string) Path to Helper Script to delete', |
| 1496 | ), |
| 1497 | 'example_request_data' => array( |
| 1498 | 'headers' => array( |
| 1499 | 'authorization' => 'Bearer YOUR_API_TOKEN', |
| 1500 | ), |
| 1501 | ), |
| 1502 | 'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/example.wordpress.org/delete-backup-helper-script', |
| 1503 | ) |
| 1504 | ); |