Initial commit

This commit is contained in:
2026-01-15 12:23:11 +01:00
commit 92fc092460
52 changed files with 2283 additions and 0 deletions

43
inc/classes/Excerpt.php Normal file
View File

@@ -0,0 +1,43 @@
<?php
/**
* Klasa Excerpt
*
* @link https://krzysztof-turek.com
*
* @package tylkofotografia.pl
* @version 0.2
*/
class Excerpt {
use Singleton;
function __construct() {
}
public static function improvedExcerpt($text, $length)
{
global $shortcode_tags;
if ('' != $text)
{
$text = get_the_content('');
$text = strip_shortcodes($text);
$text = apply_filters('the_content', $text);
$text = str_replace('\]\]\>', ']]&gt;', $text);
$text = preg_replace('@<script[^>]*?>.*?</script>@si', '', $text);
$text = preg_replace('@<figcaption[^>]*?>.*?</figcaption>@si', '', $text);
$text = strip_tags($text);
$text = trim($text);
$words = explode(' ', $text, $length + 1);
if (count($words) > $length)
{
array_pop($words);
$text = trim(implode(' ', $words)) . '...';
}
}
$text = preg_replace('/\s\s+/', ' ', $text);
return $text;
}
}