Alert: 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.

LLMS_Certificates::modify_dom_links( DOMDocument $dom )

Modify head’s s of the DOMDocument.


Parameters Parameters

$dom

(DOMDocument) (Required) The DOMDocument containing the certificate.


Top ↑

Return Return

(void)


Top ↑

Source Source

File: includes/class.llms.certificates.php

	private function modify_dom_links( $dom ) {

		// Get all <links>.
		$links      = $dom->getElementsByTagName( 'link' );
		$to_replace = array();

		// Inline stylesheets.
		foreach ( $links as $link ) {

			// Only proceed for stylesheets.
			if ( 'stylesheet' !== $link->getAttribute( 'rel' ) ) {
				continue;
			}

			$raw = $this->get_stylesheet_raw( $link->getAttribute( 'href' ) );

			if ( empty( $raw ) ) {
				continue;
			}

			// Add it to be inlined late.
			$tag          = $dom->createElement( 'style', $raw );
			$to_replace[] = array(
				'old' => $link,
				'new' => $tag,
			);

		}

		// Do replacements, ensures cascade order is retained.
		foreach ( $to_replace as $replacement ) {
			$replacement['old']->parentNode->replaceChild( $replacement['new'], $replacement['old'] );
		}

		// Remove all remaining non stylesheet <links>.
		$links = $dom->getElementsByTagName( 'link' );
		while ( $links && $links->length ) {
			$links->item( 0 )->parentNode->removeChild( $links->item( 0 ) );
		}

	}


Top ↑

Changelog Changelog

Changelog
Version Description
4.21.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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