From f33ad92dedc70719bd0c7cd616dd5c85210ade6e Mon Sep 17 00:00:00 2001 From: ANAGNOSTOPOULOS Konstantinos Date: Wed, 12 Dec 2018 12:31:10 +0100 Subject: [PATCH] FEAT: http-equiv q'n dirty --- src/OutputPageHtmlTagsInserter.php | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/OutputPageHtmlTagsInserter.php b/src/OutputPageHtmlTagsInserter.php index f8cd5cc..1b057f9 100644 --- a/src/OutputPageHtmlTagsInserter.php +++ b/src/OutputPageHtmlTagsInserter.php @@ -106,6 +106,10 @@ public function addTagContentToOutputPage( $tag, $content ) { return $this->addMetaPropertyMarkup( $tag, $content ); } + if ( $this->reqMetaHttpEquivs( $tag ) ) { + return $this->addMetaHttpEquivMarkup( $tag, $content ); + } + $this->outputPage->addMeta( $tag, $content ); } @@ -140,4 +144,30 @@ private function reqMetaPropertyMarkup( $tag ) { return false; } + private function reqMetaHttpEquivs( $tag ) { + + // If a tag contains a `og:` such as `og:title` it is expected to be a + // OpenGraph protocol tag along with other prefixes maintained in + // $GLOBALS['smtgMetaPropertyPrefixes'] + return in_array( $tag, $GLOBALS['smtgMetaHttpEquivs'] ); + } + + private function addMetaHttpEquivMarkup( $tag, $content ) { + + $comment = ''; + + if ( !$this->metaPropertyMarkup ) { + $comment .= '' . "\n"; + $this->metaPropertyMarkup = true; + } + + $content = $comment . \Html::element( 'meta', [ + 'http-equiv' => $tag, + 'content' => $content + ] ); + + $this->outputPage->addHeadItem( "meta:property:$tag", $content ); + } + + }