summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYury German <blueknight@gentoo.org>2022-06-15 12:08:35 -0400
committerYury German <blueknight@gentoo.org>2022-06-15 12:08:35 -0400
commit36d7691c33cb64ece817246e47a779ec648d10b0 (patch)
tree08f2fb95303a1d8eeba2c8629a24b35a91fb1cac /plugins/jetpack/json-endpoints/class.wpcom-json-api-update-site-homepage-endpoint.php
parenttwentyfourteen upg 2.7 to 3.2 and twentysixteen from 2.0 to 2.5 (diff)
downloadblogs-gentoo-36d7691c33cb64ece817246e47a779ec648d10b0.tar.gz
blogs-gentoo-36d7691c33cb64ece817246e47a779ec648d10b0.tar.bz2
blogs-gentoo-36d7691c33cb64ece817246e47a779ec648d10b0.zip
Openid-3.6.1 and jetpack-11.0 upgrade
Signed-off-by: Yury German <blueknight@gentoo.org>
Diffstat (limited to 'plugins/jetpack/json-endpoints/class.wpcom-json-api-update-site-homepage-endpoint.php')
-rw-r--r--plugins/jetpack/json-endpoints/class.wpcom-json-api-update-site-homepage-endpoint.php96
1 files changed, 58 insertions, 38 deletions
diff --git a/plugins/jetpack/json-endpoints/class.wpcom-json-api-update-site-homepage-endpoint.php b/plugins/jetpack/json-endpoints/class.wpcom-json-api-update-site-homepage-endpoint.php
index 16d24940..88b2a8b5 100644
--- a/plugins/jetpack/json-endpoints/class.wpcom-json-api-update-site-homepage-endpoint.php
+++ b/plugins/jetpack/json-endpoints/class.wpcom-json-api-update-site-homepage-endpoint.php
@@ -1,40 +1,55 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
+/**
+ * Set site homepage settings API endpoint.
+ *
+ * Endpoint: /sites/%s/homepage
+ */
-new WPCOM_JSON_API_Update_Site_Homepage_Endpoint( array (
- 'description' => 'Set site homepage settings',
- 'group' => '__do_not_document',
- 'stat' => 'sites:1:homepage',
- 'method' => 'POST',
- 'min_version' => '1.1',
- 'path' => '/sites/%s/homepage',
- 'path_labels' => array(
- '$site' => '(string) Site ID or domain.',
- ),
- 'request_format' => array(
- 'is_page_on_front' => '(bool) True if we will use a page as the homepage; false to use a blog page as the homepage.',
- 'page_on_front_id' => '(int) Optional. The ID of the page to use as the homepage if is_page_on_front is true.',
- 'page_for_posts_id' => '(int) Optional. The ID of the page to use as the blog page if is_page_on_front is true.',
- ),
- 'response_format' => array(
- 'is_page_on_front' => '(bool) True if we will use a page as the homepage; false to use a blog page as the homepage.',
- 'page_on_front_id' => '(int) The ID of the page to use as the homepage if is_page_on_front is true.',
- 'page_for_posts_id' => '(int) The ID of the page to use as the blog page if is_page_on_front is true.',
- ),
- 'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/82974409/homepage',
- 'example_request_data' => array(
- 'headers' => array( 'authorization' => 'Bearer YOUR_API_TOKEN' ),
- 'body' => array(
- 'is_page_on_front' => true,
- 'page_on_front_id' => 1,
- 'page_for_posts_id' => 0,
+new WPCOM_JSON_API_Update_Site_Homepage_Endpoint(
+ array(
+ 'description' => 'Set site homepage settings',
+ 'group' => '__do_not_document',
+ 'stat' => 'sites:1:homepage',
+ 'method' => 'POST',
+ 'min_version' => '1.1',
+ 'path' => '/sites/%s/homepage',
+ 'path_labels' => array(
+ '$site' => '(string) Site ID or domain.',
),
- ),
- 'example_response' => '{"is_page_on_front":true,"page_on_front_id":1,"page_for_posts_id":0}',
-) );
+ 'request_format' => array(
+ 'is_page_on_front' => '(bool) True if we will use a page as the homepage; false to use a blog page as the homepage.',
+ 'page_on_front_id' => '(int) Optional. The ID of the page to use as the homepage if is_page_on_front is true.',
+ 'page_for_posts_id' => '(int) Optional. The ID of the page to use as the blog page if is_page_on_front is true.',
+ ),
+ 'response_format' => array(
+ 'is_page_on_front' => '(bool) True if we will use a page as the homepage; false to use a blog page as the homepage.',
+ 'page_on_front_id' => '(int) The ID of the page to use as the homepage if is_page_on_front is true.',
+ 'page_for_posts_id' => '(int) The ID of the page to use as the blog page if is_page_on_front is true.',
+ ),
+ 'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/82974409/homepage',
+ 'example_request_data' => array(
+ 'headers' => array( 'authorization' => 'Bearer YOUR_API_TOKEN' ),
+ 'body' => array(
+ 'is_page_on_front' => true,
+ 'page_on_front_id' => 1,
+ 'page_for_posts_id' => 0,
+ ),
+ ),
+ 'example_response' => '{"is_page_on_front":true,"page_on_front_id":1,"page_for_posts_id":0}',
+ )
+);
+/**
+ * Site homepage setting endpoint class.
+ */
class WPCOM_JSON_API_Update_Site_Homepage_Endpoint extends WPCOM_JSON_API_Endpoint {
-
- function callback( $path = '', $site_id = 0 ) {
+ /**
+ * Set site homepage setting API callback.
+ *
+ * @param string $path API path.
+ * @param int $site_id Blog ID.
+ */
+ public function callback( $path = '', $site_id = 0 ) {
$blog_id = $this->api->switch_to_blog_and_validate_user( $this->api->get_blog_id( $site_id ) );
if ( is_wp_error( $blog_id ) ) {
return $blog_id;
@@ -63,14 +78,19 @@ class WPCOM_JSON_API_Update_Site_Homepage_Endpoint extends WPCOM_JSON_API_Endpoi
return $this->get_current_settings();
}
- function get_current_settings() {
- $is_page_on_front = ( get_option( 'show_on_front' ) === 'page' );
- $page_on_front_id = get_option( 'page_on_front' );
+ /**
+ * Get current site homepage settings.
+ *
+ * @return array
+ */
+ public function get_current_settings() {
+ $is_page_on_front = ( get_option( 'show_on_front' ) === 'page' );
+ $page_on_front_id = get_option( 'page_on_front' );
$page_for_posts_id = get_option( 'page_for_posts' );
return array(
- 'is_page_on_front' => $is_page_on_front,
- 'page_on_front_id' => $page_on_front_id,
+ 'is_page_on_front' => $is_page_on_front,
+ 'page_on_front_id' => $page_on_front_id,
'page_for_posts_id' => $page_for_posts_id,
);
}