site-logo.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /*
  3. * Site Logo.
  4. * @see http://jetpack.com/support/site-logo/
  5. *
  6. * This feature will only be activated for themes that declare their support.
  7. * This can be done by adding code similar to the following during the
  8. * 'after_setup_theme' action:
  9. *
  10. * $args = array(
  11. * 'header-text' => array(
  12. * 'site-title',
  13. * 'site-description',
  14. * ),
  15. * 'size' => 'medium',
  16. * );
  17. * add_theme_support( 'site-logo', $args );
  18. *
  19. */
  20. /**
  21. * Activate the Site Logo plugin.
  22. *
  23. * @uses current_theme_supports()
  24. * @since 3.2
  25. */
  26. function site_logo_init() {
  27. // For transferring existing site logo from Jetpack -> Core
  28. if ( current_theme_supports( 'custom-logo' ) && ! get_theme_mod( 'custom_logo' ) && $jp_logo = get_option( 'site_logo' ) ) {
  29. set_theme_mod( 'custom_logo', $jp_logo['id'] );
  30. delete_option( 'site_logo' );
  31. }
  32. // Only load our code if our theme declares support, and the standalone plugin is not activated.
  33. if ( current_theme_supports( 'site-logo' ) && ! class_exists( 'Site_Logo', false ) ) {
  34. // Load our class for namespacing.
  35. require( dirname( __FILE__ ) . '/site-logo/inc/class-site-logo.php' );
  36. // Load template tags.
  37. require( dirname( __FILE__ ) . '/site-logo/inc/functions.php' );
  38. // Load backwards-compatible template tags.
  39. require( dirname( __FILE__ ) . '/site-logo/inc/compat.php' );
  40. }
  41. }
  42. add_action( 'init', 'site_logo_init' );