ldc-sbv/wp-content/plugins/wordpress-seo/admin/tracking/class-tracking-theme-data.php

50 lines
976 B
PHP
Raw Normal View History

2021-09-21 15:01:08 +02:00
<?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\Tracking
*/
/**
* Represents the theme data.
*/
class WPSEO_Tracking_Theme_Data implements WPSEO_Collection {
/**
* Returns the collection data.
*
* @return array The collection data.
*/
public function get() {
$theme = wp_get_theme();
2021-09-21 15:05:30 +02:00
return [
'theme' => [
2021-09-21 15:01:08 +02:00
'name' => $theme->get( 'Name' ),
'url' => $theme->get( 'ThemeURI' ),
'version' => $theme->get( 'Version' ),
2021-09-21 15:05:30 +02:00
'author' => [
2021-09-21 15:01:08 +02:00
'name' => $theme->get( 'Author' ),
'url' => $theme->get( 'AuthorURI' ),
2021-09-21 15:05:30 +02:00
],
2021-09-21 15:01:08 +02:00
'parentTheme' => $this->get_parent_theme( $theme ),
2021-09-21 15:05:30 +02:00
],
];
2021-09-21 15:01:08 +02:00
}
/**
* Returns the name of the parent theme.
*
* @param WP_Theme $theme The theme object.
*
2021-09-21 15:05:30 +02:00
* @return string|null The name of the parent theme or null.
2021-09-21 15:01:08 +02:00
*/
private function get_parent_theme( WP_Theme $theme ) {
if ( is_child_theme() ) {
return $theme->get( 'Template' );
}
return null;
}
}