本文整理汇总了PHP中EasyBlogHelper::stripEmbedTags方法的典型用法代码示例。如果您正苦于以下问题:PHP EasyBlogHelper::stripEmbedTags方法的具体用法?PHP EasyBlogHelper::stripEmbedTags怎么用?PHP EasyBlogHelper::stripEmbedTags使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EasyBlogHelper
的用法示例。
在下文中一共展示了EasyBlogHelper::stripEmbedTags方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addCard
public static function addCard(&$blog, $rawIntroText)
{
$cfg = EasyBlogHelper::getConfig();
// @rule: Check if user really wants to append the opengraph tags on the headers.
if (!$cfg->get('main_twitter_cards')) {
return false;
}
// Get the absolute permalink for this blog item.
$url = EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=entry&id=' . $blog->id, false, true);
// Get the image of the blog post.
$image = self::getImage($blog, $rawIntroText);
// @task: Get Joomla's document object.
$doc = JFactory::getDocument();
// Add card definition.
$doc->addCustomTag('<meta property="twitter:card" content="summary" />');
$doc->addCustomTag('<meta property="twitter:url" content="' . $url . '" />');
$doc->addCustomTag('<meta property="twitter:title" content="' . $blog->title . '" />');
$text = EasyBlogHelper::stripEmbedTags($rawIntroText);
$text = strip_tags($text);
$text = str_ireplace("\r\n", "", $text);
// Remove any " in the content as this would mess up the headers.
$text = str_ireplace('"', '', $text);
$maxLength = 137;
if (!empty($maxLength)) {
$text = JString::strlen($text) > $maxLength ? JString::substr($text, 0, $maxLength) . '...' : $text;
}
$text = EasyBlogStringHelper::escape($text);
$doc->addCustomTag('<meta property="twitter:description" content="' . $text . '" />');
if ($image) {
$doc->addCustomTag('<meta property="twitter:image" content="' . $image . '"/> ');
}
return true;
}
示例2: addOpenGraphTags
public static function addOpenGraphTags(&$blog, $rawIntroText = '')
{
$cfg = EasyBlogHelper::getConfig();
// @rule: Check if user really wants to append the opengraph tags on the headers.
if (!$cfg->get('main_facebook_opengraph')) {
return false;
}
// Get the absolute permalink for this blog item.
$url = EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=entry&id=' . $blog->id, false, true);
// Get the image of the blog post.
$image = self::getImage($blog, $rawIntroText);
// @task: Get Joomla's document object.
$doc = JFactory::getDocument();
// Add the blog image.
$doc->addCustomTag('<meta property="og:image" content="' . $image . '"/> ');
if ($cfg->get('main_facebook_like')) {
$doc->addCustomTag('<meta property="fb:app_id" content="' . $cfg->get('main_facebook_like_appid') . '"/> ');
$doc->addCustomTag('<meta property="fb:admins" content="' . $cfg->get('main_facebook_like_admin') . '"/>');
}
$meta = EasyBlogHelper::getTable('Meta', 'Table');
$meta->loadByType(META_TYPE_POST, $blog->id);
$doc->addCustomTag('<meta property="og:title" content="' . $blog->title . '" />');
// @task: Add description of the blog.
if (!empty($meta->description)) {
$meta->description = EasyBlogStringHelper::escape($meta->description);
$doc->addCustomTag('<meta property="og:description" content="' . $meta->description . '" />');
} else {
$maxLength = $cfg->get('integrations_facebook_blogs_length');
$text = EasyBlogHelper::stripEmbedTags($rawIntroText);
$text = strip_tags($text);
$text = str_ireplace("\r\n", "", $text);
// Remove any " in the content as this would mess up the headers.
$text = str_ireplace('"', '', $text);
if (!empty($maxLength)) {
$text = JString::strlen($text) > $maxLength ? JString::substr($text, 0, $maxLength) . '...' : $text;
}
$text = EasyBlogStringHelper::escape($text);
$doc->addCustomTag('<meta property="og:description" content="' . $text . '" />');
}
$doc->addCustomTag('<meta property="og:type" content="article" />');
$doc->addCustomTag('<meta property="og:url" content="' . $url . '" />');
return true;
}