wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



_sync_custom_logo_to_site_logo › WordPress Function

Seitn/v
Veraltetn/v
_sync_custom_logo_to_site_logo ( $old_value, $value )
Parameter: (2)
  • (mixed) $old_value The old option value.
    Erforderlich: Ja
  • (mixed) $value The new option value.
    Erforderlich: Ja
Definiert in:
Codex:

Updates the site_logo option when the custom_logo theme-mod gets updated.

This function is hooked on "update_option_thememods$theme" and not "pre_set_theme_mod_custom_logo" because by hooking in update_option the function accounts for remove_theme_mod() as well.


Quellcode

function _sync_custom_logo_to_site_logo( $old_value, $value ) {
	// Delete the option when the custom logo does not exist or was removed.
	// This step ensures the option stays in sync.
	if ( empty( $value['custom_logo'] ) ) {
		delete_option( 'site_logo' );
	} else {
		remove_action( 'update_option_site_logo', '_sync_site_logo_to_custom_logo' );
		update_option( 'site_logo', $value['custom_logo'] );
		add_action( 'update_option_site_logo', '_sync_site_logo_to_custom_logo', 10, 2 );
	}
}