Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEAT: http-equiv meta tags #49

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/OutputPageHtmlTagsInserter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}

Expand Down Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be adapted. This is the identical comment copied from the following lines:

// 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']

// 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 ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if we need this here too, since this HTML comment is already added via the following lines

if ( !$this->metaPropertyMarkup ) {
$comment .= '<!-- Semantic MetaTags -->' . "\n";
$this->metaPropertyMarkup = true;
}

$comment .= '<!-- Semantic MetaTags -->' . "\n";
$this->metaPropertyMarkup = true;
}

$content = $comment . \Html::element( 'meta', [
'http-equiv' => $tag,
'content' => $content
] );

$this->outputPage->addHeadItem( "meta:property:$tag", $content );
}


}