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

Commit 79f986a

Browse files
Create dedicated file for templates rendering specific functions #49
1 parent 10a79e6 commit 79f986a

File tree

3 files changed

+93
-67
lines changed

3 files changed

+93
-67
lines changed

app/Setup/actions.php

+8-61
Original file line numberDiff line numberDiff line change
@@ -7,72 +7,19 @@
77
| Theme Actions
88
|-----------------------------------------------------------
99
|
10-
| This file purpose is to include your theme custom
11-
| actions hooks, which allows to process various
12-
| logic is specifed parts of your system.
10+
| This file purpose is to include your custom
11+
| actions hooks, which process a various
12+
| logic at specific parts of WordPress.
1313
|
1414
*/
1515

16-
use function Tonik\Theme\App\template;
17-
18-
/**
19-
* Renders post thumbnail by its formats.
20-
*
21-
* @see do_action('theme/index/post/thumbnail')
22-
* @uses resources/templates/partials/post/thumbnail-{format}.tpl.php
23-
*/
24-
function render_post_thumbnail()
25-
{
26-
template(['partials/post/thumbnail', get_post_format()]);
27-
}
28-
add_action('theme/index/post/thumbnail', 'Tonik\Theme\App\Setup\render_post_thumbnail');
29-
30-
/**
31-
* Renders post contents by its formats.
32-
*
33-
* @see do_action('theme/index/post/content')
34-
* @uses resources/templates/partials/post/content-{format}.tpl.php
35-
*/
36-
function render_post_content()
37-
{
38-
template(['partials/post/content', get_post_format()]);
39-
}
40-
add_action('theme/single/content', 'Tonik\Theme\App\Setup\render_post_content');
41-
42-
/**
43-
* Renders empty post content where there is no posts.
44-
*
45-
* @see do_action('theme/index/content/none')
46-
* @uses resources/templates/partials/index/content-none.tpl.php
47-
*/
48-
function render_empty_content()
49-
{
50-
template(['partials/index/content', 'none']);
51-
}
52-
add_action('theme/index/content/none', 'Tonik\Theme\App\Setup\render_empty_content');
53-
54-
/**
55-
* Renders sidebar content.
56-
*
57-
* @see do_action('theme/index/sidebar')
58-
* @see do_action('theme/single/sidebar')
59-
* @uses resources/templates/partials/sidebar.tpl.php
60-
*/
61-
function render_sidebar()
62-
{
63-
get_sidebar();
64-
}
65-
add_action('theme/index/sidebar', 'Tonik\Theme\App\Setup\render_sidebar');
66-
add_action('theme/single/sidebar', 'Tonik\Theme\App\Setup\render_sidebar');
67-
6816
/**
69-
* Renders [button] shortcode after homepage content.
17+
* Example action handler.
7018
*
71-
* @see do_action('theme/header/end')
72-
* @uses resources/templates/shortcodes/button.tpl.php
19+
* @return integer
7320
*/
74-
function render_documentation_button()
21+
function example_action()
7522
{
76-
echo do_shortcode("[button href='https://github.com/tonik/tonik']Checkout documentation →[/button]");
23+
//
7724
}
78-
add_action('theme/header/end', 'Tonik\Theme\App\Setup\render_documentation_button');
25+
add_filter('excerpt_length', 'Tonik\Theme\App\Setup\example_action');

app/Structure/templates.php

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?php
2+
3+
namespace Tonik\Theme\App\Structure;
4+
5+
/*
6+
|-----------------------------------------------------------
7+
| Theme Templates Actions
8+
|-----------------------------------------------------------
9+
|
10+
| This file purpose is to include your templates rendering
11+
| actions hooks, which allows you to render specific
12+
| partials at specific places of your theme.
13+
|
14+
*/
15+
16+
use function Tonik\Theme\App\template;
17+
18+
/**
19+
* Renders post thumbnail by its formats.
20+
*
21+
* @see do_action('theme/index/post/thumbnail')
22+
* @uses resources/templates/partials/post/thumbnail-{format}.tpl.php
23+
*/
24+
function render_post_thumbnail()
25+
{
26+
template(['partials/post/thumbnail', get_post_format()]);
27+
}
28+
add_action('theme/index/post/thumbnail', 'Tonik\Theme\App\Structure\render_post_thumbnail');
29+
30+
/**
31+
* Renders post contents by its formats.
32+
*
33+
* @see do_action('theme/index/post/content')
34+
* @uses resources/templates/partials/post/content-{format}.tpl.php
35+
*/
36+
function render_post_content()
37+
{
38+
template(['partials/post/content', get_post_format()]);
39+
}
40+
add_action('theme/single/content', 'Tonik\Theme\App\Structure\render_post_content');
41+
42+
/**
43+
* Renders empty post content where there is no posts.
44+
*
45+
* @see do_action('theme/index/content/none')
46+
* @uses resources/templates/partials/index/content-none.tpl.php
47+
*/
48+
function render_empty_content()
49+
{
50+
template(['partials/index/content', 'none']);
51+
}
52+
add_action('theme/index/content/none', 'Tonik\Theme\App\Structure\render_empty_content');
53+
54+
/**
55+
* Renders sidebar content.
56+
*
57+
* @see do_action('theme/index/sidebar')
58+
* @see do_action('theme/single/sidebar')
59+
* @uses resources/templates/partials/sidebar.tpl.php
60+
*/
61+
function render_sidebar()
62+
{
63+
get_sidebar();
64+
}
65+
add_action('theme/index/sidebar', 'Tonik\Theme\App\Structure\render_sidebar');
66+
add_action('theme/single/sidebar', 'Tonik\Theme\App\Structure\render_sidebar');
67+
68+
/**
69+
* Renders [button] shortcode after homepage content.
70+
*
71+
* @see do_action('theme/header/end')
72+
* @uses resources/templates/shortcodes/button.tpl.php
73+
*/
74+
function render_documentation_button()
75+
{
76+
echo do_shortcode("[button href='https://github.com/tonik/tonik']Checkout documentation →[/button]");
77+
}
78+
add_action('theme/header/end', 'Tonik\Theme\App\Structure\render_documentation_button');

config/app.php

+7-6
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,19 @@
7272
*/
7373
'autoload' => [
7474
'helpers.php',
75+
'Http/assets.php',
76+
'Http/ajaxes.php',
77+
'Setup/actions.php',
78+
'Setup/filters.php',
79+
'Setup/supports.php',
80+
'Setup/services.php',
7581
'Structure/navs.php',
7682
'Structure/widgets.php',
7783
'Structure/sidebars.php',
84+
'Structure/templates.php',
7885
'Structure/posttypes.php',
7986
'Structure/taxonomies.php',
8087
'Structure/shortcodes.php',
8188
'Structure/thumbnails.php',
82-
'Setup/actions.php',
83-
'Setup/filters.php',
84-
'Setup/supports.php',
85-
'Setup/services.php',
86-
'Http/assets.php',
87-
'Http/ajaxes.php',
8889
],
8990
];

0 commit comments

Comments
 (0)