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 */ /* Figure */
.hover-caption { .hover-caption {
@ -864,3 +811,47 @@ img.avatar.avatar-64.photo {
.hover-caption figcaption { .hover-caption figcaption {
transition: translate 200ms; 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 */
}

File diff suppressed because it is too large Load diff

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> </footer>
<?php wp_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> </body>
</html> </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() function custom_comment_check()
{ {
// Ellenőrzi, hogy egy adott bejegyzésnél engedélyezve vannak-e a hozzászólások // Ellenőrzi, hogy egy adott bejegyzésnél engedélyezve vannak-e a hozzászólások
if (is_single() && comments_open()) { if (is_single() && comments_open()) {
// Ha a hozzászólások engedélyezve vannak, két div osztály hozzáadása // 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-comment-icon"></div>
<div class="custom-tooltip">Kommentelnél? DE NEM IDE! Vicceltem, katt rám!</div> <div class="custom-tooltip">Kommentelnél? DE NEM IDE! Vicceltem, katt rám!</div>
</div>'; </div>';
@ -657,8 +639,15 @@ function rp_script()
"1.0.0", "1.0.0",
true 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 */ /* Kezdőoldal címének cseréje */
function custom_homepage_title($title, $id = null) function custom_homepage_title($title, $id = null)
@ -671,6 +660,9 @@ function custom_homepage_title($title, $id = null)
return $title; return $title;
} }
//Logó //Logó
function rp_logo_setup() function rp_logo_setup()
{ {
@ -708,108 +700,16 @@ require_once get_template_directory() . "/template-parts/breadcrumbs.php";
* Achievement betöltése * Achievement betöltése
*/ */
require_once get_template_directory() . "/template-parts/achievement.php"; 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) * Custom Comments betöltése
{ */
switch ($comment->comment_type): require_once get_template_directory() . "/template-parts/custom-comments.php";
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;
}
}
?> ?>

View file

@ -81,35 +81,10 @@
<!-- Secondary Navigation --> <!-- Secondary Navigation -->
<nav class="header__nav header__nav--secondary"> <nav class="header__nav header__nav--secondary">
<ul class="social-links social-links--circle"> <ul class="social-links social-links--circle">
<li class="social-links__item">
<li class="social-links__item">
<a class="social-links__link" href="https://search.rp1.hu" target="_blank" title="Keresés" alt="kereses" <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> aria-label="Keresés"><i class="fa fa-search"></i></a>
</li> </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"> <li class="social-links__item">
<a class="social-links__link" href="https://streamlabs.com/ravepriest1/tip" target="_blank" <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> title="Támogatás" alt="tamogatas" aria-label="Támogatás"><i class="fa-solid fa-wallet"></i></a>

View file

@ -1,23 +1,23 @@
<?php get_header(); ?> <?php get_header(); ?>
<div class="page-heading"> <div class="page-heading">
<div class="page-heading__inner"> <div class="page-heading__inner">
<div class="container"> <div class="container">
<?php while (have_posts()): <?php while (have_posts()):
the_post(); ?> the_post(); ?>
<h2 class="page-heading__title page-heading__post-title"> <h2 class="page-heading__title page-heading__post-title">
<?php the_title(); ?> <?php the_title(); ?>
</h2> </h2>
<div class="breadcrumb breadcrumb-item active"> <div class="breadcrumb breadcrumb-item active">
<?php if (function_exists("get_breadcrumb")) { <?php if (function_exists("get_breadcrumb")) {
get_breadcrumb(); get_breadcrumb();
} ?> } ?>
</div> </div>
<?php <?php
endwhile; ?> endwhile; ?>
</div> </div>
</div> </div>
</div> </div>
<main class="site-content"> <main class="site-content">
@ -27,101 +27,104 @@
<div class="content"> <div class="content">
<div class="section-heading section-heading--divider-top"> <div class="section-heading section-heading--divider-top">
<h3 class="section-heading__title"> <h3 class="section-heading__title">
<?php while (have_posts()): the_post(); ?> <?php while (have_posts()):
the_post(); ?>
<?php the_title(); ?> <?php the_title(); ?>
</h3> </h3>
</div> </div>
<?php
the_content(
'<br><span class="btn btn-inverse">View More</span>',
'sandbox'
);
if (function_exists("rp_display_heart_for_post")) {
rp_display_heart_for_post(get_the_ID());
}
?>
<!-- // INFO: Szerző megjelenítése --> <?php
<div class="box-author"> the_content(
<div class="author"> '<br><span class="btn btn-inverse">View More</span>',
<div class="author-content"> 'sandbox'
<h4><?php the_author(); ?></h4> );
<?php if (get_the_author_meta("description")) {
echo wpautop(get_the_author_meta("description")); if (function_exists("rp_display_heart_for_post")) {
rp_display_heart_for_post(get_the_ID());
}
?>
<!-- // INFO: Szerző megjelenítése -->
<div class="box-author">
<div class="author">
<div class="author-content">
<h4><?php the_author(); ?></h4>
<?php if (get_the_author_meta("description")) {
echo wpautop(get_the_author_meta("description"));
} ?>
<div class="author-links">
<a class="author-link-posts" title="Szerző írásai"
href="<?php echo get_author_posts_url(get_the_author_meta("ID")); ?>"></a>
<?php
$author_url = get_the_author_meta("user_url");
if (!empty($author_url)): ?>
<a class="author-link-website" title="Szerző oldala"
href="<?php echo esc_url($author_url); ?>"></a>
<?php endif; ?>
</div>
</div>
<!-- // INFO: Közreműködők -->
<?php if (function_exists("display_co_authors")) {
display_co_authors();
} ?>
</div>
<div class="post-meta">
<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();
} ?> } ?>
<div class="author-links"> <p><i class="fa-solid fa-folder icon-padding"></i><?php the_category(", "); ?></p>
<a class="author-link-posts" title="Szerző írásai"
href="<?php echo get_author_posts_url(get_the_author_meta("ID")); ?>"></a>
<?php if (has_tag()): ?>
<p><i class="fa-solid fa-tag icon-padding"></i><?php the_tags("", ", "); ?></p>
<?php endif; ?>
<div class="clear"></div>
<div class="post-nav">
<?php <?php
$author_url = get_the_author_meta("user_url"); $prev_post = get_previous_post();
if (!empty($author_url)): ?> $next_post = get_next_post();
<a class="author-link-website" title="Szerző oldala"
href="<?php echo esc_url($author_url); ?>"></a> 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"); ?>
</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"); ?>
</a>
<?php endif; ?> <?php endif; ?>
<?php edit_post_link(__("Bejegyzés szerkesztése")); ?>
<div class="clear"></div>
</div> </div>
</div> </div>
<!-- // INFO: Közreműködők -->
<?php if (function_exists("display_co_authors")) {
display_co_authors();
} ?>
</div>
<div class="post-meta">
<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();
} ?>
<p><i class="fa-solid fa-folder icon-padding"></i><?php the_category(", "); ?></p>
<?php if (has_tag()): ?>
<p><i class="fa-solid fa-tag icon-padding"></i><?php the_tags("", ", "); ?></p>
<?php endif; ?>
<div class="clear"></div>
<div class="post-nav">
<?php
$prev_post = get_previous_post();
$next_post = get_next_post();
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"); ?>
</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"); ?>
</a>
<?php endif; ?>
<?php edit_post_link(__("Bejegyzés szerkesztése")); ?>
<div class="clear"></div> <div class="clear"></div>
</div> </div>
</div> </div>
<div style="height:60px" aria-hidden="true" class="wp-block-spacer"></div>
<hr class="hr">
<div class="clear"></div> <?php comments_template("", true); ?>
</div>
</div> </div>
<div style="height:60px" aria-hidden="true" class="wp-block-spacer"></div>
<hr class="hr">
<?php comments_template("", true); ?>
</div> </div>
</div> </div>
</div> </main>
</main>
<?php endwhile; ?> <?php endwhile; ?>
<?php get_footer(); ?>
<?php get_footer(); ?>

View file

@ -30,7 +30,8 @@ function get_breadcrumb()
$category = get_the_category(); $category = get_the_category();
if (!empty($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); $cat_parents = rtrim(get_category_parents($last_category->term_id, true, $separator), $separator);
echo '<span>' . $cat_parents . '</span>'; 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');
?>