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

View File

@@ -0,0 +1,50 @@
<?php
/**
* Klasa Breadcrumbs
*
* @link https://krzysztof-turek.com
*
* @package tylkofotografia.pl
* @version 0.2
*/
class Breadcrumbs {
use Singleton;
public static function postBreadcrumbs()
{
global $wpdb, $post;
$result = $wpdb->get_results("SELECT T2.id, T2.post_title, T2.post_name, T2.post_status
FROM (
SELECT
@r AS _id,
(SELECT @r := post_parent FROM {$wpdb->prefix}posts WHERE id = _id) AS post_parent,
@l := @l + 1 AS lvl
FROM
(SELECT @r := " . $post->ID . ", @l := 0) vars,
wp_posts h
WHERE @r <> 0) T1
JOIN wp_posts T2
ON T1._id = T2.id
ORDER BY T1.lvl DESC;");
$counter = count($result);
$link = '<a href="' . get_site_url() . '/" >' . get_bloginfo('name') . '</a>';
$link .= ' / ';
foreach ($result as $page)
{
if ($page->post_status != 'draft') {
$link .= '<a href="' . get_permalink( $page->id ) . '" >' . $page->post_title . '</a>';
} else {
$link .= '' . $page->post_title . '';
}
$counter--;
if ($counter > 0)
{
$link .= ' / ';
}
}
return $link;
}
}

30
inc/classes/Character.php Normal file
View File

@@ -0,0 +1,30 @@
<?php
/**
* Klasa Tables
*
* @link https://krzysztof-turek.com
*
* @package tylkofotografia.pl
* @version 0.2
*/
class Character {
use Singleton;
function __construct() {
$this->setupFilter();
}
protected function setupFilter() {
add_filter( 'the_content', [$this, 'fontAwesome'] );
}
public function fontAwesome( $content ) {
$content = str_replace(
[ '%v%', '%x%' ],
[ '<i class="fa-solid fa-check text-success"></i>', '<i class="fa-solid fa-xmark text-danger
"></i>'],
$content
);
return $content;
}
}

40
inc/classes/Enqueue.php Normal file
View File

@@ -0,0 +1,40 @@
<?php
/**
* Klasa Enqueue
*
* @link https://krzysztof-turek.com
*
* @package tylkofotografia.pl
* @version 0.2
*/
class Enqueue {
use Singleton;
function __construct() {
add_action('wp_enqueue_scripts',[ $this, 'enqueueScripts']);
}
public function enqueueScripts() {
wp_register_style('style', get_stylesheet_uri(), [], filemtime( get_template_directory() . '/style.css'), 'all');
wp_register_style('bootstrap', get_template_directory_uri() . '/css/bootstrap.min.css', [], false, 'all');
wp_register_style('fontawesome', get_template_directory_uri() . '/css/all.min.css', [], false, 'all');
wp_register_script('bootstrap', get_template_directory_uri() . '/js/bootstrap.min.js', [], false, 'all');
wp_register_script('newsletter', get_template_directory_uri() . '/js/newsletter.js', [], false, 'all');
wp_register_script('lightbox', get_template_directory_uri() . '/js/index.bundle.min.js', [], false, 'all');
wp_enqueue_style('bootstrap');
wp_enqueue_style('fontawesome');
wp_enqueue_style('style');
wp_enqueue_script('bootstrap');
wp_enqueue_script('lightbox');
if ( is_plugin_active( 'newsletter/plugin.php' ) ) {
wp_enqueue_script('newsletter');
}
}
}

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;
}
}

23
inc/classes/Init.php Normal file
View File

@@ -0,0 +1,23 @@
<?php
/**
* Klasa Init
*
* @link https://krzysztof-turek.com
*
* @package tylkofotografia.pl
* @version 0.2
*/
class Init {
use Singleton;
function __construct() {
Setup::getInstance();
Enqueue::getInstance();
Menus::getInstance();
Character::getInstance();
Tables::getInstance();
}
}

58
inc/classes/Menus.php Normal file
View File

@@ -0,0 +1,58 @@
<?php
/**
* Klasa Menus
*
* @link https://krzysztof-turek.com
*
* @package tylkofotografia.pl
* @version 0.2
*/
class Menus {
use Singleton;
function __construct() {
$this->setupHooks();
}
protected function setupHooks() {
add_action( 'init', [ $this, 'registerMenus' ]);
}
public function registerMenus()
{
register_nav_menus([
'tf-header-menu' => esc_html__('Header Menu', 'tylkofotografia') ,
'tf-footer-menu' => esc_html__('Footer Menu', 'tylkofotografia')
]);
}
public function get_menu_id( $location ) {
$locations = get_nav_menu_locations();
if (!empty($locations)) {
return $locations[$location];
} else {
return '';
}
}
public function get_child_menu_items( $menu_array, $parent_id ) {
$child_menus = [];
if ( ! empty( $menu_array ) && is_array( $menu_array ) ) {
foreach ( $menu_array as $menu ) {
if ( intval( $menu->menu_item_parent ) === $parent_id ) {
array_push( $child_menus, $menu );
}
}
}
return $child_menus;
}
}

39
inc/classes/Setup.php Normal file
View File

@@ -0,0 +1,39 @@
<?php
/**
* Klasa Setup
*
* @link https://krzysztof-turek.com
*
* @package tylkofotografia.pl
* @version 0.2
*/
class Setup {
use Singleton;
function __construct() {
$this->setupTheme();
}
protected function setupHooks() {
add_action( 'after_setup_theme', [ $this, 'setupTheme' ] );
}
public function setupTheme() {
add_theme_support( 'title-tag' );
add_theme_support( 'post-thumbnails' );
add_theme_support(
'html5',
[
'search-form',
'comment-form',
'comment-list',
'gallery',
'caption',
'script',
'style',
]
);
add_theme_support( 'custom-header' );
}
}

32
inc/classes/Tables.php Normal file
View File

@@ -0,0 +1,32 @@
<?php
/**
* Klasa Tables
*
* @link https://krzysztof-turek.com
*
* @package tylkofotografia.pl
* @version 0.2
*/
class Tables {
use Singleton;
function __construct() {
$this->setupFilter();
}
protected function setupFilter() {
add_filter( 'the_content', [$this, 'bootstrapResponsiveTable'] );
}
public function bootstrapResponsiveTable( $content ) {
$content = preg_replace('/<table[^>]*class=["\'][^"\']*["\']/i', '<table', $content);
$content = str_replace(
[ '<table>', '</table>' ],
[ '<table class="table table-bordered table-hover table-sm">', '</table>' ],
$content
);
return $content;
}
}