✨ Add a social network plugin
This commit is contained in:
parent
dcf00a1f71
commit
449a3be3a8
7 changed files with 104 additions and 0 deletions
|
@ -106,6 +106,7 @@ include(PATH_KERNEL . 'url.class.php');
|
||||||
include(PATH_KERNEL . 'login.class.php');
|
include(PATH_KERNEL . 'login.class.php');
|
||||||
include(PATH_KERNEL . 'parsedown.class.php');
|
include(PATH_KERNEL . 'parsedown.class.php');
|
||||||
include(PATH_KERNEL . 'security.class.php');
|
include(PATH_KERNEL . 'security.class.php');
|
||||||
|
include(PATH_KERNEL . 'social.class.php');
|
||||||
|
|
||||||
// Include functions
|
// Include functions
|
||||||
include(PATH_KERNEL . 'functions.php');
|
include(PATH_KERNEL . 'functions.php');
|
||||||
|
|
|
@ -20,6 +20,22 @@ class Theme
|
||||||
return $GLOBALS['SOCIAL_NETWORKS_EMOJI'][Text::cleanUrl($socialNetwork)];
|
return $GLOBALS['SOCIAL_NETWORKS_EMOJI'][Text::cleanUrl($socialNetwork)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function listSiteSocials($list = true, $emoji = false) {
|
||||||
|
global $site;
|
||||||
|
$socialList = Theme::socialNetworks();
|
||||||
|
|
||||||
|
$socialString = ($list == true) ? "<ul class='social-networks'>" : "";
|
||||||
|
foreach ($socialList as $key => $name) {
|
||||||
|
$social = new Social($name, $site->getSocialNetwork($name));
|
||||||
|
$socialString .= (($list == true) ? "<li class='social'>" : "");
|
||||||
|
$socialString = $socialString . $social->getLink($emoji);
|
||||||
|
$socialString .= (($list == true) ? "</li>" : "");
|
||||||
|
}
|
||||||
|
|
||||||
|
$socialString .= (($list == true) ? "</ul>" : "");
|
||||||
|
return $socialString;
|
||||||
|
}
|
||||||
|
|
||||||
public static function title()
|
public static function title()
|
||||||
{
|
{
|
||||||
global $site;
|
global $site;
|
||||||
|
|
22
bl-kernel/social.class.php
Normal file
22
bl-kernel/social.class.php
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
<?php defined('KOBLOG') or die('Koblog CMS.');
|
||||||
|
|
||||||
|
class Social {
|
||||||
|
|
||||||
|
public $slug;
|
||||||
|
public $url;
|
||||||
|
public $emoji;
|
||||||
|
public $name;
|
||||||
|
|
||||||
|
function __construct($name, $url)
|
||||||
|
{
|
||||||
|
$this->name = $name;
|
||||||
|
$this->slug = Text::cleanUrl($name);
|
||||||
|
$this->emoji = $GLOBALS['SOCIAL_NETWORKS_EMOJI'][$this->slug];
|
||||||
|
$this->url = $url;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getLink($useEmoji = false) {
|
||||||
|
return "<a href='". $this->url ."' rel='me'>".($useEmoji ? '<span aria-hidden="true">'.$this->emoji."</span>" : ""). " " . $this->name."</a>";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
7
bl-plugins/socials/languages/en.json
Normal file
7
bl-plugins/socials/languages/en.json
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"plugin-data":
|
||||||
|
{
|
||||||
|
"name": "Social Networks",
|
||||||
|
"description": "Shows the social network list in the sidebar."
|
||||||
|
}
|
||||||
|
}
|
7
bl-plugins/socials/languages/fr_FR.json
Normal file
7
bl-plugins/socials/languages/fr_FR.json
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"plugin-data":
|
||||||
|
{
|
||||||
|
"name": "Réseaux sociaux",
|
||||||
|
"description": "Affiche la liste des réseaux sociaux dans la barre latérale."
|
||||||
|
}
|
||||||
|
}
|
11
bl-plugins/socials/metadata.json
Normal file
11
bl-plugins/socials/metadata.json
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
"author": "Koblog",
|
||||||
|
"email": "",
|
||||||
|
"website": "https://plugins.koblog.com",
|
||||||
|
"version": "kb_0.0.1",
|
||||||
|
"releaseDate": "2024-08-23",
|
||||||
|
"license": "MIT",
|
||||||
|
"compatible": "kb_0.0.1",
|
||||||
|
"notes": "",
|
||||||
|
"type": "widget"
|
||||||
|
}
|
40
bl-plugins/socials/plugin.php
Normal file
40
bl-plugins/socials/plugin.php
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class pluginSocials extends Plugin {
|
||||||
|
|
||||||
|
public function init()
|
||||||
|
{
|
||||||
|
$this->dbFields = array(
|
||||||
|
'label' => 'Social Networks',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function form()
|
||||||
|
{
|
||||||
|
global $L;
|
||||||
|
|
||||||
|
$html = '<div>';
|
||||||
|
$html .= '<label>' . $L->get('Label') . '</label>';
|
||||||
|
$html .= '<input name="label" type="text" dir="auto" value="' . $this->getValue('label') . '">';
|
||||||
|
$html .= '<span class="tip">' . $L->get('This title is almost always used in the sidebar of the site') . '</span>';
|
||||||
|
$html .= '</div>';
|
||||||
|
|
||||||
|
return $html;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method called on the sidebar of the website
|
||||||
|
public function siteSidebar()
|
||||||
|
{
|
||||||
|
global $L;
|
||||||
|
global $url;
|
||||||
|
|
||||||
|
$html = '<div class="plugin plugin-archives">';
|
||||||
|
$html .= '<h2 class="plugin-label">' . $this->getValue('label') . '</h2>';
|
||||||
|
$html .= '<div class="plugin-content">';
|
||||||
|
$html .= Theme::listSiteSocials(true, true);
|
||||||
|
$html .= '</div>';
|
||||||
|
$html .= '</div>';
|
||||||
|
return $html;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue