Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
makura-2025
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Raj Shah
makura-2025
Commits
51f48f21
Commit
51f48f21
authored
Jan 02, 2025
by
rajshah
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
toc done
parent
837811b9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
104 additions
and
78 deletions
+104
-78
style.js
assets/js/style.js
+19
-0
single-post.php
single-post.php
+85
-78
No files found.
assets/js/style.js
View file @
51f48f21
...
@@ -540,4 +540,23 @@
...
@@ -540,4 +540,23 @@
});
});
});
});
});
});
/* Table of Content */
function
sanitizeTitle
(
text
)
{
return
text
.
toString
()
.
trim
()
// Remove leading and trailing whitespace
.
toLowerCase
()
// Convert to lowercase
.
replace
(
/
[^
a-z0-9
\s
-
]
/g
,
""
)
// Remove special characters
.
replace
(
/
\s
+/g
,
"-"
)
// Replace spaces with hyphens
.
replace
(
/-+/g
,
"-"
);
// Remove multiple consecutive hyphens
}
$
(
function
()
{
$
(
".blog-detail-content h2, .blog-detail-content h3"
).
each
(
function
()
{
var
text
=
$
(
this
).
text
();
var
sanitizedText
=
sanitizeTitle
(
text
);
$
(
this
).
attr
(
"id"
,
sanitizedText
);
});
});
})(
jQuery
);
})(
jQuery
);
single-post.php
View file @
51f48f21
...
@@ -50,9 +50,9 @@ get_header();
...
@@ -50,9 +50,9 @@ get_header();
</defs>
</defs>
</svg>
</svg>
<?php
<?php
$post_content
=
get_the_content
();
$post_content
=
get_the_content
();
$reading_time
=
calculate_reading_time
(
$post_content
);
$reading_time
=
calculate_reading_time
(
$post_content
);
echo
$reading_time
;
?>
mins read
echo
$reading_time
;
?>
mins read
</div>
</div>
<div
class=
"d-flex views"
>
<div
class=
"d-flex views"
>
<svg
class=
"me-2"
width=
"24"
height=
"24"
viewBox=
"0 0 24 24"
fill=
"none"
xmlns=
"http://www.w3.org/2000/svg"
>
<svg
class=
"me-2"
width=
"24"
height=
"24"
viewBox=
"0 0 24 24"
fill=
"none"
xmlns=
"http://www.w3.org/2000/svg"
>
...
@@ -94,31 +94,38 @@ get_header();
...
@@ -94,31 +94,38 @@ get_header();
Back to Blog
Back to Blog
</a>
</a>
</div>
</div>
<?php
$content
=
apply_filters
(
'the_content'
,
get_the_content
());
if
(
!
empty
(
$content
))
{
libxml_use_internal_errors
(
true
);
$dom
=
new
DOMDocument
();
$dom
->
loadHTML
(
mb_convert_encoding
(
$content
,
'HTML-ENTITIES'
,
'UTF-8'
));
<div
class=
"blog-category toc"
>
$table_of_contents
=
'
<div class="blog-category toc">
<div class="toc-title">
<div class="toc-title">
<h6>Table of Content</h6>
<h6>Table of Content</h6>
</div>
</div>
<div class="category-list">
<div class="category-list">
<ul
class=
"wp-block-categories-list wp-block-categories"
>
<ul class="wp-block-categories-list wp-block-categories">'
;
<li
class=
"cat-item cat-item-44"
><a
href=
"http://192.168.1.89/makura-theme/category/company/"
>
Company
</a>
$xpath
=
new
DOMXPath
(
$dom
);
</li>
$headings
=
$xpath
->
query
(
'//h2 | //h3'
);
<li
class=
"cat-item cat-item-30"
><a
href=
"http://192.168.1.89/makura-theme/category/digital-marketing/"
>
Digital Marketing
</a>
foreach
(
$headings
as
$heading
)
{
</li>
$id
=
sanitize_title
(
$heading
->
nodeValue
);
<li
class=
"cat-item cat-item-33"
><a
href=
"http://192.168.1.89/makura-theme/category/updates/"
>
News
&
$heading
->
setAttribute
(
'id'
,
$id
);
Updates
</a>
$table_of_contents
.=
'<li><a class="cat-item" href="#'
.
$id
.
'">'
.
$heading
->
nodeValue
.
'</a></li>'
;
</li>
}
<li
class=
"cat-item cat-item-1"
><a
href=
"http://192.168.1.89/makura-theme/category/uncategorized/"
>
Uncategorized
</a>
$table_of_contents
.=
'</ul>
</li>
<li
class=
"cat-item cat-item-31"
><a
href=
"http://192.168.1.89/makura-theme/category/web-development/"
>
Web Development
</a>
</li>
</ul>
</div>
</div>
</div>
</div>'
;
echo
$table_of_contents
;
}
else
{
echo
'<div class="table-of-content"><h4>No Content Available</h4></div>'
;
}
?>
<p>
<?php
echo
the_field
(
'read_time'
);
?>
</p>
<p>
<?php
echo
the_field
(
'read_time'
);
?>
</p>
<div
class=
"share-article2"
>
<div
class=
"share-article2"
>
<h5>
Share this article
</h5>
<h5>
Share this article
</h5>
...
@@ -154,15 +161,15 @@ get_header();
...
@@ -154,15 +161,15 @@ get_header();
<div
class=
"tags-wrapper"
>
<div
class=
"tags-wrapper"
>
<h5>
Tags
</h5>
<h5>
Tags
</h5>
<?php
<?php
$tags
=
get_tags
();
$tags
=
get_tags
();
if
(
$tags
)
:
?>
if
(
$tags
)
:
?>
<ul>
<ul>
<?php
foreach
(
$tags
as
$tag
)
:
?>
<?php
foreach
(
$tags
as
$tag
)
:
?>
<li><a
href=
"
<?php
echo
esc_url
(
get_tag_link
(
$tag
->
term_id
));
?>
"
<li><a
href=
"
<?php
echo
esc_url
(
get_tag_link
(
$tag
->
term_id
));
?>
"
title=
"
<?php
echo
esc_attr
(
$tag
->
name
);
?>
"
>
<?php
echo
esc_html
(
$tag
->
name
);
?>
</a>
title=
"
<?php
echo
esc_attr
(
$tag
->
name
);
?>
"
>
<?php
echo
esc_html
(
$tag
->
name
);
?>
</a>
</li>
</li>
<?php
endforeach
;
?>
<?php
endforeach
;
?>
</ul>
</ul>
<?php
endif
;
?>
<?php
endif
;
?>
</div>
</div>
</div>
</div>
...
@@ -182,65 +189,65 @@ get_header();
...
@@ -182,65 +189,65 @@ get_header();
<div
class=
"container"
>
<div
class=
"container"
>
<div
class=
"row"
>
<div
class=
"row"
>
<?php
$related_posts_section
=
get_field
(
'related_post_section'
,
'option'
);
<?php
$related_posts_section
=
get_field
(
'related_post_section'
,
'option'
);
if
(
!
empty
(
$related_posts_section
))
:
if
(
!
empty
(
$related_posts_section
))
:
?>
?>
<h2>
<?php
echo
$related_posts_section
[
'title'
];
?>
</h2>
<h2>
<?php
echo
$related_posts_section
[
'title'
];
?>
</h2>
<div
class=
"d-flex align-items after-title pb-60 justify-content-between"
>
<div
class=
"d-flex align-items after-title pb-60 justify-content-between"
>
<div
class=
"col-lg-8 col-md-8 col-sm-8 paragraph"
>
<div
class=
"col-lg-8 col-md-8 col-sm-8 paragraph"
>
<?php
echo
$related_posts_section
[
'description'
];
?>
<?php
echo
$related_posts_section
[
'description'
];
?>
</div>
</div>
<?php
if
(
$link
=
$related_posts_section
[
'link'
])
:
<?php
if
(
$link
=
$related_posts_section
[
'link'
])
:
$link_target
=
$link
[
'target'
]
?
$link
[
'target'
]
:
'_self'
;
?>
$link_target
=
$link
[
'target'
]
?
$link
[
'target'
]
:
'_self'
;
?>
<div
class=
"col-lg-3 col-md-3 col-sm-3 right-button d-flex align-items-center justify-content-end"
>
<div
class=
"col-lg-3 col-md-3 col-sm-3 right-button d-flex align-items-center justify-content-end"
>
<a
href=
"
<?php
echo
$link
[
'url'
];
?>
"
target=
"
<?php
echo
esc_attr
(
$link_target
);
?>
"
<a
href=
"
<?php
echo
$link
[
'url'
];
?>
"
target=
"
<?php
echo
esc_attr
(
$link_target
);
?>
"
class=
"btn btn-primary btn-start-project"
>
<?php
echo
$link
[
'title'
];
?>
</a>
class=
"btn btn-primary btn-start-project"
>
<?php
echo
$link
[
'title'
];
?>
</a>
</div>
<?php
endif
;
?>
</div>
</div>
<?php
endif
;
?>
</div>
<?php
endif
;
?>
<?php
endif
;
?>
</div>
</div>
<?php
<?php
$related
=
get_posts
(
array
(
'category__in'
=>
wp_get_post_categories
(
get_the_ID
()),
'numberposts'
=>
5
,
'post__not_in'
=>
array
(
get_the_ID
())));
$related
=
get_posts
(
array
(
'category__in'
=>
wp_get_post_categories
(
get_the_ID
()),
'numberposts'
=>
5
,
'post__not_in'
=>
array
(
get_the_ID
())));
if
(
$related
)
:
if
(
$related
)
:
?>
?>
<div
class=
"row"
>
<div
class=
"row"
>
<div
class=
"blog-carousel owl-carousel owl-theme owl-loaded owl-drag"
>
<div
class=
"blog-carousel owl-carousel owl-theme owl-loaded owl-drag"
>
<?php
foreach
(
$related
as
$post
)
:
<?php
foreach
(
$related
as
$post
)
:
setup_postdata
(
$post
);
?>
setup_postdata
(
$post
);
?>
<div
class=
"item blog-card"
>
<div
class=
"item blog-card"
>
<a
href=
"
<?php
the_permalink
();
?>
"
>
<a
href=
"
<?php
the_permalink
();
?>
"
>
<div
class=
"blog-image-wrapper"
>
<div
class=
"blog-image-wrapper"
>
<?php
the_post_thumbnail
();
?>
<?php
the_post_thumbnail
();
?>
</div>
</div>
<div
class=
"text-wrapper"
>
<div
class=
"text-wrapper"
>
<!--<p>
<?php
echo
get_simple_tag_list
(
get_the_ID
());
?>
</p>-->
<!--<p>
<?php
echo
get_simple_tag_list
(
get_the_ID
());
?>
</p>-->
<h6>
<?php
the_title
();
?>
</h6>
<h6>
<?php
the_title
();
?>
</h6>
<?php
the_excerpt
();
?>
<?php
the_excerpt
();
?>
<span><svg
width=
"20"
height=
"21"
viewBox=
"0 0 20 21"
fill=
"none"
xmlns=
"http://www.w3.org/2000/svg"
>
<span><svg
width=
"20"
height=
"21"
viewBox=
"0 0 20 21"
fill=
"none"
xmlns=
"http://www.w3.org/2000/svg"
>
<path
<path
d=
"M16.25 3.625H3.75C3.40482 3.625 3.125 3.90482 3.125 4.25V16.75C3.125 17.0952 3.40482 17.375 3.75 17.375H16.25C16.5952 17.375 16.875 17.0952 16.875 16.75V4.25C16.875 3.90482 16.5952 3.625 16.25 3.625Z"
d=
"M16.25 3.625H3.75C3.40482 3.625 3.125 3.90482 3.125 4.25V16.75C3.125 17.0952 3.40482 17.375 3.75 17.375H16.25C16.5952 17.375 16.875 17.0952 16.875 16.75V4.25C16.875 3.90482 16.5952 3.625 16.25 3.625Z"
stroke=
"#005AFF"
stroke-width=
"1.5"
stroke-linecap=
"round"
stroke-linejoin=
"round"
></path>
stroke=
"#005AFF"
stroke-width=
"1.5"
stroke-linecap=
"round"
stroke-linejoin=
"round"
></path>
<path
d=
"M13.75 2.375V4.875"
stroke=
"#005AFF"
stroke-width=
"1.5"
stroke-linecap=
"round"
<path
d=
"M13.75 2.375V4.875"
stroke=
"#005AFF"
stroke-width=
"1.5"
stroke-linecap=
"round"
stroke-linejoin=
"round"
></path>
stroke-linejoin=
"round"
></path>
<path
d=
"M6.25 2.375V4.875"
stroke=
"#005AFF"
stroke-width=
"1.5"
stroke-linecap=
"round"
<path
d=
"M6.25 2.375V4.875"
stroke=
"#005AFF"
stroke-width=
"1.5"
stroke-linecap=
"round"
stroke-linejoin=
"round"
></path>
stroke-linejoin=
"round"
></path>
<path
d=
"M3.125 7.375H16.875"
stroke=
"#005AFF"
stroke-width=
"1.5"
stroke-linecap=
"round"
<path
d=
"M3.125 7.375H16.875"
stroke=
"#005AFF"
stroke-width=
"1.5"
stroke-linecap=
"round"
stroke-linejoin=
"round"
></path>
stroke-linejoin=
"round"
></path>
</svg>
<?php
echo
get_the_date
(
'd, M Y'
,
get_the_ID
());
?>
</span>
</svg>
<?php
echo
get_the_date
(
'd, M Y'
,
get_the_ID
());
?>
</span>
</div>
</a>
</div>
</div>
</a>
<?php
endforeach
;
wp_reset_postdata
();
?>
</div>
</div>
<?php
endforeach
;
wp_reset_postdata
();
?>
</div>
</div>
</div>
<?php
endif
;
<?php
endif
;
?>
?>
</div>
</div>
</section>
</section>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment