Custom Logo is one of the awesome features of WordPress 4.5. You can see release detail of WordPress 4.5 “Coleman” here. Detail of Custom Logo is here. This link gives you detailed explanation of declaring support for Custom Logo and parameters available.
I needed to update my theme to use Custom Logo. But my all themes has logo option available. Image field was provided in the Customizer for logo. In the implementation of this new feature, existing logo was not supposed to be lost. So, I had to add new update script which will import old logo if set by use in existing theme.
Earlier, logo was displayed like following. Logo was saved in theme mod with key
Update script I used is given below. I have tried to comment each step as much as possible as inline comments.
What is happening here?
awesome_import_logo_fieldfunction is hooked to
- Function will bail if WordPress version is lower than 4.5.
- Existing logo is fetched. If there is existing logo then, find corresponding attachment ID and set it to Custom Logo.
custom_logokey is used in theme mod by Custom Logo.
- You also need to remove old logo after successful import.
In latest release of WordPress 4.5, another striking feature is support of partial refresh in Customizer. See Selective Refresh in the Customizer. Good thing is that Custom Logo automatically support this feature. You may have noticed this in Customizer. When logo is changed or removed, whole page is not refreshed, only section of logo is changed. It is faster and provides better user experience.
One more thing
You have already declared support for Custom Logo. And you also have old logo option in Customizer. So, you may want to hide your old logo option with version compare. For WP >= 4.5, Logo field provided by core will be displayed. On lower version your theme option will work as earlier.