ToC added

This commit is contained in:
gabeszm 2025-01-10 11:27:58 +01:00
parent b469fae0c8
commit 8ed38752eb
10 changed files with 631 additions and 617 deletions

View file

@ -779,59 +779,6 @@ img.avatar.avatar-64.photo {
}
}
/* Keresés */
/* Search Overlay Container */
#search-overlay {
display: none;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.85);
z-index: 9999;
}
/* Centered Search Form */
#search-overlay .search-container {
position: absolute;
top: 20%;
left: 50%;
transform: translateX(-50%);
width: 80%;
max-width: 600px;
border: 1px solid;
background-color: #000;
}
/* Form Control Styling */
#search-form .form-control {
border-radius: 0;
box-shadow: none;
font-size: 18px;
}
/* Input Group Text Styling */
#search-overlay .input-group-text {
background: none;
border: none;
padding: 0.75rem;
}
.searchbox-input {
position: relative;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
-webkit-box-align: stretch;
-ms-flex-align: stretch;
align-items: stretch;
width: 100%;
border: 2px solid white;
}
/* Figure */
.hover-caption {
@ -864,3 +811,47 @@ img.avatar.avatar-64.photo {
.hover-caption figcaption {
transition: translate 200ms;
}
/**
* ToC
*/
#toc-container {
background-image: url(../../assets/img/black-paper.webp);
background-color: rgba(0, 0, 0, 0.25);
margin-bottom: 20px;
padding: 10px;
}
#toc-container details summary {
cursor: pointer;
font-weight: bold;
}
#toc-container ul {
list-style-type: none;
padding-left: 20px;
margin: 10px 0;
}
#toc-container ul li {
margin-bottom: 5px;
padding-left: 6px;
}
#toc-container ul li a {
text-decoration: none;
color: #cacaca;
}
#toc-container ul li a:hover {
text-decoration: underline;
color: #6441a5;
}
#toc-container ul li::marker {
content: "•"; /* Marker karaktere */
color: #b5b5b5; /* Marker színe */
font-size: 1.2em; /* Marker mérete */
font-weight: bold; /* Marker stílusa */
}

View file

