summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYury German <blueknight@gentoo.org>2022-01-23 18:37:36 -0500
committerYury German <blueknight@gentoo.org>2022-01-23 18:37:36 -0500
commitf18b23a3a9378fb0a98856d436aa9ebf94e47429 (patch)
treee418433e22854ebd2d77eaa869d5d0470a973317 /plugins/jetpack/modules/theme-tools/site-logo.php
parentAdd classic-editor 1.5 (diff)
downloadblogs-gentoo-f18b23a3a9378fb0a98856d436aa9ebf94e47429.tar.gz
blogs-gentoo-f18b23a3a9378fb0a98856d436aa9ebf94e47429.tar.bz2
blogs-gentoo-f18b23a3a9378fb0a98856d436aa9ebf94e47429.zip
Updating Classic Editor, Google Authenticatior, Jetpack, Public Post Preview, Table of Contents, Wordpress Importer
Signed-off-by: Yury German <blueknight@gentoo.org>
Diffstat (limited to 'plugins/jetpack/modules/theme-tools/site-logo.php')
-rw-r--r--plugins/jetpack/modules/theme-tools/site-logo.php46
1 files changed, 39 insertions, 7 deletions
diff --git a/plugins/jetpack/modules/theme-tools/site-logo.php b/plugins/jetpack/modules/theme-tools/site-logo.php
index cef77e69..78f69ba1 100644
--- a/plugins/jetpack/modules/theme-tools/site-logo.php
+++ b/plugins/jetpack/modules/theme-tools/site-logo.php
@@ -22,15 +22,10 @@
* Activate the Site Logo plugin.
*
* @uses current_theme_supports()
- * @since 3.2
+ * @since 3.2.0
+ * @since 9.9.0 Uses Core site_logo option format universally.
*/
function site_logo_init() {
- // For transferring existing site logo from Jetpack -> Core
- if ( current_theme_supports( 'custom-logo' ) && ! get_theme_mod( 'custom_logo' ) && $jp_logo = get_option( 'site_logo' ) ) {
- set_theme_mod( 'custom_logo', $jp_logo['id'] );
- delete_option( 'site_logo' );
- }
-
// Only load our code if our theme declares support, and the standalone plugin is not activated.
if ( current_theme_supports( 'site-logo' ) && ! class_exists( 'Site_Logo', false ) ) {
// Load our class for namespacing.
@@ -44,3 +39,40 @@ function site_logo_init() {
}
}
add_action( 'init', 'site_logo_init' );
+
+/**
+ * When switching from a legacy theme that uses `site-logo` to a theme that uses `custom-logo`,
+ * update the theme's custom logo if it doesn't already have one.
+ *
+ * @return void
+ */
+function jetpack_update_custom_logo_from_site_logo() {
+ $site_logo = get_option( 'site_logo' );
+
+ if ( current_theme_supports( 'custom-logo' ) && ! get_theme_mod( 'custom_logo' ) && $site_logo ) {
+ set_theme_mod( 'custom_logo', $site_logo );
+ }
+}
+add_action( 'after_switch_theme', 'jetpack_update_custom_logo_from_site_logo', 10, 0 );
+
+/**
+ * Transforms the legacy site_logo array, when present, into an attachment ID.
+ *
+ * The attachment ID is the format used for the site_logo option by the Site Logo block,
+ * and the updated Jetpack site-logo feature.
+ *
+ * @since 9.9.0
+ *
+ * @param int|array $site_logo Option.
+ * @return int
+ */
+function jetpack_site_logo_block_compat( $site_logo ) {
+ if ( isset( $site_logo['id'] ) ) {
+ remove_filter( 'option_site_logo', 'jetpack_site_logo_block_compat', 1 );
+ update_option( 'site_logo', $site_logo['id'] );
+ return $site_logo['id'];
+ }
+
+ return $site_logo;
+}
+add_filter( 'option_site_logo', 'jetpack_site_logo_block_compat', 1 );