Skip to content

Commit

Permalink
Site Logo: Update url for site icon settings with fallback for WP cor…
Browse files Browse the repository at this point in the history
…e versions earlier than 6.5 (#59485)

* Site Logo: Update url for site icon settings with fallback for WP core versions earlier than 6.5

* Move PHP changes to compat.php file

Co-authored-by: andrewserong <andrewserong@git.wordpress.org>
Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>
Co-authored-by: tellthemachines <isabel_brison@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: carolinan <poena@git.wordpress.org>
Co-authored-by: richtabor <richtabor@git.wordpress.org>
Co-authored-by: aaronjorbin <jorbin@git.wordpress.org>
  • Loading branch information
9 people committed Mar 1, 2024
1 parent c53b018 commit 1b5360c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
15 changes: 15 additions & 0 deletions lib/compat/wordpress-6.5/compat.php
Expand Up @@ -36,3 +36,18 @@ function array_is_list( $arr ) {
return true;
}
}

/**
* Sets a global JS variable used to flag whether to direct the Site Logo block's admin urls
* to the Customizer. This allows Gutenberg running on versions of WordPress < 6.5.0 to
* support the previous location for the Site Icon settings. This function should not be
* backported to core, and should be removed when the required WP core version for Gutenberg
* is >= 6.5.0.
*/
function gutenberg_add_use_customizer_site_logo_url_flag() {
if ( ! is_wp_version_compatible( '6.5' ) ) {
wp_add_inline_script( 'wp-block-editor', 'window.__experimentalUseCustomizerSiteLogoUrl = true', 'before' );
}
}

add_action( 'admin_init', 'gutenberg_add_use_customizer_site_logo_url_flag' );
13 changes: 9 additions & 4 deletions packages/block-library/src/site-logo/edit.js
Expand Up @@ -268,6 +268,14 @@ const SiteLogo = ( {
</ResizableBox>
);

// Support the previous location for the Site Icon settings. To be removed
// when the required WP core version for Gutenberg is >= 6.5.0.
const shouldUseNewUrl = ! window?.__experimentalUseCustomizerSiteLogoUrl;

const siteIconSettingsUrl = shouldUseNewUrl
? siteUrl + '/wp-admin/options-general.php'
: siteUrl + '/wp-admin/customize.php?autofocus[section]=title_tagline';

const syncSiteIconHelpText = createInterpolateElement(
__(
'Site Icons are what you see in browser tabs, bookmark bars, and within the WordPress mobile apps. To use a custom icon that is different from your site logo, use the <a>Site Icon settings</a>.'
Expand All @@ -276,10 +284,7 @@ const SiteLogo = ( {
a: (
// eslint-disable-next-line jsx-a11y/anchor-has-content
<a
href={
siteUrl +
'/wp-admin/customize.php?autofocus[section]=title_tagline'
}
href={ siteIconSettingsUrl }
target="_blank"
rel="noopener noreferrer"
/>
Expand Down

0 comments on commit 1b5360c

Please sign in to comment.