@ -159,7 +159,7 @@
padding-left: 25px;
}
.single a.post-edit-link:hover {
background-image: url("../../assets/img/icons/1x/edit-c.png");
background-image: url("../../assets/img/icons/1x/edit-g.png");
}
.icon-padding {
@ -673,7 +673,7 @@ p.form-submit {
opacity: 0.9;
bottom: 80px;
left: 672.5px;
display: block;
display: none; /* Block az aktiváláshoz */
}
@media only screen and (max-width: 1200px) {

16
assets/js/toc.js Normal file
View file

@ -0,0 +1,16 @@
document.addEventListener("DOMContentLoaded", function () {
const tocToggle = document.getElementById("toc-toggle");
const tocContainer = document.getElementById("toc-container");
if (tocToggle && tocContainer) {
tocToggle.addEventListener("click", function () {
if (tocContainer.style.display === "none") {
tocContainer.style.display = "block";
tocToggle.textContent = "Tartalomjegyzék elrejtése";
} else {
tocContainer.style.display = "none";
tocToggle.textContent = "Tartalomjegyzék megjelenítése";
}
});
}
});

View file

@ -82,19 +82,5 @@ if ( 'option-1col' == $footer_layout ) {
</footer>
<?php wp_footer(); ?>
<!-- JavaScript for toggling search form -->
<script type="text/javascript">
document.getElementById('search-icon').addEventListener('click', function(e) {
e.preventDefault();
var searchOverlay = document.getElementById('search-overlay');
searchOverlay.style.display = 'block';
});
document.getElementById('search-overlay').addEventListener('click', function(e) {
if (e.target.id === 'search-overlay') {
this.style.display = 'none';
}
});
</script>
</body>
</html>

View file

@ -504,30 +504,12 @@ if (!function_exists("escapium_post_header")) {
}
}
// /**
// * Load custom global CSS into both block editor "iframe" and frontend
// *
// * @return void
// */
// function my_theme_enqueue_custom_global_css_in_blocks()
// {
// // Add custom CSS to frontend.
// wp_enqueue_style(
// 'my-custom-css',
// get_template_directory_uri() . '/assets/css/custom.css',
// array('global-styles', '') // say to wordpress to inject this file after the css file generated from "theme.json"
// );
// // Add custom CSS to block editor "iframe".
// add_editor_style('custom.css');
// }
// add_action('wp_head', 'my_theme_enqueue_custom_global_css_in_blocks');
function custom_comment_check()
{
// Ellenőrzi, hogy egy adott bejegyzésnél engedélyezve vannak-e a hozzászólások
if (is_single() && comments_open()) {
// Ha a hozzászólások engedélyezve vannak, két div osztály hozzáadása
echo '<div class="custom-comment-icon-wrapper">
echo '<div class="custom-comment-icon-wrapper>
<div class="custom-comment-icon"></div>
<div class="custom-tooltip">Kommentelnél? DE NEM IDE! Vicceltem, katt rám!</div>
</div>';
@ -657,8 +639,15 @@ function rp_script()
"1.0.0",
true
);
wp_enqueue_script(
"toc",
get_template_directory_uri() . "/assets/js/toc.js",
["jquery"],
"1.0.0",
true
);
}
add_action("wp_footer", "rp_script");
add_action("wp_enqueue_scripts", "rp_script");
/* Kezdőoldal címének cseréje */
function custom_homepage_title($title, $id = null)
@ -671,6 +660,9 @@ function custom_homepage_title($title, $id = null)
return $title;
}
//Logó
function rp_logo_setup()
{
@ -708,108 +700,16 @@ require_once get_template_directory() . "/template-parts/breadcrumbs.php";
* Achievement betöltése
*/
require_once get_template_directory() . "/template-parts/achievement.php";
error_log('TOC require_once lefutott.');
/* ---------------------------------------------------------------------------------------------
COMMENT FUNCTION
--------------------------------------------------------------------------------------------- */
/**
* ToC betöltése
*/
require_once get_template_directory() . "/template-parts/toc.php";
if (!function_exists("escapium_comment")) {
function escapium_comment($comment, $args, $depth)
{
switch ($comment->comment_type):
case "pingback":
case "trackback": ?>
<li <?php comment_class(); ?> id="comment-<?php comment_ID(); ?>">
<?php __(
"Pingback:",
"escapium"
); ?> <?php comment_author_link(); ?> <?php edit_comment_link(
__("(Edit)", "escapium"),
'<span class="edit-link">',
"</span>"
); ?>
</li>
<?php break;
default:
global $post; ?>
<li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
<div id="comment-<?php comment_ID(); ?>" class="comment">
<?php echo get_avatar($comment, 80); ?>
<div class="comment-inner">
<div class="comment-header">
<?php printf('<cite class="fn">%1$s</cite>', get_comment_author_link()); ?>
<p><a href="<?php echo esc_url(
get_comment_link($comment->comment_ID)
); ?>"><?php printf(
_x('%1$s at %2$s', "[date] at [time of day]", "escapium"),
get_comment_date(),
get_comment_time()
); ?></a></p>
<div class="comment-actions">
<?php edit_comment_link(__("Edit", "escapium"), "", ""); ?>
<?php comment_reply_link(
array_merge($args, [
"reply_text" => __("Reply", "escapium"),
"depth" => $depth,
"max_depth" => $args["max_depth"],
])
); ?>
<div class="clear"></div>
</div><!-- .comment-actions -->
</div><!-- .comment-header -->
<div class="comment-content">
<?php if ("0" == $comment->comment_approved): ?>
<p class="comment-awaiting-moderation"><?php _e(
"Awaiting moderation",
"escapium"
); ?></p>
<?php endif; ?>
<?php comment_text(); ?>
</div><!-- .comment-content -->
<div class="comment-actions-below hidden">
<?php edit_comment_link(__("Edit", "escapium"), "", ""); ?>
<?php comment_reply_link(
array_merge($args, [
"reply_text" => __("Reply", "escapium"),
"depth" => $depth,
"max_depth" => $args["max_depth"],
])
); ?>
<div class="clear"></div>
</div><!-- .comment-actions -->
</div><!-- .comment-inner -->
</div><!-- .comment-## -->
<?php break;
endswitch;
}
}
/**
* Custom Comments betöltése
*/
require_once get_template_directory() . "/template-parts/custom-comments.php";
?>

