3380 058f31828c first commit преди 1 година 3381 058f31828c first commit преди 1 година 3394 058f31828c first commit преди 1 година 3394_fsm 058f31828c first commit преди 1 година 3394_vm 058f31828c first commit преди 1 година 3395 058f31828c first commit преди 1 година 3429 058f31828c first commit преди 1 година 3430 058f31828c first commit преди 1 година 3431 058f31828c first commit преди 1 година 3433 058f31828c first commit преди 1 година 3439 058f31828c first commit преди 1 година 3440 058f31828c first commit преди 1 година 3455 058f31828c first commit преди 1 година 3456 058f31828c first commit преди 1 година 3456_fsm 058f31828c first commit преди 1 година 3456_vm 058f31828c first commit преди 1 година 3466 058f31828c first commit преди 1 година 3467 058f31828c first commit преди 1 година 3468 058f31828c first commit преди 1 година 3501 058f31828c first commit преди 1 година 3502 058f31828c first commit преди 1 година 3503 058f31828c first commit преди 1 година 3534 058f31828c first commit преди 1 година 3541 058f31828c first commit преди 1 година 3541_fsm 058f31828c first commit преди 1 година 3541_vm 058f31828c first commit преди 1 година 3542 058f31828c first commit преди 1 година 3574 058f31828c first commit преди 1 година 3575 058f31828c first commit преди 1 година 3576 058f31828c first commit преди 1 година 3596 058f31828c first commit преди 1 година 3597 058f31828c first commit преди 1 година 3598 058f31828c first commit преди 1 година 3599 058f31828c first commit преди 1 година 3600 058f31828c first commit преди 1 година 3600_fsm 058f31828c first commit преди 1 година 3600_vm 058f31828c first commit преди 1 година 3601 058f31828c first commit преди 1 година 3601_fsm 058f31828c first commit преди 1 година 3601_vm 058f31828c first commit преди 1 година 3602 058f31828c first commit преди 1 година 3602_fsm 058f31828c first commit преди 1 година 3602_vm 058f31828c first commit преди 1 година 3603 058f31828c first commit преди 1 година 3603_fsm 058f31828c first commit преди 1 година 3603_vm 058f31828c first commit преди 1 година 3604 058f31828c first commit преди 1 година 3605 058f31828c first commit преди 1 година 3606 058f31828c first commit преди 1 година 3607 058f31828c first commit преди 1 година 3608 058f31828c first commit преди 1 година 3609 058f31828c first commit преди 1 година 3712 058f31828c first commit преди 1 година 3764 058f31828c first commit преди 1 година 3764_fsm 058f31828c first commit преди 1 година 3764_vm 058f31828c first commit преди 1 година 3766 058f31828c first commit преди 1 година 3767 058f31828c first commit преди 1 година 3997 058f31828c first commit преди 1 година 4143 058f31828c first commit преди 1 година 4144 058f31828c first commit преди 1 година 4145 058f31828c first commit преди 1 година 4146 058f31828c first commit преди 1 година 4147 058f31828c first commit преди 1 година 4148 058f31828c first commit преди 1 година 4149 058f31828c first commit преди 1 година 4150 058f31828c first commit преди 1 година 4151 058f31828c first commit преди 1 година 4152 058f31828c first commit преди 1 година 4153 058f31828c first commit преди 1 година 4154 058f31828c first commit преди 1 година 4155 058f31828c first commit преди 1 година 4156 058f31828c first commit преди 1 година 4157 058f31828c first commit преди 1 година 4158 058f31828c first commit преди 1 година 4159 058f31828c first commit преди 1 година 4160 058f31828c first commit преди 1 година 4161 058f31828c first commit преди 1 година 4162 058f31828c first commit преди 1 година 4163 058f31828c first commit преди 1 година 4164 058f31828c first commit преди 1 година 4165 058f31828c first commit преди 1 година 4166 058f31828c first commit преди 1 година 4167 058f31828c first commit преди 1 година 4168 058f31828c first commit преди 1 година 4169 058f31828c first commit преди 1 година 4170 058f31828c first commit преди 1 година 4171 058f31828c first commit преди 1 година 4172 058f31828c first commit преди 1 година 4173 058f31828c first commit преди 1 година 4174 058f31828c first commit преди 1 година 5002 058f31828c first commit преди 1 година 548 058f31828c first commit преди 1 година 549 058f31828c first commit преди 1 година 6102 058f31828c first commit преди 1 година 6104 058f31828c first commit преди 1 година 6106 058f31828c first commit преди 1 година 6110 058f31828c first commit преди 1 година 6111 058f31828c first commit преди 1 година 6112 058f31828c first commit преди 1 година 6113 058f31828c first commit преди 1 година 6117 058f31828c first commit преди 1 година 826 058f31828c first commit преди 1 година 827 058f31828c first commit преди 1 година 828 058f31828c first commit преди 1 година PG_VERSION 058f31828c first commit преди 1 година pg_filenode.map 058f31828c first commit преди 1 година tum/whitesports - Gogs: Simplico Git Service

