FacebookMeta extends HtmlMeta
Generates Facebook meta tag data (Open Graph) for the <head> element of a web page.
Example usage inside a Core Theme controller method:
add_action('wp_head', function() use ($post) {
echo (string) FacebookMeta::createFromCorePost($post);
});
Table of Contents
- $appId : array<string|int, mixed>
- $description : string
- $imageHeight : int
- $imageUrl : string
- $imageWidth : int
- $modifiedOn : Carbon|null
- $pagesId : array<string|int, mixed>
- $publishedOn : Carbon|null
- $publisherUrl : string
- $section : string
- $siteName : string
- $tags : array<string|int, mixed>
- $title : string
- $type : string
- $url : string
- __toString() : string
- addAppId() : self
- Add a Facebook App ID to the set.
- addPagesId() : self
- addTag() : self
- Add a tag.
- createFromCorePost() : FacebookMeta
- getAppId() : array<string|int, mixed>
- Returns a set of Facebook App IDs.
- getDescription() : string
- getImageHeight() : int
- getImageUrl() : string
- getImageWidth() : int
- getModifiedOn() : Carbon|null
- Get the "modified on" datetime.
- getPagesId() : array<string|int, mixed>
- getPublishedOn() : Carbon|null
- Get the value of publishedOn
- getPublisherUrl() : string
- getSection() : string
- getSiteName() : string
- getTags() : array<string|int, string>
- getTitle() : string
- getType() : string
- getUrl() : string
- render() : string
- Render the component to HTML.
- setAppId() : self
- setDescription() : self
- setImageHeight() : self
- setImageUrl() : self
- setImageWidth() : self
- setModifiedOn() : self
- Set the "modifed on" datetime. If no timezone value is passed, the default is the value of wp_timezone().
- setPagesId() : self
- setPublishedOn() : self
- Set the "published on" datetime. If no timezone value is passed, the default is the value of wp_timezone().
- setPublisherUrl() : self
- setSection() : self
- setSiteName() : self
- setTags() : self
- Add a list tags. $tags may also be set as a single string or tokenized (e.g. CSV, piped).
- setTitle() : self
- setType() : self
- setUrl() : self
Properties
$appId
private
array<string|int, mixed>
$appId
= []
$description
private
string
$description
= ''
$imageHeight
private
int
$imageHeight
= 0
$imageUrl
private
string
$imageUrl
= ''
$imageWidth
private
int
$imageWidth
= 0
$modifiedOn
private
Carbon|null
$modifiedOn
= null
$pagesId
private
array<string|int, mixed>
$pagesId
= []
$publishedOn
private
Carbon|null
$publishedOn
= null
$publisherUrl
private
string
$publisherUrl
= ''
$section
private
string
$section
= ''
$siteName
private
string
$siteName
= ''
$tags
private
array<string|int, mixed>
$tags
= []
$title
private
string
$title
= ''
$type
private
string
$type
= 'website'
$url
private
string
$url
= ''
Methods
__toString()
public
__toString() : string
Return values
string —addAppId()
Add a Facebook App ID to the set.
public
addAppId(string $appId) : self
Parameters
- $appId : string
Return values
self —addPagesId()
public
addPagesId(string $pagesId) : self
Parameters
- $pagesId : string
Return values
self —addTag()
Add a tag.
public
addTag(string $tag) : self
Parameters
- $tag : string
Return values
self —createFromCorePost()
public
static createFromCorePost(CorePost $post[, string $contentType = 'article' ][, string $section = '' ]) : FacebookMeta
Parameters
- $post : CorePost
- $contentType : string = 'article'
- $section : string = ''
Return values
FacebookMeta —getAppId()
Returns a set of Facebook App IDs.
public
getAppId() : array<string|int, mixed>
Return values
array<string|int, mixed> —getDescription()
public
getDescription() : string
Return values
string —getImageHeight()
public
getImageHeight() : int
Return values
int —getImageUrl()
public
getImageUrl() : string
Return values
string —getImageWidth()
public
getImageWidth() : int
Return values
int —getModifiedOn()
Get the "modified on" datetime.
public
getModifiedOn() : Carbon|null
Return values
Carbon|null —getPagesId()
public
getPagesId() : array<string|int, mixed>
Return values
array<string|int, mixed> —getPublishedOn()
Get the value of publishedOn
public
getPublishedOn() : Carbon|null
Return values
Carbon|null —getPublisherUrl()
public
getPublisherUrl() : string
Return values
string —getSection()
public
getSection() : string
Return values
string —getSiteName()
public
getSiteName() : string
Return values
string —getTags()
public
getTags() : array<string|int, string>
Return values
array<string|int, string> —getTitle()
public
getTitle() : string
Return values
string —getType()
public
getType() : string
Return values
string —getUrl()
public
getUrl() : string
Return values
string —render()
Render the component to HTML.
public
render() : string
Return values
string —setAppId()
public
setAppId([array<string|int, mixed> $appId = [] ]) : self
Parameters
- $appId : array<string|int, mixed> = []
Return values
self —setDescription()
public
setDescription(string $description) : self
Parameters
- $description : string
Return values
self —setImageHeight()
public
setImageHeight(int $imageHeight) : self
Parameters
- $imageHeight : int
Return values
self —setImageUrl()
public
setImageUrl(string $imageUrl) : self
Parameters
- $imageUrl : string
Return values
self —setImageWidth()
public
setImageWidth(int $imageWidth) : self
Parameters
- $imageWidth : int
Return values
self —setModifiedOn()
Set the "modifed on" datetime. If no timezone value is passed, the default is the value of wp_timezone().
public
setModifiedOn(Carbon|string|int $modifiedOn[, string $timezone = '' ]) : self
Parameters
- $modifiedOn : Carbon|string|int
- $timezone : string = ''
-
Optional
Return values
self —setPagesId()
public
setPagesId([array<string|int, mixed> $pagesId = [] ]) : self
Parameters
- $pagesId : array<string|int, mixed> = []
Return values
self —setPublishedOn()
Set the "published on" datetime. If no timezone value is passed, the default is the value of wp_timezone().
public
setPublishedOn(Carbon|string|int $publishedOn[, string $timezone = '' ]) : self
Parameters
- $publishedOn : Carbon|string|int
- $timezone : string = ''
-
Optional
Return values
self —setPublisherUrl()
public
setPublisherUrl(string $publisherUrl) : self
Parameters
- $publisherUrl : string
Return values
self —setSection()
public
setSection(string $section) : self
Parameters
- $section : string
Return values
self —setSiteName()
public
setSiteName(string $siteName) : self
Parameters
- $siteName : string
Return values
self —setTags()
Add a list tags. $tags may also be set as a single string or tokenized (e.g. CSV, piped).
public
setTags(array<string|int, mixed>|string $tags[, string $token = null ]) : self
Parameters
- $tags : array<string|int, mixed>|string
- $token : string = null
-
Optional
Return values
self —setTitle()
public
setTitle(string $title) : self
Parameters
- $title : string
Return values
self —setType()
public
setType(string $type) : self
Parameters
- $type : string
Return values
self —setUrl()
public
setUrl(string $url) : self
Parameters
- $url : string