WP_Debug_Data::get_wp_parent_theme(): array

In this article

This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

Gets the WordPress parent theme section of the debug data.

Return

array

Source

private static function get_wp_parent_theme(): array {
	$theme_updates = get_theme_updates();
	$transient     = get_site_transient( 'update_themes' );

	$auto_updates         = array();
	$auto_updates_enabled = wp_is_auto_update_enabled_for_type( 'theme' );
	if ( $auto_updates_enabled ) {
		$auto_updates = (array) get_site_option( 'auto_update_themes', array() );
	}

	$active_theme = wp_get_theme();
	$parent_theme = $active_theme->parent();
	$fields       = array();

	if ( $parent_theme ) {
		$parent_theme_version       = $parent_theme->version;
		$parent_theme_version_debug = $parent_theme_version;

		if ( array_key_exists( $parent_theme->stylesheet, $theme_updates ) ) {
			$parent_theme_update_new_version = $theme_updates[ $parent_theme->stylesheet ]->update['new_version'];

			/* translators: %s: Latest theme version number. */
			$parent_theme_version       .= ' ' . sprintf( __( '(Latest version: %s)' ), $parent_theme_update_new_version );
			$parent_theme_version_debug .= sprintf( ' (latest version: %s)', $parent_theme_update_new_version );
		}

		$parent_theme_author_uri = $parent_theme->display( 'AuthorURI' );

		$fields = array(
			'name'           => array(
				'label' => __( 'Name' ),
				'value' => sprintf(
					/* translators: 1: Theme name. 2: Theme slug. */
					__( '%1$s (%2$s)' ),
					$parent_theme->name,
					$parent_theme->stylesheet
				),
			),
			'version'        => array(
				'label' => __( 'Version' ),
				'value' => $parent_theme_version,
				'debug' => $parent_theme_version_debug,
			),
			'author'         => array(
				'label' => __( 'Author' ),
				'value' => wp_kses( $parent_theme->author, array() ),
			),
			'author_website' => array(
				'label' => __( 'Author website' ),
				'value' => ( $parent_theme_author_uri ? $parent_theme_author_uri : __( 'Undefined' ) ),
				'debug' => ( $parent_theme_author_uri ? $parent_theme_author_uri : '(undefined)' ),
			),
			'theme_path'     => array(
				'label' => __( 'Theme directory location' ),
				'value' => get_template_directory(),
			),
		);

		if ( $auto_updates_enabled ) {
			if ( isset( $transient->response[ $parent_theme->stylesheet ] ) ) {
				$item = $transient->response[ $parent_theme->stylesheet ];
			} elseif ( isset( $transient->no_update[ $parent_theme->stylesheet ] ) ) {
				$item = $transient->no_update[ $parent_theme->stylesheet ];
			} else {
				$item = array(
					'theme'        => $parent_theme->stylesheet,
					'new_version'  => $parent_theme->version,
					'url'          => '',
					'package'      => '',
					'requires'     => '',
					'requires_php' => '',
				);
			}

			$auto_update_forced = wp_is_auto_update_forced_for_item( 'theme', null, (object) $item );

			if ( ! is_null( $auto_update_forced ) ) {
				$enabled = $auto_update_forced;
			} else {
				$enabled = in_array( $parent_theme->stylesheet, $auto_updates, true );
			}

			if ( $enabled ) {
				$parent_theme_auto_update_string = __( 'Enabled' );
			} else {
				$parent_theme_auto_update_string = __( 'Disabled' );
			}

			/** This filter is documented in wp-admin/includes/class-wp-debug-data.php */
			$parent_theme_auto_update_string = apply_filters( 'theme_auto_update_debug_string', $parent_theme_auto_update_string, $parent_theme, $enabled );

			$fields['auto_update'] = array(
				'label' => __( 'Auto-update' ),
				'value' => $parent_theme_auto_update_string,
				'debug' => $parent_theme_auto_update_string,
			);
		}
	}

	return array(
		'label'  => __( 'Parent Theme' ),
		'fields' => $fields,
	);
}

Hooks

apply_filters( ‘theme_auto_update_debug_string’, string $auto_updates_string, WP_Theme $theme, bool $enabled )

Filters the text string of the auto-updates setting for each theme in the Site Health debug data.

Changelog

VersionDescription
6.7.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.