-
Notifications
You must be signed in to change notification settings - Fork 2
/
functions.php
118 lines (96 loc) · 3.19 KB
/
functions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<?php
add_theme_support('title-tag');
function klise_menus()
{
register_nav_menus(
array(
'main-menu' => _('Main Menu'),
'footer-menu' => _('Footer Menu')
)
);
}
add_action('init', 'klise_menus');
function klise_check_active_menu($menu_item)
{
global $wp;
$actual_link = home_url($wp->request) . '/';
if ($actual_link == $menu_item->url) {
return 'active';
}
return '';
}
function klise_customizer($wp_customize) {
$wp_customize->add_section( 'author_section' , array(
'title' => __( 'Author Section', 'klise' ),
'description' => 'Author section settings.',
));
$wp_customize->add_setting( 'author_image', array(
'default' => ''
));
$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'author_image', array(
'label' => __( 'Author image', 'urlista_theme' ),
'section' => 'author_section',
'settings' => 'author_image',
)));
$wp_customize->add_setting( 'author_name', array(
'capability' => 'edit_theme_options',
'default' => 'Wordpress Klisé',
'sanitize_callback' => 'sanitize_text_field',
));
$wp_customize->add_control( 'author_name', array(
'type' => 'text',
'section' => 'author_section',
'label' => __( 'Author Name' ),
));
$wp_customize->add_setting( 'author_bio', array(
'capability' => 'edit_theme_options',
'default' => 'The minimalist Wordpress theme, light and dark mode support, for running a personal site and blog, meet Klisé theme at <a href="https://github.com/enderkus/klise">@github</a>.',
));
$wp_customize->add_control( 'author_bio', array(
'type' => 'textarea',
'section' => 'author_section',
'label' => __( 'Author Bio' ),
));
$wp_customize->add_section( 'klise_theme_settings' , array(
'title' => __( 'Klisé Settings', 'klise' ),
'description' => 'Theme settings.',
));
$wp_customize->add_setting( 'copyright_text', array(
'capability' => 'edit_theme_options',
'default' => '© 2023 Klisé',
'sanitize_callback' => 'sanitize_text_field',
));
$wp_customize->add_control( 'copyright_text', array(
'type' => 'text',
'section' => 'klise_theme_settings',
'label' => __( 'Copyright Text' ),
));
}
add_action('customize_register', 'klise_customizer');
function klise_end_point_register()
{
register_rest_route('klise/v1', 'postlist', [
'methods' => WP_REST_SERVER::READABLE,
'callback' => 'klise_end_point_results'
]);
}
function klise_end_point_results($data)
{
$search_query = new WP_Query([
'post_type' => ['post'],
'posts_per_page' => -1,
]);
$results = [];
// proceed to database query
while ($search_query->have_posts()) {
$search_query->the_post();
array_push($results, [
'title' => get_the_title(),
'url' => get_the_permalink(),
'description' => get_the_excerpt()
]);
}
wp_reset_postdata();
return $results;
}
add_action('rest_api_init', 'klise_end_point_register');