View file

@ -81,35 +81,10 @@
<!-- Secondary Navigation -->
<nav class="header__nav header__nav--secondary">
<ul class="social-links social-links--circle">
<li class="social-links__item">
<a class="social-links__link" href="https://search.rp1.hu" target="_blank" title="Keresés" alt="kereses"
aria-label="Keresés"><i class="fa fa-search"></i></a>
</li>
<!-- -- <div id="search-overlay">
<div class="search-container">
<form role="search" method="get" id="search-form" action="<?php echo esc_url(
home_url("/")
); ?>" class="input-group">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">
<i class="fas fa-search text-muted"></i>
</span>
</div>
<input type="search" class="form-control border-0" placeholder="Search" aria-label="search" name="s" id="search-input" value="<?php echo esc_attr(
get_search_query()
); ?>">
</div>
</form>
</div>
</div>
-->
<li class="social-links__item">
<a class="social-links__link" href="https://streamlabs.com/ravepriest1/tip" target="_blank"
title="Támogatás" alt="tamogatas" aria-label="Támogatás"><i class="fa-solid fa-wallet"></i></a>

View file

@ -27,7 +27,8 @@
<div class="content">
<div class="section-heading section-heading--divider-top">
<h3 class="section-heading__title">
<?php while (have_posts()): the_post(); ?>
<?php while (have_posts()):
the_post(); ?>
<?php the_title(); ?>
</h3>
</div>
@ -38,6 +39,7 @@
'sandbox'
);
if (function_exists("rp_display_heart_for_post")) {
rp_display_heart_for_post(get_the_ID());
}
@ -73,7 +75,9 @@
</div>
<div class="post-meta">
<p><i class="fa-regular fa-clock icon-padding"></i><?php the_time(get_option("date_format")); ?></p>
<p><i
class="fa-regular fa-clock icon-padding"></i><?php the_time(get_option("date_format")); ?>
</p>
<?php if (function_exists("zilla_likes")) {
zilla_likes();
@ -94,13 +98,15 @@
if ($prev_post): ?>
<a href="<?php the_permalink($prev_post->ID); ?>">
<i class="fa-regular fa-circle-left icon-padding"></i><?php _e("Előző bejegyzés"); ?>
<i
class="fa-regular fa-circle-left icon-padding"></i><?php _e("Előző bejegyzés"); ?>
</a>
<?php endif;
if ($next_post): ?>
<a href="<?php the_permalink($next_post->ID); ?>">
<i class="fa-regular fa-circle-right icon-padding"></i><?php _e("Következő bejegyzés"); ?>
<i
class="fa-regular fa-circle-right icon-padding"></i><?php _e("Következő bejegyzés"); ?>
</a>
<?php endif; ?>
@ -109,7 +115,6 @@
</div>
</div>
<div class="clear"></div>
</div>
</div>
@ -122,6 +127,4 @@
</main>
<?php endwhile; ?>
<?php get_footer(); ?>

View file

@ -30,7 +30,8 @@ function get_breadcrumb()
$category = get_the_category();
if (!empty($category)) {
$last_category = end(array_values($category));
$category_values = array_values($category);
$last_category = end($category_values);
$cat_parents = rtrim(get_category_parents($last_category->term_id, true, $separator), $separator);
echo '<span>' . $cat_parents . '</span>';
}

View file

@ -0,0 +1,105 @@
<?php
/* ---------------------------------------------------------------------------------------------
COMMENT FUNCTION
--------------------------------------------------------------------------------------------- */
if (!function_exists("escapium_comment")) {
function escapium_comment($comment, $args, $depth)
{
switch ($comment->comment_type):
case "pingback":
case "trackback": ?>
<li <?php comment_class(); ?> id="comment-<?php comment_ID(); ?>">
<?php __(
"Pingback:",
"escapium"
); ?> <?php comment_author_link(); ?> <?php edit_comment_link(
__("(Edit)", "escapium"),
'<span class="edit-link">',
"</span>"
); ?>
</li>
<?php break;
default:
global $post; ?>
<li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
<div id="comment-<?php comment_ID(); ?>" class="comment">
<?php echo get_avatar($comment, 80); ?>
<div class="comment-inner">
<div class="comment-header">
<?php printf('<cite class="fn">%1$s</cite>', get_comment_author_link()); ?>
<p><a href="<?php echo esc_url(
get_comment_link($comment->comment_ID)
); ?>"><?php printf(
_x('%1$s at %2$s', "[date] at [time of day]", "escapium"),
get_comment_date(),
get_comment_time()
); ?></a></p>
<div class="comment-actions">
<?php edit_comment_link(__("Edit", "escapium"), "", ""); ?>
<?php comment_reply_link(
array_merge($args, [
"reply_text" => __("Reply", "escapium"),
"depth" => $depth,
"max_depth" => $args["max_depth"],
])
); ?>
<div class="clear"></div>
</div><!-- .comment-actions -->
</div><!-- .comment-header -->
<div class="comment-content">
<?php if ("0" == $comment->comment_approved): ?>
<p class="comment-awaiting-moderation"><?php _e(
"Awaiting moderation",
"escapium"
); ?></p>
<?php endif; ?>
<?php comment_text(); ?>
</div><!-- .comment-content -->
<div class="comment-actions-below hidden">
<?php edit_comment_link(__("Edit", "escapium"), "", ""); ?>
<?php comment_reply_link(
array_merge($args, [
"reply_text" => __("Reply", "escapium"),
"depth" => $depth,
"max_depth" => $args["max_depth"],
])
); ?>
<div class="clear"></div>
</div><!-- .comment-actions -->
</div><!-- .comment-inner -->
</div><!-- .comment-## -->
<?php break;
endswitch;
}
}
?>

