-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.php
More file actions
125 lines (111 loc) · 3.75 KB
/
functions.php
File metadata and controls
125 lines (111 loc) · 3.75 KB
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
119
120
121
122
123
124
125
<?php
add_action( 'after_setup_theme', 'starbasego_setup' );
function starbasego_setup()
{
load_theme_textdomain( 'starbasego', get_template_directory() . '/languages' );
add_theme_support( 'automatic-feed-links' );
add_theme_support( 'post-thumbnails' );
global $content_width;
if ( ! isset( $content_width ) ) $content_width = 640;
register_nav_menus(
array( 'main-menu' => __( 'Main Menu', 'starbasego' ) )
);
}
function cc_mime_types( $mimes ){
$mimes['svg'] = 'image/svg+xml';
return $mimes;
}
add_filter( 'upload_mimes', 'cc_mime_types' );
add_action( 'wp_enqueue_scripts', 'starbasego_load_scripts' );
function starbasego_load_scripts()
{
wp_enqueue_script(
'script',
get_stylesheet_directory_uri() . '/assets/script/script.js',
array( 'jquery' )
);
}
add_action( 'comment_form_before', 'starbasego_enqueue_comment_reply_script' );
function starbasego_enqueue_comment_reply_script()
{
if ( get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); }
}
add_filter( 'the_title', 'starbasego_title' );
function starbasego_title( $title ) {
return $title != '' ? $title : ' ';
}
add_filter( 'wp_title', 'starbasego_filter_wp_title' );
function starbasego_filter_wp_title( $title )
{
return $title . esc_attr( get_bloginfo( 'name' ) );
}
add_action( 'widgets_init', 'starbasego_widgets_init' );
function starbasego_widgets_init()
{
register_sidebar( array (
'name' => __( 'Sidebar Widget Area', 'starbasego' ),
'id' => 'sidebar-widget-area',
'before_widget' => '<div id="widget-%1$s" class="widget-container">',
'after_widget' => "</div>",
'before_title' => '<h4 class="widget-title">',
'after_title' => '</h4>',
) );
}
add_filter( 'get_comments_number', 'starbasego_comments_number' );
function starbasego_comments_number( $count )
{
if ( !is_admin() ) {
global $id;
$comments_by_type = &separate_comments( get_comments( 'status=approve&post_id=' . $id ) );
return count( $comments_by_type['comment'] );
} else {
return $count;
}
}
function starbasego_search_form( $form ) {
$form = '<form role="search" method="get" id="searchform" class="search-form" action="' . home_url( '/' ) . '" >
<label class="screen-reader-text" for="s">' . __( 'Search' ) . '</label>
<input type="text" value="' . get_search_query() . '" placeholder="Mies van der Rohe" name="s" id="s" />
<button type="submit" id="searchsubmit">
<i class="fa fa-search"></i>
</button>
</form>';
return $form;
}
add_filter( 'get_search_form', 'starbasego_search_form' );
function starbasego_theme_customizer( $wp_customize ) {
$wp_customize->add_section( 'starbasego_logo_section' , array(
'title' => __( 'Logo', 'starbasego' ),
'priority' => 30,
'description' => 'Upload a logo to replace the default site name and description in the header',
) );
$wp_customize->add_setting( 'starbasego_logo' );
$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'starbasego_logo', array(
'label' => __( 'Logo', 'starbasego' ),
'section' => 'starbasego_logo_section',
'settings' => 'starbasego_logo',
) ) );
}
add_action('customize_register', 'starbasego_theme_customizer');
remove_filter('get_the_excerpt', 'wp_trim_excerpt');
add_filter('get_the_excerpt', 'starbasego_new_excerpt');
function starbasego_new_excerpt($text)
{
if ($text == '')
{
$text = get_the_content('');
$text = strip_shortcodes( $text );
$text = apply_filters('the_content', $text);
$text = str_replace(']]>', ']]>', $text);
$text = strip_tags($text);
$text = nl2br($text);
$excerpt_length = apply_filters('excerpt_length', 25);
$words = explode(' ', $text, $excerpt_length + 1);
if (count($words) > $excerpt_length) {
array_pop($words);
array_push($words, '...');
$text = implode(' ', $words);
}
}
return $text;
}