forked from flatpressblog/flatpress
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
*SEO Metatag Info Plugin in the standard distribution* - includes all languages FlatPress currently supports as standard (translation via Deepl). - Content customized texts incl. placeholder as example. - With own hook in entry- and statictemplate, because otherwise the tag plugin is also shown when creating static pages; which is not supposed to be
- Loading branch information
1 parent
24595d5
commit bb436dd
Showing
16 changed files
with
1,262 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
SEO-Metatag Plugin | ||
================== | ||
|
||
This plugin helps to better present your FlatPress posts and static pages on social media and make them more readable for search engine queries. | ||
Enter a suitable description and keywords for your created static page or post. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
<?php | ||
/* | ||
* Author: Enrico Reinsdorf ([email protected]) | ||
* Author URI: www.re-design.de | ||
* Changelog: *Fixed* PHP 7.4 Methods with the same name as their class will not be constructors in a future version of PHP | ||
* Change-Date: 12.10.2022 | ||
*/ | ||
|
||
// error_reporting(E_ALL); | ||
// error_reporting(-1); | ||
// ini_set('error_reporting', E_ALL); | ||
|
||
class iniParser { | ||
|
||
var $_iniFilename = ''; | ||
var $_iniParsedArray = array(); | ||
|
||
/** | ||
* erstellt einen mehrdimensionalen Array aus der INI-Datei | ||
**/ | ||
function __construct($filename) | ||
{ | ||
$this->_iniFilename = $filename; | ||
|
||
$file_content = file($this->_iniFilename); | ||
$this->_iniParsedArray = array(); | ||
$cur_sec = false; | ||
foreach ($file_content as $line) { | ||
$line = trim($line); | ||
if (preg_match("/^\[.+\]$/",$line)) { | ||
$sec_name = str_replace(array("[", "]"), "", $line); | ||
// If this section already exists, ignore the line. | ||
if (! isset($this->_iniParsedArray[$sec_name])) { | ||
$this->_iniParsedArray [$sec_name] = array(); | ||
$cur_sec = $sec_name; | ||
} | ||
} else { | ||
$line_arr = explode('=', $line, 2); | ||
// If the line doesn't match the var=value pattern, or if it's a | ||
// comment then add it without a key. | ||
if (isset($line_arr [1]) && | ||
!(substr(trim($line_arr [0]), 0, 1) == '//' || | ||
substr(trim($line_arr [0]), 0, 1) == ';')) { | ||
$this->_iniParsedArray [$cur_sec] [$line_arr [0]] = $line_arr [1]; | ||
} else { | ||
$this->_iniParsedArray [] = $line_arr [0]; | ||
} | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* gibt die komplette Sektion zurück | ||
**/ | ||
function getSection($key) | ||
{ | ||
return $this->_iniParsedArray [$key]; | ||
} | ||
|
||
/** | ||
* gibt einen Wert aus einer Sektion zurück | ||
**/ | ||
function getValue($section, $key) | ||
{ | ||
if (!isset($this->_iniParsedArray [$section])) return false; | ||
return $this->_iniParsedArray [$section] [$key]; | ||
} | ||
|
||
/** | ||
* gibt den Wert einer Sektion oder die ganze Section zurück | ||
**/ | ||
function get($section, $key=NULL) | ||
{ | ||
if (is_null($key)) return $this->getSection($section); | ||
return $this->getValue($section, $key); | ||
} | ||
|
||
/** | ||
* Seta um valor de acordo com a chave especificada | ||
**/ | ||
function setSection($section, $array) | ||
{ | ||
if (!is_array($array)) return false; | ||
return $this->_iniParsedArray [$section] = $array; | ||
} | ||
|
||
/** | ||
* setzt einen neuen Wert in einer Section | ||
**/ | ||
function setValue($section, $key, $value) | ||
{ | ||
if ($this->_iniParsedArray [$section] [$key] = $value) return true; | ||
} | ||
|
||
/** | ||
* setzt einen neuen Wert in einer Section oder eine gesamte, neue Section | ||
**/ | ||
function set($section, $key, $value=NULL) | ||
{ | ||
if (is_array($key) && is_null($value)) return $this->setSection($section, $key); | ||
return $this->setValue($section, $key, $value); | ||
} | ||
|
||
/** | ||
* sichert den gesamten Array in die INI-Datei | ||
**/ | ||
function save($filename = null) | ||
{ | ||
if ($filename == null) $filename = $this->_iniFilename; | ||
if (is_writeable($filename)) { | ||
$SFfdescriptor = fopen($filename, "w"); | ||
foreach($this->_iniParsedArray as $section => $array){ | ||
fwrite($SFfdescriptor, "[" . $section . "]\n"); | ||
foreach($array as $key => $value) { | ||
fwrite($SFfdescriptor, "$key = $value\n"); | ||
} | ||
fwrite($SFfdescriptor, "\n"); | ||
} | ||
fclose($SFfdescriptor); | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
} | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,229 @@ | ||
<?php | ||
|
||
if (!function_exists('is_single')){ | ||
function is_single(){ | ||
global $fp_params; | ||
return (!empty($fp_params ['entry'])); | ||
} | ||
} | ||
|
||
if (!function_exists('is_comments')){ | ||
function is_comments(){ | ||
global $fp_params; | ||
return (isset($fp_params ['comments'])); | ||
} | ||
} | ||
|
||
if (!function_exists('is_static')){ | ||
function is_static(){ | ||
global $fp_params, $fp_config; | ||
return (!empty($fp_params ['page']) || | ||
(empty($fp_params) && !empty($fp_config ['general'] ['startpage'])) | ||
); | ||
} | ||
} | ||
|
||
if (!function_exists('is_static_home')){ | ||
function is_static_home(){ | ||
global $fp_params, $fp_config; | ||
return ( | ||
(empty($fp_params ['page']) && empty($fp_params) && !empty($fp_config ['general'] ['startpage'])) || | ||
(!empty($fp_params ['page']) && !empty($fp_config ['general'] ['startpage']) && | ||
$fp_params ['page'] === $fp_config ['general'] ['startpage']) | ||
); | ||
} | ||
} | ||
|
||
if (!function_exists('is_blog_home')){ | ||
function is_blog_home(){ | ||
global $fp_params, $fp_config; | ||
return ( | ||
(count(array_filter($fp_params)) === 1 && !empty($fp_params ['paged']) && $fp_params ['paged'] == 1) || | ||
(empty($fp_params) && empty($fp_config ['general'] ['startpage'])) | ||
); | ||
} | ||
} | ||
|
||
if (!function_exists('is_blog_page')){ | ||
function is_blog_page(){ | ||
global $fp_params, $fp_config; | ||
return ( | ||
(count(array_filter($fp_params)) === 1 && !empty($fp_params ['paged']) && $fp_params ['paged'] >= 1) || | ||
(empty($fp_params) && empty($fp_config ['general'] ['startpage'])) | ||
); | ||
} | ||
} | ||
|
||
if (!function_exists('is_paging')){ | ||
function is_paging(){ | ||
global $fp_params; | ||
return (!empty($fp_params ['paged']) && $fp_params ['paged'] >= 2); | ||
} | ||
} | ||
|
||
if (!function_exists('is_category')){ | ||
function is_category(){ | ||
global $fp_params; | ||
return (!empty($fp_params ['cat']) && !is_tag()); | ||
} | ||
} | ||
|
||
if (!function_exists('is_tag')){ | ||
function is_tag(){ | ||
global $fp_params; | ||
return (!empty($fp_params ['tag'])); | ||
} | ||
} | ||
|
||
if (!function_exists('is_feed')){ | ||
function is_feed(){ | ||
global $fp_params; | ||
return (!empty($fp_params ['feed'])); | ||
} | ||
} | ||
|
||
if (!function_exists('is_search')){ | ||
function is_search(){ | ||
global $fp_params; | ||
return (!empty($_GET ['q'])); | ||
} | ||
} | ||
|
||
if (!function_exists('is_contact')){ | ||
function is_contact(){ | ||
global $smarty; | ||
return ( | ||
(!empty($smarty->_tpl_vars ['SCRIPT_NAME']) && // check if contact form | ||
strpos($smarty->_tpl_vars ['SCRIPT_NAME'], 'contact.php')) | ||
); | ||
} | ||
} | ||
|
||
if (!function_exists('is_archive')){ | ||
function is_archive(){ | ||
global $fp_params; | ||
return (!is_single() && !is_static() && !is_category() && !is_tag() && | ||
(!empty($fp_params ['y']) || !empty($fp_params ['m']) || !empty($fp_params ['d']))); | ||
} | ||
} | ||
|
||
if (!function_exists('is_archive_year')){ | ||
function is_archive_year(){ | ||
global $fp_params; | ||
return (is_archive() && | ||
(!empty($fp_params ['y']) && | ||
(empty($fp_params ['m']) && empty($fp_params ['d'])) | ||
) | ||
); | ||
} | ||
} | ||
if (!function_exists('is_archive_month')){ | ||
function is_archive_month(){ | ||
global $fp_params; | ||
return (is_archive() && | ||
( | ||
(!empty($fp_params ['y']) && !empty($fp_params ['m'])) && | ||
empty($fp_params ['d']) | ||
) | ||
); | ||
} | ||
} | ||
if (!function_exists('is_archive_day')){ | ||
function is_archive_day(){ | ||
global $fp_params; | ||
return (is_archive() && | ||
(!empty($fp_params ['y']) && !empty($fp_params ['m']) && !empty($fp_params ['d']))); | ||
} | ||
} | ||
|
||
if (!function_exists('get_category_name')){ | ||
function get_category_name($catid){ | ||
$category_names = entry_categories_get('defs'); | ||
return (!empty($category_names [$catid]) ?$category_names [$catid]:""); | ||
} | ||
} | ||
|
||
if (!function_exists('pathinfo_filename')){ | ||
function pathinfo_filename($file) { //file.name.ext, returns file.name | ||
if (defined('PATHINFO_FILENAME')) return pathinfo($file,PATHINFO_FILENAME); | ||
if (strstr($file, '.')) return substr($file,0,strrpos($file,'.')); | ||
} | ||
} | ||
|
||
if (!function_exists('currentPageURL')){ | ||
function currentPageURL() { | ||
$curpageURL = 'http'; | ||
if ($_SERVER ["HTTPS"] == "on") {$curpageURL.= "s";} | ||
$curpageURL .= "://"; | ||
if ($_SERVER ["SERVER_PORT"] != "80") { | ||
// $curpageURL.= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; | ||
$curpageURL .= $_SERVER ["SERVER_NAME"] . $_SERVER ["REQUEST_URI"]; | ||
} else { | ||
$curpageURL .= $_SERVER ["SERVER_NAME"] . $_SERVER ["REQUEST_URI"]; | ||
} | ||
return $curpageURL; | ||
} | ||
} | ||
|
||
// removes files and non-empty directories | ||
if (!function_exists('rrmdir')){ | ||
function rrmdir($dir) { | ||
if (is_dir($dir)) { | ||
$files = scandir($dir); | ||
foreach ($files as $file) | ||
if ($file != "." && $file != "..") rrmdir("$dir/$file"); | ||
rmdir($dir); | ||
} | ||
else if (file_exists($dir)) unlink($dir); | ||
} | ||
} | ||
// copies files and non-empty directories | ||
if (!function_exists('rcopy')){ | ||
function rcopy($src, $dst) { | ||
if (file_exists($dst)) rrmdir($dst); | ||
if (is_dir($src)) { | ||
mkdir($dst); | ||
$files = scandir($src); | ||
foreach ($files as $file) | ||
if ($file != "." && $file != "..") | ||
rcopy("$src/$file", "$dst/$file"); | ||
} | ||
else if (file_exists($src)) copy($src, $dst); | ||
} | ||
} | ||
|
||
function is_empty_dir($dir){ | ||
if ($dh = @opendir($dir)) | ||
{ | ||
while ($file = readdir($dh)) | ||
{ | ||
if ($file != '.' && $file != '..') { | ||
closedir($dh); | ||
return false; | ||
} | ||
} | ||
closedir($dh); | ||
return true; | ||
} | ||
else return false; // whatever the reason is : no such dir, not a dir, not readable | ||
} | ||
|
||
// debug | ||
if (!function_exists('echoPre')){ | ||
function echoPre($value, $print=true){ | ||
$output = ''; | ||
if ($value){ | ||
$output .= "<pre>"; | ||
$output .= print_r($value, true); | ||
$output .= "</pre><br>"; | ||
if ($print) | ||
echo $output; | ||
else | ||
return $output; | ||
} | ||
return false; | ||
} | ||
} | ||
|
||
?> | ||
|
Oops, something went wrong.