This commit is contained in:
Ty Clifford
2026-07-03 07:31:09 -04:00
commit cebb0d3af1
800 changed files with 89782 additions and 0 deletions
@@ -0,0 +1,7 @@
{
"default-image": "Standardbillede",
"plugin-data": {
"description": "Med X (tidligere Twitter) kort kan du vedhæfte vigtige billeder, videoer og medieoplevelser til opslag, hvilket hjælper med at få trafik på din hjemmeside.",
"name": "X/Twitter Cards"
}
}
@@ -0,0 +1,7 @@
{
"plugin-data": {
"name": "X/Twitter Cards",
"description": "X (ehemals Twitter) Cards hängt Medien wie Bilder oder Videos an einen Beitrag, wenn ein Link der Website auf X geteilt wird."
},
"default-image": "Standardbild"
}
@@ -0,0 +1,7 @@
{
"plugin-data": {
"name": "X/Twitter Cards",
"description": "X (ehemals Twitter) Cards hängt Medien wie Bilder oder Videos an einen Beitrag, wenn ein Link der Website auf X geteilt wird."
},
"default-image": "Standardbild"
}
@@ -0,0 +1,8 @@
{
"plugin-data":
{
"name": "X/Twitter Cards",
"description": "With X (formerly Twitter) Cards, you can attach rich photos, videos and media experiences to posts, helping to drive traffic to your website."
},
"default-image": "Default image"
}
@@ -0,0 +1,8 @@
{
"plugin-data":
{
"name": "X/Twitter Cards",
"description": "Con las tarjetas de X (antes Twitter) puedes adjuntar fotos, videos y experiencias multimedia a publicaciones."
},
"default-image": "Imagen predeterminada"
}
@@ -0,0 +1,8 @@
{
"plugin-data":
{
"name": "X/Twitter Cards",
"description": "بوسیله X (قبلاً Twitter) Cards ، شما می‌توانید تصاویر، ویدئو و تجربیات رسانه ای را به پست‌ها پیوست کرده، و با اینکار کمکی می‌شود تا ترافیک بیشتری به سمت وبسایت شما روانه شود."
},
"default-image": "تصویر پیش‌فرض"
}
@@ -0,0 +1,8 @@
{
"plugin-data":
{
"name": "Cartes X/Twitter",
"description": "Les Cartes X (anciennement Twitter) sont des protocoles qui vous permettent d'attacher des photos, des vidéos et autres médias interactifs à vos publications, cela vas vous aider à générer du trafic vers votre site."
},
"default-image": "Image par défaut."
}
@@ -0,0 +1,8 @@
{
"plugin-data":
{
"name": "X/Twitter Cards",
"description": "Con X (precedentemente Twitter) Cards, puoi aggiungere foto, video e media ai tuoi post, aiutando a guidare il traffico sul tuo sito."
},
"default-image": "Immagine predefinita"
}
@@ -0,0 +1,8 @@
{
"plugin-data":
{
"name": "X/Twitter Cards",
"description": "X(旧Twitter)カードを使用すると、投稿にリッチな写真、動画、メディア体験を添付して、ウェブサイトへのトラフィックを増やすことができます。"
},
"default-image": "デフォルト画像"
}
@@ -0,0 +1,8 @@
{
"plugin-data":
{
"name": "X/Twitter Cards",
"description": "Met X (voorheen Twitter) Cards kunnen foto's, video's and media-ervaringen worden gekoppeld aan berichten om zo bezoekers naar deze website te trekken."
},
"default-image": "Standaardafbeelding"
}
@@ -0,0 +1,8 @@
{
"plugin-data":
{
"name": "X/Twitter Cards",
"description": "С помощью X (ранее Twitter) Cards вы можете добавить фото, видео и медиа к публикациям, тем самым привлекая дополнительный трафик для вашего сайта."
},
"default-image": "Изображение по умолчанию"
}
@@ -0,0 +1,8 @@
{
"plugin-data":
{
"name": "X/Twitter Cards",
"description": "X (eski adıyla Twitter) Kartları ile zengin fotoğraf, video ve medya deneyimlerini gönderilere ekleyebilir ve web sitenize trafik çekmenize yardımcı olabilirsiniz."
},
"default-image": "Varsayılan resim"
}
+10
View File
@@ -0,0 +1,10 @@
{
"author": "Bludit",
"email": "",
"website": "https://plugins.bludit.com",
"version": "3.22.0",
"releaseDate": "2026-05-10",
"license": "MIT",
"compatible": "3.22",
"notes": ""
}
+149
View File
@@ -0,0 +1,149 @@
<?php
class pluginTwitterCards extends Plugin
{
public function init()
{
// Fields and default values for the database of this plugin
$this->dbFields = array(
'defaultImage' => '',
'twitterSite' => '',
'cardType' => 'summary_large_image'
);
}
public function form()
{
global $L;
$html = '<div class="alert alert-primary" role="alert">';
$html .= $this->description();
$html .= '</div>';
$html .= '<div>';
$html .= '<label>Twitter @username</label>';
$html .= '<input name="twitterSite" type="text" dir="auto" value="' . $this->getValue('twitterSite') . '" placeholder="@username">';
$html .= '<span class="tip">Your Twitter @username for twitter:site attribution</span>';
$html .= '</div>';
$html .= '<div>';
$html .= '<label>Card Type</label>';
$html .= '<select name="cardType">';
$html .= '<option value="summary_large_image"' . ($this->getValue('cardType') === 'summary_large_image' ? ' selected' : '') . '>Summary with Large Image (recommended)</option>';
$html .= '<option value="summary"' . ($this->getValue('cardType') === 'summary' ? ' selected' : '') . '>Summary</option>';
$html .= '</select>';
$html .= '<span class="tip">Large image cards get better engagement on Twitter</span>';
$html .= '</div>';
$html .= '<div>';
$html .= '<label>' . $L->get('Default image') . '</label>';
$html .= '<input id="jsdefaultImage" name="defaultImage" type="text" dir="auto" value="' . $this->getValue('defaultImage') . '" placeholder="https://">';
$html .= '<span class="tip">Fallback image when content has no image</span>';
$html .= '</div>';
return $html;
}
/**
* Sanitize and escape content for use in meta tags
*/
private function sanitize($text, $maxLength = 0)
{
// Strip HTML tags
$text = strip_tags($text);
// Decode HTML entities first to avoid double encoding
$text = html_entity_decode($text, ENT_QUOTES, 'UTF-8');
// Trim whitespace
$text = trim($text);
// Truncate if needed (Twitter has limits)
if ($maxLength > 0 && mb_strlen($text, 'UTF-8') > $maxLength) {
$text = mb_substr($text, 0, $maxLength, 'UTF-8') . '...';
}
// Escape for HTML attribute
return htmlspecialchars($text, ENT_QUOTES, 'UTF-8');
}
public function siteHead()
{
global $url;
global $site;
global $WHERE_AM_I;
global $content;
global $page;
$cardType = $this->getValue('cardType');
if (empty($cardType)) {
$cardType = 'summary_large_image';
}
$data = array(
'card' => $cardType,
'site' => $this->getValue('twitterSite'),
'title' => $this->sanitize($site->title(), 70),
'description' => $this->sanitize($site->description(), 200),
'image' => '',
'imageAlt' => ''
);
switch ($WHERE_AM_I) {
case 'page':
$data['title'] = $this->sanitize($page->title(), 70);
// Get description: use page description or fallback to content excerpt
$description = $page->description();
if (empty($description)) {
$description = Text::truncate(strip_tags($page->contentRaw()), 160);
}
$data['description'] = $this->sanitize($description, 200);
$data['image'] = $page->coverImage($absolute = true);
$data['imageAlt'] = $data['title'];
$pageContent = $page->content();
break;
default:
$pageContent = '';
if (Text::isNotEmpty($this->getValue('defaultImage'))) {
$data['image'] = $this->getValue('defaultImage');
} elseif (isset($content[0])) {
$data['image'] = $content[0]->coverImage($absolute = true);
$data['imageAlt'] = $this->sanitize($content[0]->title(), 70);
$pageContent = $content[0]->content();
}
break;
}
// Build HTML output
$html = PHP_EOL . '<!-- Twitter Cards -->' . PHP_EOL;
$html .= '<meta name="twitter:card" content="' . $data['card'] . '">' . PHP_EOL;
// Add site handle if configured
if (!empty($data['site'])) {
$html .= '<meta name="twitter:site" content="' . $this->sanitize($data['site']) . '">' . PHP_EOL;
}
$html .= '<meta name="twitter:title" content="' . $data['title'] . '">' . PHP_EOL;
$html .= '<meta name="twitter:description" content="' . $data['description'] . '">' . PHP_EOL;
// If the page doesn't have a coverImage try to get an image from the HTML content
if (empty($data['image'])) {
$src = DOM::getFirstImage($pageContent);
if ($src !== false) {
$data['image'] = $src;
} elseif (Text::isNotEmpty($this->getValue('defaultImage'))) {
$data['image'] = $this->getValue('defaultImage');
}
}
// Add image with alt text for accessibility
if (!empty($data['image'])) {
$html .= '<meta name="twitter:image" content="' . $data['image'] . '">' . PHP_EOL;
if (!empty($data['imageAlt'])) {
$html .= '<meta name="twitter:image:alt" content="' . $data['imageAlt'] . '">' . PHP_EOL;
}
}
return $html;
}
}