If you're in the admin and you want to "read" the <head />
of the frontend, you can make an internal HTTP request and scrape the response HTML:
$url = home_url();
$request = wp_remote_get( $url );
$body = wp_remote_retrieve_body( $request );
$dom = new DOMDocument();
libxml_use_internal_errors( true );
$dom->loadHTML( $body );
$xpath = new DOMXpath( $dom );
$links = $xpath->query( '/html/head/link[@rel="stylesheet"]' );
foreach ( $links as $link ) {
echo $link->getAttribute( 'href' );
echo "\n";
}
This is just example code as I don't know what exactly you're looking for - you might want to change $url
to be a specific post permalink (instead of the homepage), or you might want to change the DOM xpath to query the link
tag you're looking for directly by its attribute.