-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
207 lines (154 loc) · 6 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
<?php
// Register Custom Navigation Walker
require_once('wp_bootstrap_navwalker.php');
/*function wpt_register_js() {
wp_register_script('jquery.bootstrap.min', get_template_directory_uri() . '/bootstrap/js/bootstrap.min.js', 'jquery');
}
add_action( 'wp_enqueue_scripts', 'wpt_register_js' );
*/
function wpt_register_css() {
wp_enqueue_style( 'bootstrap-min', get_template_directory_uri() . '/bootstrap/css/bootstrap.min.css' );
wp_enqueue_style( 'main-styles', get_template_directory_uri() . '/style.css' );
}
add_action( 'wp_enqueue_scripts', 'wpt_register_css' );
/* Bootstrap*/
function wpbootstrap_scripts_with_jquery()
{
// Register the script like this for a theme:
wp_register_script( 'custom-script', get_template_directory_uri() . '/bootstrap/js/bootstrap.min.js', array( 'jquery' ) );
// For either a plugin or a theme, you can then enqueue the script:
wp_enqueue_script( 'custom-script' );
}
add_action( 'wp_enqueue_scripts', 'wpbootstrap_scripts_with_jquery' );
add_action('after_setup_theme', 'my_theme_setup');
function my_theme_setup(){
load_theme_textdomain( 'simple-china', get_template_directory() . '/languages' );
}
add_theme_support( 'title-tag' );
$args = array(
'flex-width' => true,
'width' => 980,
'flex-height' => true,
'height' => 200,
'default-image' => get_template_directory_uri() . '/images/headbd.png',
);
global $wp_version;
if ( version_compare( $wp_version, '3.4', '>=' ) ) :
add_theme_support( 'custom-header', $args );
endif;
/**
* Set up the content width value based on the theme's design.
*
* @see
*
* @since v 2.3
*/
if ( ! isset( $content_width ) ) {
$content_width = 900;
}
/*
* Make available for translation.
*
* Translations can be added to the /languages/ directory.
* If you're building a theme based on Twenty Fourteen, use a find and
* replace to change 'simple-china' to the name of your theme in all
* template files.
*/
// This theme styles the visual editor to resemble the theme style.
add_editor_style( array( 'css/editor-style.css', chinatheme_font_url() ) );
// Add RSS feed links to <head> for posts and comments.
add_theme_support( 'automatic-feed-links' );
// Enable support for Post Thumbnails, and declare two sizes.
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 672, 372, true );
add_image_size( 'chinatheme-full-width', 1038, 576, true );
// This theme uses wp_nav_menu() in two locations.
register_nav_menus( array(
'primary' => __( 'Top primary menu', 'simple-china' )
) );
/*
* Switch default core markup for search form, comment form, and comments
* to output valid HTML5.
*/
add_theme_support( 'html5', array(
'search-form', 'comment-form', 'comment-list', 'gallery', 'caption'
) );
// This theme allows users to set a custom background.
add_theme_support( 'custom-background', apply_filters( 'simple-china_custom_background_args', array(
'default-color' => 'f5f5f5',
) ) );
// Add support for featured content.
add_theme_support( 'featured-content', array(
'featured_content_filter' => 'simple-china_get_featured_posts',
'max_posts' => 6,
) );
// This theme uses its own gallery styles.
add_filter( 'use_default_gallery_style', '__return_false' );
// end_setup
/**
* Register Lato Google font for chinatheme.
*
* @since Twenty Fourteen 1.0
*
* @return string
*/
function chinatheme_font_url() {
$font_url = '';
/*
* Translators: If there are characters in your language that are not supported
* by Lato, translate this to 'off'. Do not translate into your own language.
*/
if ( 'off' !== _x( 'on', 'Lato font: on or off', 'simple-china' ) ) {
$font_url = add_query_arg( 'family', urlencode( 'Lato:300,400,700,900,300italic,400italic,700italic' ), "//fonts.googleapis.com/css" );
}
return $font_url;
}
add_action( 'widgets_init', 'china_theme_widgets_init' );
function china_theme_widgets_init() {
register_sidebar( array(
'name' => __( 'Main Sidebar', 'simple-china' ),
'id' => 'sidebar-1',
'description' => __( 'Widgets in this area will be shown on all posts and pages.', 'simple-china' ),
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '<h2 class="bgpng sbtitle widgettitle">',
'after_title' => '</h2>',
) );
register_sidebar( array(
'name' => __( 'Front left', 'simple-china' ),
'id' => 'sidebar-f1',
'description' => __( 'Widgets in this area on fron page on the left.', 'simple-china' ),
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '<h2 class="bgpng sbtitle widgettitle">',
'after_title' => '</h2>',
) );
register_sidebar( array(
'name' => __( 'Front center', 'simple-china' ),
'id' => 'sidebar-f2',
'description' => __( 'Widgets in this area on fron page on the center.', 'simple-china' ),
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '<h2 class="bgpng sbtitle widgettitle">',
'after_title' => '</h2>',
) );
register_sidebar( array(
'name' => __( 'Front right', 'simple-china' ),
'id' => 'sidebar-f3',
'description' => __( 'Widgets in this area on fron page on the right.', 'simple-china' ),
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '<h2 class="bgpng sbtitle widgettitle">',
'after_title' => '</h2>',
) );
register_sidebar( array(
'name' => __( 'Front content', 'simple-china' ),
'id' => 'sidebar-fright',
'description' => __( 'Widgets in this area on fron page inside content on right .', 'simple-china' ),
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '<h2 class="bgpng sbtitle widgettitle">',
'after_title' => '</h2>',
) );
}
?>