Skip to content

Commit

Permalink
Site Logo: Rename sitelogo to site_logo (#31511)
Browse files Browse the repository at this point in the history
  • Loading branch information
creativecoder authored May 11, 2021
1 parent e0756da commit e6129cf
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
16 changes: 8 additions & 8 deletions packages/block-library/src/site-logo/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,30 +255,30 @@ export default function LogoEdit( {
const [ logoUrl, setLogoUrl ] = useState();
const [ error, setError ] = useState();
const ref = useRef();
const { mediaItemData, sitelogo, url } = useSelect( ( select ) => {
const { mediaItemData, siteLogo, url } = useSelect( ( select ) => {
const siteSettings = select( coreStore ).getEditedEntityRecord(
'root',
'site'
);
const mediaItem = select( coreStore ).getEntityRecord(
'root',
'media',
siteSettings.sitelogo
siteSettings.site_logo
);
return {
mediaItemData: mediaItem && {
url: mediaItem.source_url,
alt: mediaItem.alt_text,
},
sitelogo: siteSettings.sitelogo,
siteLogo: siteSettings.site_logo,
url: siteSettings.url,
};
}, [] );

const { editEntityRecord } = useDispatch( coreStore );
const setLogo = ( newValue ) =>
editEntityRecord( 'root', 'site', undefined, {
sitelogo: newValue,
site_logo: newValue,
} );

let alt = null;
Expand All @@ -296,13 +296,13 @@ export default function LogoEdit( {

if ( ! media.id && media.url ) {
// This is a temporary blob image
setLogo( '' );
setError();
setLogo( undefined );
setError( null );
setLogoUrl( media.url );
return;
}

setLogo( media.id.toString() );
setLogo( media.id );
};

const onUploadError = ( message ) => {
Expand All @@ -323,7 +323,7 @@ export default function LogoEdit( {

const label = __( 'Site Logo' );
let logoImage;
if ( sitelogo === undefined ) {
if ( siteLogo === undefined ) {
logoImage = <Spinner />;
}

Expand Down
14 changes: 7 additions & 7 deletions packages/block-library/src/site-logo/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ function register_block_core_site_logo() {
* @return string The site logo if set.
*/
function override_custom_logo_theme_mod( $custom_logo ) {
$sitelogo = get_option( 'sitelogo' );
return false === $sitelogo ? $custom_logo : $sitelogo;
$site_logo = get_option( 'site_logo' );
return false === $site_logo ? $custom_logo : $site_logo;
}

/**
Expand All @@ -99,9 +99,9 @@ function sync_site_logo_to_theme_mod( $custom_logo ) {
// Delete the option when the custom logo does not exist or was removed.
// This step ensures the option stays in sync.
if ( empty( $custom_logo ) ) {
delete_option( 'sitelogo' );
delete_option( 'site_logo' );
} else {
update_option( 'sitelogo', $custom_logo );
update_option( 'site_logo', $custom_logo );
}
return $custom_logo;
}
Expand All @@ -112,12 +112,12 @@ function sync_site_logo_to_theme_mod( $custom_logo ) {
function register_block_core_site_logo_setting() {
register_setting(
'general',
'sitelogo',
'site_logo',
array(
'show_in_rest' => array(
'name' => 'sitelogo',
'name' => 'site_logo',
),
'type' => 'string',
'type' => 'integer',
'description' => __( 'Site logo.' ),
)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import EntityTypeList from './entity-type-list';
const TRANSLATED_SITE_PROTPERTIES = {
title: __( 'Title' ),
description: __( 'Tagline' ),
sitelogo: __( 'Logo' ),
site_logo: __( 'Logo' ),
show_on_front: __( 'Show on front' ),
page_on_front: __( 'Page on front' ),
};
Expand Down

0 comments on commit e6129cf

Please sign in to comment.