class-tracking-theme-data.php 976 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /**
  3. * WPSEO plugin file.
  4. *
  5. * @package WPSEO\Admin\Tracking
  6. */
  7. /**
  8. * Represents the theme data.
  9. */
  10. class WPSEO_Tracking_Theme_Data implements WPSEO_Collection {
  11. /**
  12. * Returns the collection data.
  13. *
  14. * @return array The collection data.
  15. */
  16. public function get() {
  17. $theme = wp_get_theme();
  18. return [
  19. 'theme' => [
  20. 'name' => $theme->get( 'Name' ),
  21. 'url' => $theme->get( 'ThemeURI' ),
  22. 'version' => $theme->get( 'Version' ),
  23. 'author' => [
  24. 'name' => $theme->get( 'Author' ),
  25. 'url' => $theme->get( 'AuthorURI' ),
  26. ],
  27. 'parentTheme' => $this->get_parent_theme( $theme ),
  28. ],
  29. ];
  30. }
  31. /**
  32. * Returns the name of the parent theme.
  33. *
  34. * @param WP_Theme $theme The theme object.
  35. *
  36. * @return null|string The name of the parent theme or null.
  37. */
  38. private function get_parent_theme( WP_Theme $theme ) {
  39. if ( is_child_theme() ) {
  40. return $theme->get( 'Template' );
  41. }
  42. return null;
  43. }
  44. }