Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Site Logo: Rename sitelogo to site_logo #31511

Merged
merged 4 commits into from
May 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -233,30 +233,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 @@ -274,13 +274,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 @@ -301,7 +301,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 @@ -66,8 +66,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 @@ -81,9 +81,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 @@ -94,12 +94,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