Skip to content
This repository was archived by the owner on Nov 14, 2024. It is now read-only.

Commit bff0284

Browse files
Refactor docblocks of templates actions and filters #48
1 parent 79f986a commit bff0284

19 files changed

+114
-71
lines changed

404.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
/**
1818
* Renders 404 page header.
1919
*
20-
* @see do_action('theme/index/header')
21-
* @uses resources/templates/partials/header.tpl.php
20+
* @see resources/templates/index.tpl.php
2221
*/
2322
function render_header()
2423
{
@@ -32,6 +31,6 @@ function render_header()
3231
/**
3332
* Renders 404 page.
3433
*
35-
* @uses resources/templates/index.tpl.php
34+
* @see resources/templates/index.tpl.php
3635
*/
3736
template('index');

app/Structure/templates.php

+14-17
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
/**
1919
* Renders post thumbnail by its formats.
2020
*
21-
* @see do_action('theme/index/post/thumbnail')
22-
* @uses resources/templates/partials/post/thumbnail-{format}.tpl.php
21+
* @see resources/templates/index.tpl.php
2322
*/
2423
function render_post_thumbnail()
2524
{
@@ -28,35 +27,33 @@ function render_post_thumbnail()
2827
add_action('theme/index/post/thumbnail', 'Tonik\Theme\App\Structure\render_post_thumbnail');
2928

3029
/**
31-
* Renders post contents by its formats.
30+
* Renders empty post content where there is no posts.
3231
*
33-
* @see do_action('theme/index/post/content')
34-
* @uses resources/templates/partials/post/content-{format}.tpl.php
32+
* @see resources/templates/index.tpl.php
3533
*/
36-
function render_post_content()
34+
function render_empty_content()
3735
{
38-
template(['partials/post/content', get_post_format()]);
36+
template(['partials/index/content', 'none']);
3937
}
40-
add_action('theme/single/content', 'Tonik\Theme\App\Structure\render_post_content');
38+
add_action('theme/index/content/none', 'Tonik\Theme\App\Structure\render_empty_content');
4139

4240
/**
43-
* Renders empty post content where there is no posts.
41+
* Renders post contents by its formats.
4442
*
45-
* @see do_action('theme/index/content/none')
46-
* @uses resources/templates/partials/index/content-none.tpl.php
43+
* @see resources/templates/single.tpl.php
4744
*/
48-
function render_empty_content()
45+
function render_post_content()
4946
{
50-
template(['partials/index/content', 'none']);
47+
template(['partials/post/content', get_post_format()]);
5148
}
52-
add_action('theme/index/content/none', 'Tonik\Theme\App\Structure\render_empty_content');
49+
add_action('theme/single/content', 'Tonik\Theme\App\Structure\render_post_content');
5350

5451
/**
5552
* Renders sidebar content.
5653
*
57-
* @see do_action('theme/index/sidebar')
58-
* @see do_action('theme/single/sidebar')
5954
* @uses resources/templates/partials/sidebar.tpl.php
55+
* @see resources/templates/index.tpl.php
56+
* @see resources/templates/single.tpl.php
6057
*/
6158
function render_sidebar()
6259
{
@@ -68,8 +65,8 @@ function render_sidebar()
6865
/**
6966
* Renders [button] shortcode after homepage content.
7067
*
71-
* @see do_action('theme/header/end')
7268
* @uses resources/templates/shortcodes/button.tpl.php
69+
* @see resources/templates/partials/header.tpl.php
7370
*/
7471
function render_documentation_button()
7572
{

footer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@
1717
/**
1818
* Renders layout's footer.
1919
*
20-
* @uses resources/templates/layout/footer.tpl.php
20+
* @see resources/templates/layout/footer.tpl.php
2121
*/
2222
template('layout/footer');

header.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@
1717
/**
1818
* Renders layout's head.
1919
*
20-
* @uses resources/templates/layout/head.tpl.php
20+
* @see resources/templates/layout/head.tpl.php
2121
*/
2222
template('layout/head');

index.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
/**
1919
* Renders index page header.
2020
*
21-
* @see do_action('theme/index/header')
22-
* @uses resources/templates/partials/header.tpl.php
21+
* @see resources/templates/index.tpl.php
2322
*/
2423
function render_header()
2524
{
@@ -33,6 +32,6 @@ function render_header()
3332
/**
3433
* Renders index page.
3534
*
36-
* @uses resources/templates/index.tpl.php
35+
* @see resources/templates/index.tpl.php
3736
*/
3837
template('index');

page.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@
1818
/**
1919
* Renders single page.
2020
*
21-
* @uses resources/templates/single.tpl.php
21+
* @see resources/templates/single.tpl.php
2222
*/
2323
template('single');

resources/templates/index.tpl.php

+38-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1-
<?php get_header() ?>
1+
<?php get_header(); ?>
22

3-
<?php do_action('theme/index/header') ?>
3+
<?php
4+
/**
5+
* Functions hooked into `theme/index/header` action.
6+
*
7+
* @hooked Tonik\Theme\Index\render_header - 10
8+
*/
9+
do_action('theme/index/header');
10+
?>
411

512
<section class="section">
613
<div class="wrapper">
@@ -10,18 +17,39 @@
1017

1118
<div class="posts">
1219
<?php while (have_posts()) : the_post() ?>
13-
<?php do_action('theme/index/post/thumbnail') ?>
14-
<?php endwhile ?>
20+
<?php
21+
/**
22+
* Functions hooked into `theme/index/post/thumbnail` action.
23+
*
24+
* @hooked Tonik\Theme\App\Structure\render_post_thumbnail - 10
25+
*/
26+
do_action('theme/index/post/thumbnail');
27+
?>
28+
<?php endwhile; ?>
1529
</div>
1630
<?php else : ?>
17-
<?php do_action('theme/index/content/none') ?>
18-
<?php endif ?>
31+
<?php
32+
/**
33+
* Functions hooked into `theme/index/content/none` action.
34+
*
35+
* @hooked Tonik\Theme\App\Structure\render_empty_content - 10
36+
*/
37+
do_action('theme/index/content/none');
38+
?>
39+
<?php endif; ?>
1940
</div>
2041

21-
<?php if (apply_filters('theme/index/sidebar/visibility', true)): ?>
22-
<?php do_action('theme/index/sidebar') ?>
23-
<?php endif ?>
42+
<?php if (apply_filters('theme/index/sidebar/visibility', true)) : ?>
43+
<?php
44+
/**
45+
* Functions hooked into `theme/index/sidebar` action.
46+
*
47+
* @hooked Tonik\Theme\App\Structure\render_sidebar - 10
48+
*/
49+
do_action('theme/index/sidebar');
50+
?>
51+
<?php endif; ?>
2452
</div>
2553
</section>
2654

27-
<?php get_footer() ?>
55+
<?php get_footer(); ?>

resources/templates/layout/footer.tpl.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<footer class="footer">
22
<ul>
3-
<li><a href="<?= get_home_url() ?>">Index</a></li>
3+
<li><a href="<?= get_home_url(); ?>">Index</a></li>
44
<li><a href="https://github.com/tonik/tonik/wiki">Documentation</a></li>
55
<li><a href="https://github.com/tonik/tonik">Github</a></li>
66
</ul>

resources/templates/layout/head.tpl.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
<body <?php body_class(); ?>>
1010
<main class="main">
1111
<nav>
12-
<a href="<?= get_home_url() ?>"><h1>WordPress Starter Theme</h1></a>
12+
<a href="<?= get_home_url(); ?>"><h1>WordPress Starter Theme</h1></a>
1313
</nav>
+8-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
<header class="header">
2-
<?php do_action('theme/header/start') ?>
3-
42
<h2><?= $title ?></h2>
5-
63
<p><?= $lead ?></p>
74

8-
<?php do_action('theme/header/end') ?>
5+
<?php
6+
/**
7+
* Functions hooked into `theme/header/end` action.
8+
*
9+
* @hooked Tonik\Theme\App\Structure\render_documentation_button - 10
10+
*/
11+
do_action('theme/header/end')
12+
?>
913
</header>
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
<?php
2-
use function App\Theme\config;
3-
?>
4-
51
<section>
6-
<div><?php get_search_form() ?></div>
2+
<div><?php get_search_form(); ?></div>
73
</section>
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
<article>
2-
<h1><?php the_title() ?></h1>
2+
<h1><?php the_title(); ?></h1>
33

4-
<time><small><?php the_date() ?></small></time>
4+
<time>
5+
<small><?php the_date(); ?></small>
6+
</time>
57

6-
<p><?php the_content() ?></p>
8+
<p><?php the_content(); ?></p>
79
</article>
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
<article class="thumbnail">
2-
<a href="<?php the_permalink() ?>">
3-
<h2><?php the_title() ?></h2>
2+
<a href="<?php the_permalink(); ?>">
3+
<h2><?php the_title(); ?></h2>
44
</a>
55

6-
<time><small><?php the_date() ?></small></time>
6+
<time>
7+
<small><?php the_date(); ?></small>
8+
</time>
79
</article>

resources/templates/partials/searchform.tpl.php

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
<?php
2-
use function App\Theme\config;
3-
?>
4-
5-
<form action="/" method="get">
1+
<form action="/" method="GET">
62
<label for="search">
7-
<input id="search" type="text" name="s" value="<?php the_search_query(); ?>" placeholder="<?= __('Searching for...', config('textdomain')) ?>">
3+
<input
4+
id="search"
5+
type="text"
6+
name="s"
7+
value="<?php the_search_query(); ?>"
8+
placeholder="<?= __('Searching for...', Tonik\Theme\App\config('textdomain')) ?>"
9+
>
810
</label>
911

1012
<input type="submit" value="Search">

resources/templates/partials/sidebar.tpl.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<aside class="sidebar">
22
<?php if (is_active_sidebar('sidebar')) : ?>
33
<ul>
4-
<?php dynamic_sidebar('sidebar') ?>
4+
<?php dynamic_sidebar('sidebar'); ?>
55
</ul>
66
<?php else: ?>
77
<h5>Sidebar</h5>

resources/templates/single.tpl.php

+22-8
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,33 @@
1-
<?php get_header() ?>
1+
<?php get_header(); ?>
22

33
<section class="section">
44
<div class="wrapper">
55
<div class="content">
66
<?php if (have_posts()) : ?>
77
<?php while (have_posts()) : the_post() ?>
8-
<?php do_action('theme/single/content') ?>
9-
<?php endwhile ?>
10-
<?php endif ?>
8+
<?php
9+
/**
10+
* Functions hooked into `theme/single/content` action.
11+
*
12+
* @hooked Tonik\Theme\App\Structure\render_post_content - 10
13+
*/
14+
do_action('theme/single/content');
15+
?>
16+
<?php endwhile; ?>
17+
<?php endif; ?>
1118
</div>
1219

13-
<?php if (apply_filters('theme/single/sidebar/visibility', true)): ?>
14-
<?php do_action('theme/single/sidebar') ?>
15-
<?php endif ?>
20+
<?php if (apply_filters('theme/single/sidebar/visibility', true)) : ?>
21+
<?php
22+
/**
23+
* Functions hooked into `theme/single/sidebar` action.
24+
*
25+
* @hooked Tonik\Theme\App\Structure\render_sidebar - 10
26+
*/
27+
do_action('theme/single/sidebar');
28+
?>
29+
<?php endif; ?>
1630
</div>
1731
</section>
1832

19-
<?php get_footer() ?>
33+
<?php get_footer(); ?>

searchform.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@
1717
/**
1818
* Renders search form.
1919
*
20-
* @uses resources/templates/partials/searchform.tpl.php
20+
* @see resources/templates/partials/searchform.tpl.php
2121
*/
2222
template('partials/searchform');

sidebar.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@
1717
/**
1818
* Renders sidebar.
1919
*
20-
* @uses resources/templates/partials/sidebar.tpl.php
20+
* @see resources/templates/partials/sidebar.tpl.php
2121
*/
2222
template('partials/sidebar');

single.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@
1818
/**
1919
* Renders single post.
2020
*
21-
* @uses resources/templates/single.tpl.php
21+
* @see resources/templates/single.tpl.php
2222
*/
2323
template('single');

0 commit comments

Comments
 (0)