37
template-parts/toc.php Normal file
View file

@ -0,0 +1,37 @@
<?php
function generate_table_of_contents($content)
{
if (is_single()) {
$matches = [];
// Címsorok keresése a tartalomban (H2-H6)
preg_match_all('/<h[2-6][^>]*>(.*?)<\/h[2-6]>/', $content, $matches);
if (!empty($matches[0])) {
$toc = '<div id="toc-container">';
$toc .= '<details>';
$toc .= '<summary>Tartalomjegyzék</summary>';
$toc .= '<ul>';
foreach ($matches[1] as $key => $heading) {
$slug = 'heading-' . $key;
// Horgonypontok hozzáadása a címsorokhoz
$content = str_replace($matches[0][$key], '<a id="' . $slug . '"></a>' . $matches[0][$key], $content);
// Marker automatikusan az <li> ::marker ál-eleméhez kerül
$toc .= '<li><a href="#' . $slug . '">' . strip_tags($heading) . '</a></li>';
}
$toc .= '</ul>';
$toc .= '</details>';
$toc .= '</div>';
// TOC hozzáadása a tartalom elejére
$content = $toc . $content;
} else {
// Debug üzenet, ha nincsenek címsorok
error_log('Nincsenek címsorok a tartalomban.');
}
}
return $content;
}
add_filter('the_content', 'generate_table_of_contents');
?>