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