Repository navigation
Expand file tree
/
Copy pathfunctions.php
More file actions
321 lines (265 loc) · 9.53 KB
/
Copy pathfunctions.php
File metadata and controls
321 lines (265 loc) · 9.53 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
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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
<?php
/*
_____________
/ ____ \
_____/ \ \ \
/\ \ \___\ \
/ \ \ \
/ / / _______\
/ / / \ /
/ / / \ /
\ \ \ _____ ___\ /
\ \ /\ \ / \
\ \ / \____\/ _____\
\ \/ / / / \
\ /____/ /___\
\ /
\______________________/
Notes:
----------------------------------------
still need to create a cleaner way of working with the customiser:
- https://github.com/bueltge/Documentation/blob/master/inc/theme-customize.php
- https://github.com/philipnewcomer/Customizer-Framework
- strip google fonts stuff - should be its own control away from here
- https://github.com/devinsays/customizer-library
- http://kirki.org/
add vcard spec data - http://www.whatwg.org/specs/web-apps/current-work/multipage/microdata.html#vcard
create new colour control - http://pluto.kiwi.nz/2014/07/how-to-add-a-color-control-with-alphaopacity-to-the-wordpress-theme-customizer/
*/
// set content width
if ( ! isset( $content_width ) ) $content_width = apply_filters( 'cftp_content_width', 600 );
/**
* cftp_theme_setup
*
* Setup certain aspects of the theme, add theme support for WordPress features
*
* @author Scott Evans
* @return void
*/
function cftp_theme_setup() {
// load language files
load_theme_textdomain( 'bootiful', get_template_directory() . '/assets/languages' );
// add support for custom backgrounds
// add_theme_support( 'custom-background' );
// add support for custom header http://codex.wordpress.org/Function_Reference/add_theme_support#Custom_Header
// add_theme_support( 'custom-header' );
// add feed links for comments and posts to <head>
add_theme_support( 'automatic-feed-links' );
// setup thumbnail support
add_theme_support( 'post-thumbnails' );
// custom menu support
add_theme_support( 'menus' );
// html5 features
add_theme_support( 'html5', array(
'comment-list',
'comment-form',
'search-form',
'gallery',
'captions'
) );
// add theme hook alliance support (https://github.com/zamoose/themehookalliance) - filterable by child theme
add_theme_support('tha_hooks', apply_filters('bootiful_tha_hooks', array('head', 'body', 'header','content','entry','comments','sidebar','footer')));
// register navigation menus for this theme
register_nav_menus( apply_filters( 'cftp_register_menu', array(
'navigation' => __( 'Navigation', 'bootiful' ),
'footer' => __('Footer', 'bootiful')
)
));
// image sizes
// add_image_size( 'custom-image-size', 630, 500, false );
}
add_action( 'after_setup_theme','cftp_theme_setup' );
/**
* cftp_theme_constants
*
* Setup theme related constants, added to init hook with low priority
* so easily filtered by other code (e.g customiser)
*
* @return void
*/
function cftp_theme_constants() {
// parse template info from style.css - version number
$theme_data = wp_get_theme();
define( 'CFTP_THEME_VERSION', $theme_data['Version'] );
// cache bust based on options settings and file gen time of main css - filterable for child themes to add different css filemtime
$cachefiles = intval( filemtime( get_template_directory() . '/assets/less/styles.less' ) );
$cacheoptions = md5( serialize( get_theme_mods() ) );
$cacheoptions = preg_replace( "/[^0-9]/", "", $cacheoptions );
$cacheoptions = intval( $cacheoptions );
$cachebust = apply_filters( 'cftp_cache_bust', abs( intval( $cacheoptions+$cachefiles ) ) );
define( 'CFTP_CACHE_BUST', $cachebust );
}
add_action( 'init', 'cftp_theme_constants', 100 );
/**
* sidebars
*/
load_template( get_template_directory() . '/assets/inc/sidebars.php' );
/**
* theme customiser
*/
locate_template( '/assets/inc/customiser.php', true, true );
/**
* editor
*/
if (is_admin()) { load_template( get_template_directory() . '/assets/inc/editor.php' ); }
/**
* only load front end functions for theme
*/
if (!is_admin()) { load_template( get_template_directory() . '/assets/inc/theme.php' ); }
/**
* bootstrap menu walker
*/
if (!is_admin()) { load_template( get_template_directory() . '/assets/inc/nav.php' ); }
/**
* theme hook alliance
*/
if (!is_admin()) { load_template(get_template_directory() . '/assets/inc/tha.php'); }
/**
* cftp_admin_css_setup
*
* Register and enqueue all css/less files backend (and login screen)
*
* @author Scott Evans
* @return void
*/
function cftp_admin_css_setup() {
wp_register_style( 'cftp-theme-admin', get_template_directory_uri() . '/assets/less/wp-admin.less', array(), filemtime(get_template_directory() . '/assets/less/wp-admin.less' ) );
wp_enqueue_style( 'cftp-theme-admin' );
}
add_action( 'admin_init', 'cftp_admin_css_setup' );
add_action( 'login_enqueue_scripts', 'cftp_admin_css_setup' );
/**
* cftp_theme_css_setup
*
* Register and enqueue all css/less files.
*
* @author Scott Evans
* @return void
*/
function cftp_theme_css_setup() {
// the rest of the styles
wp_register_style( 'cftp-theme', get_template_directory_uri() . '/assets/less/styles.less', array(), CFTP_CACHE_BUST, 'all' );
//wp_register_style('cftp-print', get_template_directory_uri() . '/assets/less/print.less' array(), CFTP_CACHE_BUST, 'print');
// register ie styles
wp_register_style( 'cftp-ie', get_template_directory_uri() . '/assets/less/styles-ie.less', array(), CFTP_CACHE_BUST, 'screen' );
// all styles for this theme
wp_enqueue_style( 'cftp-theme' );
// remove admin bar css for print media - added already
//remove_action( 'wp_head', 'wp_admin_bar_header' );
// print style sheet (including admin bar hide removed above)
// wp_enqueue_style('cftp-print');
// ie styles
wp_enqueue_style( 'cftp-ie' );
}
add_action( 'wp_enqueue_scripts', 'cftp_theme_css_setup' );
/**
* cftp_admin_js_setup
*
* Register and enqueue all admin javascript files.
*
* @author Scott Evans
* @return void
*/
function cftp_admin_js_setup() {
}
add_action( 'admin_enqueue_scripts', 'cftp_admin_js_setup' );
/**
* cftp_theme_js_setup
*
* Register and enqueue all theme javascript files.
*
* @author Scott Evans
* @return void
*/
function cftp_theme_js_setup() {
// register all scripts
wp_register_script('cftp-js', get_template_directory_uri() . '/assets/js/scripts.min.js', array('jquery'), filemtime(get_template_directory() . '/assets/js/scripts.min.js'));
// comment threading
if ( is_single() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
// standard shipped jquery
wp_enqueue_script('jquery');
// theme js file
wp_enqueue_script('cftp-js');
}
add_action( 'wp_enqueue_scripts', 'cftp_theme_js_setup' );
/**
* cftp_conditional_ie_styles
*
* Add conditional comments around IE specific stylesheets
*
* @author Scott Evans
* @param string $tag
* @param strong $handle
* @return string
*/
function cftp_conditional_ie_styles( $tag, $handle ) {
if ('cftp-ie' == $handle || 'screen-ie' == $handle)
$tag = '<!-- IE css -->' . "\n" .'<!--[if lt IE 9]>' . "\n" . $tag . '<![endif]-->' . "\n";
return $tag;
}
add_filter( 'style_loader_tag', 'cftp_conditional_ie_styles', 10, 2 );
/**
* current_url
*
* Determine the current url.
*
* @author Scott Evans
* @param boolean $parse
* @return string or array
*/
if (!function_exists('current_url')) {
function current_url($parse = false) {
$s = empty($_SERVER['HTTPS']) ? '' : ($_SERVER['HTTPS'] == 'on') ? 's' : '';
$protocol = substr(strtolower($_SERVER['SERVER_PROTOCOL']), 0, strpos(strtolower($_SERVER['SERVER_PROTOCOL']), '/')) . $s;
$port = ($_SERVER['SERVER_PORT'] == '80') ? '' : (":".$_SERVER['SERVER_PORT']);
if ($parse) {
return parse_url($protocol . "://" . $_SERVER['HTTP_HOST'] . $port . $_SERVER['REQUEST_URI']);
} else {
return $protocol . "://" . $_SERVER['HTTP_HOST'] . $port . $_SERVER['REQUEST_URI'];
}
}
}
/**
* cftp_string_search
*
* Search a $string for $needle.
*
* @author Scott Evans
* @param string $needle
* @param string $string
* @return bool
*/
if ( !function_exists( 'cftp_string_search' ) ) {
function cftp_string_search($needle,$string) {
return (strpos($string, $needle) !== false);
}
}
/**
* cftp_wp_head
*
* Custom header meta for theme - move to exposure?
*
* @author Scott Evans
* @return void
*/
function cftp_wp_head() {
?>
<!-- icons -->
<link rel="shortcut icon" type="image/x-icon" href="<?php if ($favicon = get_theme_mod('favicon')) { echo $favicon; } else { echo get_template_directory_uri() . '/assets/images/favicon.ico'; } ?>" />
<link rel="apple-touch-icon-precomposed" href="<?php if ($touchicon = get_theme_mod('touchicon')) { echo $touchicon; } else { echo get_template_directory_uri() . '/assets/images/apple-touch-icon-precomposed.png'; } ?>" />
<?php
// ie9+ pinned app
?>
<!-- allow pinned app in ie9+ / windows 8 -->
<meta name="application-name" content="<?php bloginfo('name'); ?>" />
<meta name="msapplication-tooltip" content="<?php bloginfo('description'); ?>"/>
<meta name="msapplication-starturl" content="<?php echo home_url(); ?>"/>
<?php if ($touchicon = get_theme_mod('touchicon')) { ?><meta name="msapplication-TileImage" content="<?php echo $touchicon; ?>"><?php echo "\n"; } ?>
<?php if ($ie9colour = get_theme_mod('primarycol')) { ?><meta name="msapplication-TileColor" content="<?php echo $ie9colour; ?>"><?php echo "\n"; } ?>
<?php if ($ie9colour = get_theme_mod('ie9_colour')) { ?><meta name="msapplication-navbutton-color" content="<?php echo $ie9colour; ?>"><?php echo "\n"; } ?>
<?php
}
add_action('wp_head', 'cftp_wp_head');
add_action('admin_head', 'cftp_wp_head');