This repository has been archived by the owner on Aug 6, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 93
/
functions.php
243 lines (212 loc) · 7.97 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
<?php
/**
* Casper functions and definitions
*
* @package Casper
*/
if ( ! function_exists( 'casper_setup' ) ) :
/**
* Sets up theme defaults and registers support for various WordPress features.
*
* Note that this function is hooked into the after_setup_theme hook, which
* runs before the init hook. The init hook is too late for some features, such
* as indicating support for post thumbnails.
*/
function casper_setup() {
/**
* Set the content width based on the theme's design and stylesheet.
*/
if ( ! isset( $content_width ) ) {
$content_width = 640; /* pixels */
}
/*
* Make theme available for translation.
* Translations can be filed in the /languages/ directory.
* If you're building a theme based on Casper, use a find and replace
* to change 'casper' to the name of your theme in all the template files
*/
load_theme_textdomain( 'casper', get_template_directory() . '/languages' );
// Add default posts and comments RSS feed links to head.
add_theme_support( 'automatic-feed-links' );
/*
* Enable support for Post Thumbnails on posts and pages.
*
* @link http://codex.wordpress.org/Function_Reference/add_theme_support#Post_Thumbnails
*/
add_theme_support( 'post-thumbnails' );
/*
* Let WordPress manage the document title.
* By adding theme support, we declare that this theme does not use a
* hard-coded <title> tag in the document head, and expect WordPress to
* provide it for us.
*/
add_theme_support( 'title-tag' );
// This theme uses wp_nav_menu() in one location.
register_nav_menus( array(
'primary' => __( 'Primary Menu', 'casper' ),
) );
// Enable support for Post Formats.
add_theme_support( 'post-formats', array( 'aside', 'image', 'video', 'quote', 'link' ) );
// Setup the WordPress core custom background feature.
add_theme_support( 'custom-background', apply_filters( 'casper_custom_background_args', array(
'default-color' => 'ffffff',
'default-image' => '',
) ) );
// Enable support for HTML5 markup.
add_theme_support( 'html5', array(
'comment-list',
'search-form',
'comment-form',
'gallery',
) );
function new_excerpt_more( $more ) {
if ( false != get_theme_mod( 'casper_read_more_link')) {
return ' <a class="read-more" href="'. get_permalink( get_the_ID() ) . '">' . get_theme_mod( 'casper_read_more_link') . '</a>';
} else {
return ' <a class="read-more" href="'. get_permalink( get_the_ID() ) . '">' . __( '… <span class="meta-nav">→</span>', 'casper' ) . '</a>';
}
}
add_filter( 'excerpt_more', 'new_excerpt_more' );
// Enable automatic theme updates
add_filter( 'auto_update_theme', '__return_true' );
}
endif; // casper_setup
add_action( 'after_setup_theme', 'casper_setup' );
if ( ! function_exists( 'casper_widgets_init' ) ) :
/**
* Register widgetized area and update sidebar with default widgets.
*/
function casper_widgets_init() {
register_sidebar( array(
'name' => __( 'Footer Bar', 'casper' ),
'id' => 'sidebar-1',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h1 class="widget-title">',
'after_title' => '</h1>',
) );
}
endif; // casper_widgets_init
add_action( 'widgets_init', 'casper_widgets_init' );
if ( ! function_exists( 'casper_scripts' ) ) :
/**
* Enqueue scripts and styles.
*/
function casper_scripts() {
wp_enqueue_style('casper-google-fonts', '//fonts.googleapis.com/css?family=Noto+Serif:400,700,400italic|Open+Sans:700,400');
wp_enqueue_style( 'casper-style', get_stylesheet_uri() );
wp_enqueue_script( 'casper-index', get_template_directory_uri() . '/js/main.js', array('jquery'), '1.0.0', true );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
endif; // casper_scripts
add_action( 'wp_enqueue_scripts', 'casper_scripts' );
/**
* Implement the Custom Header feature.
*/
require get_template_directory() . '/inc/custom-header.php';
/**
* Custom template tags for this theme.
*/
require get_template_directory() . '/inc/template-tags.php';
/**
* Custom functions that act independently of the theme templates.
*/
require get_template_directory() . '/inc/extras.php';
/**
* Customizer additions.
*/
require get_template_directory() . '/inc/customizer.php';
/**
* Load Jetpack compatibility file.
*/
require get_template_directory() . '/inc/jetpack.php';
if ( ! function_exists( 'casper_add_editor_styles' ) ) :
/**
* Custom Editor Styles
*/
function casper_add_editor_styles() {
add_editor_style( 'css/custom-editor-style.css' );
}
endif; // casper_add_editor_styles
add_action( 'after_setup_theme', 'casper_add_editor_styles' );
if ( ! function_exists( 'casper_customizer_head' ) ) :
/**
* Admin CSS
*/
function casper_admin_css(){
wp_enqueue_style ('casper_admin_style', get_template_directory_uri() . '/css/admin.css', array(), false, false);
}
add_action('admin_head', 'casper_admin_css');
/**
* Customizer hook
*/
function casper_customizer_head() {
if (get_theme_mod( 'casper_custom_meta' )!=false) { echo get_theme_mod( 'casper_custom_meta' ); } ?>
<style type="text/css">
<?php if(get_header_textcolor()){ ?>
.blog-title a, .blog-description, .social-icons a { color: #<?php header_textcolor(); ?>; }
<?php } ?>
<?php if('blank' === get_header_textcolor()) { ?>
.blog-description { display: none; }
<?php } ?>
<?php if(false != get_theme_mod( 'casper_header_textcolor' ) && false != get_theme_mod( 'casper_display_header' )){ ?>
body:not(.home) .blog-title a, body:not(.home) .blog-description, body:not(.home) .social-icons a {
color: <?php echo get_theme_mod( 'casper_header_textcolor' ); ?>;
}
<?php } ?>
<?php if(get_theme_mod('casper_header_color')){ ?>
.site-head { background-color: <?php echo get_theme_mod( 'casper_header_color' ); ?>; }
<?php } ?>
<?php if(false != get_theme_mod( 'casper_display_header' )) { ?>
body:not(.home) #masthead{ background: none; }
<?php } ?>
<?php if(false != get_theme_mod( 'casper_display_header_all' )) { ?>
body:not(.home) .site-head:after { display: none; }
body:not(.home) #masthead{ height: auto; border: none; }
body:not(.home) .blog-title, body:not(.home) .blog-description { display: none; }
body:not(.home) .inner { padding-top: 1em; }
body:not(.home) .main-navigation { position: relative; }
<?php } ?>
<?php if( get_theme_mod( 'casper_link_color' )) { ?>
section a { color: <?php echo get_theme_mod( 'casper_link_color' ); ?>; }
<?php } ?>
<?php if(get_theme_mod( 'casper_hover_color' )) { ?>
a:hover, body .blog-title a:hover, body .social-icons a:hover { color: <?php echo get_theme_mod( 'casper_hover_color' ); ?>; }
<?php } ?>
<?php if(!get_theme_mod( 'casper_display_header' )){ ?>
.main-navigation a { color: <?php echo get_theme_mod( 'casper_home_menu_color' ); ?>; }
<?php } ?>
<?php if(get_theme_mod( 'casper_menu_color' )){ ?>
.main-navigation a { color: <?php echo get_theme_mod( 'casper_menu_color' ); ?>; }
<?php } ?>
<?php if(get_theme_mod( 'casper_home_menu_color' )){ ?>
.home .main-navigation a { color: <?php echo get_theme_mod( 'casper_home_menu_color' ); ?>; }
<?php } ?>
<?php if( false != get_theme_mod( 'casper_logo_circle' ) ) { ?>
.blog-logo img {
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
border-radius: 50%;
}
<?php } ?>
<?php if( false != get_theme_mod( 'casper_logo_frame' ) ) { ?>
.blog-logo img {
border: 3px solid white;
-webkit-box-shadow: 0 1px 1px rgba(0,0,0,0.3);
-moz-box-shadow: 0 1px 1px rgba(0,0,0,0.3);
box-shadow: 0 1px 1px rgba(0,0,0,0.3);
}
<?php } ?>
<?php if( false != get_theme_mod( 'casper_hide_page_header_dot' ) ) { ?>
.site-head:after {
display: none;
}
<?php } ?>
</style>
<?php
}
endif; // casper_customizer_head
add_action( 'wp_head', 'casper_customizer_head' );
?>