Aucune description

class.wpcom-json-api-update-site-homepage-endpoint.php 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. new WPCOM_JSON_API_Update_Site_Homepage_Endpoint( array (
  3. 'description' => 'Set site homepage settings',
  4. 'group' => '__do_not_document',
  5. 'stat' => 'sites:1:homepage',
  6. 'method' => 'POST',
  7. 'min_version' => '1.1',
  8. 'path' => '/sites/%s/homepage',
  9. 'path_labels' => array(
  10. '$site' => '(string) Site ID or domain.',
  11. ),
  12. 'request_format' => array(
  13. 'is_page_on_front' => '(bool) True if we will use a page as the homepage; false to use a blog page as the homepage.',
  14. 'page_on_front_id' => '(int) Optional. The ID of the page to use as the homepage if is_page_on_front is true.',
  15. 'page_for_posts_id' => '(int) Optional. The ID of the page to use as the blog page if is_page_on_front is true.',
  16. ),
  17. 'response_format' => array(
  18. 'is_page_on_front' => '(bool) True if we will use a page as the homepage; false to use a blog page as the homepage.',
  19. 'page_on_front_id' => '(int) The ID of the page to use as the homepage if is_page_on_front is true.',
  20. 'page_for_posts_id' => '(int) The ID of the page to use as the blog page if is_page_on_front is true.',
  21. ),
  22. 'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/82974409/homepage',
  23. 'example_request_data' => array(
  24. 'headers' => array( 'authorization' => 'Bearer YOUR_API_TOKEN' ),
  25. 'body' => array(
  26. 'is_page_on_front' => true,
  27. 'page_on_front_id' => 1,
  28. 'page_for_posts_id' => 0,
  29. ),
  30. ),
  31. 'example_response' => '{"is_page_on_front":true,"page_on_front_id":1,"page_for_posts_id":0}',
  32. ) );
  33. class WPCOM_JSON_API_Update_Site_Homepage_Endpoint extends WPCOM_JSON_API_Endpoint {
  34. function callback( $path = '', $site_id = 0 ) {
  35. $blog_id = $this->api->switch_to_blog_and_validate_user( $this->api->get_blog_id( $site_id ) );
  36. if ( is_wp_error( $blog_id ) ) {
  37. return $blog_id;
  38. }
  39. if ( ! current_user_can( 'edit_theme_options' ) ) {
  40. return new WP_Error( 'unauthorized', 'User is not authorized to access homepage settings', 403 );
  41. }
  42. $args = $this->input();
  43. if ( empty( $args ) || ! is_array( $args ) ) {
  44. return $this->get_current_settings();
  45. }
  46. if ( isset( $args['is_page_on_front'] ) ) {
  47. $show_on_front = $args['is_page_on_front'] ? 'page' : 'posts';
  48. update_option( 'show_on_front', $show_on_front );
  49. }
  50. if ( isset( $args['page_on_front_id'] ) ) {
  51. update_option( 'page_on_front', $args['page_on_front_id'] );
  52. }
  53. if ( isset( $args['page_for_posts_id'] ) ) {
  54. update_option( 'page_for_posts', $args['page_for_posts_id'] );
  55. }
  56. return $this->get_current_settings();
  57. }
  58. function get_current_settings() {
  59. $is_page_on_front = ( get_option( 'show_on_front' ) === 'page' );
  60. $page_on_front_id = get_option( 'page_on_front' );
  61. $page_for_posts_id = get_option( 'page_for_posts' );
  62. return array(
  63. 'is_page_on_front' => $is_page_on_front,
  64. 'page_on_front_id' => $page_on_front_id,
  65. 'page_for_posts_id' => $page_for_posts_id,
  66. );
  67. }
  68. }