summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/jetpack/json-endpoints/class.wpcom-json-api-update-site-logo-endpoint.php')
-rw-r--r--plugins/jetpack/json-endpoints/class.wpcom-json-api-update-site-logo-endpoint.php25
1 files changed, 12 insertions, 13 deletions
diff --git a/plugins/jetpack/json-endpoints/class.wpcom-json-api-update-site-logo-endpoint.php b/plugins/jetpack/json-endpoints/class.wpcom-json-api-update-site-logo-endpoint.php
index 2ccca0a9..996601d7 100644
--- a/plugins/jetpack/json-endpoints/class.wpcom-json-api-update-site-logo-endpoint.php
+++ b/plugins/jetpack/json-endpoints/class.wpcom-json-api-update-site-logo-endpoint.php
@@ -12,7 +12,7 @@ new WPCOM_JSON_API_Update_Site_Logo_Endpoint( array (
),
'request_format' => array(
'id' => '(int) The ID of the logo post',
- 'url' => '(string) The URL of the logo post',
+ 'url' => '(string) The URL of the logo post (deprecated)',
),
'response_format' => array(
'id' => '(int) The ID of the logo post',
@@ -23,7 +23,6 @@ new WPCOM_JSON_API_Update_Site_Logo_Endpoint( array (
'headers' => array( 'authorization' => 'Bearer YOUR_API_TOKEN' ),
'body' => array(
'id' => 12345,
- 'url' => 'https://s.w.org/about/images/logos/codeispoetry-rgb.png',
),
),
'example_response' => '
@@ -68,29 +67,29 @@ class WPCOM_JSON_API_Update_Site_Logo_Endpoint extends WPCOM_JSON_API_Endpoint {
$args = $this->input();
$logo_settings = $this->get_current_settings();
+
if ( empty( $args ) || ! is_array( $args ) ) {
return $logo_settings;
}
if ( isset( $args['id'] ) ) {
- $logo_settings['id'] = intval( $args['id'], 10 );
- }
- if ( isset( $args['url'] ) ) {
- $logo_settings['url'] = $args['url'];
- }
- if ( isset( $args['url'] ) || isset( $args['id'] ) ) {
- update_option( 'site_logo', $logo_settings );
+ update_option( 'site_logo', (int) $args['id'] );
}
return $this->get_current_settings();
}
function get_current_settings() {
- $logo_settings = get_option( 'site_logo' );
- if ( ! is_array( $logo_settings ) ) {
- $logo_settings = array();
+ $logo_id = get_option( 'site_logo' );
+
+ if ( ! $logo_id ) {
+ return array();
}
- return $logo_settings;
+
+ return array(
+ 'id' => $logo_id,
+ 'url' => wp_get_attachment_url( $logo_id ),
+ );
}
}