-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap.php
83 lines (76 loc) · 2.63 KB
/
bootstrap.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
<?php
/**
* LaunchPad is a weird theme... I'm sorry
* This file fixes a lot of weirdness so you can simply get rolling with your child theme
*/
/**
* Ensure that parent template views load automatically
* @param string $dir views directory path
* @return string
* @since 1.0.0
* @version 1.0.0
*/
function lp_child_views_dir( $dir ) {
return str_replace( get_stylesheet_directory(), get_template_directory(), $dir );
}
add_filter( 'launchpad_views_directory', 'lp_child_views_dir', 10, 1 );
/**
* Allow templates added to resources/views to override default LP views
* @param string $template full template path
* @param string $name file name
* @param string $path path without file name
* @return string
* @since 1.1.0
* @version 1.1.0
*/
function lp_child_locate_template( $template, $name, $path ) {
$override = str_replace( get_template_directory(), get_stylesheet_directory(), $template );
if ( file_exists( $override ) ) {
return $override;
}
return $template;
}
add_filter( 'launchpad_locate_template', 'lp_child_locate_template', 10, 3 );
/**
* Automatically load parent styles as dependencies to child theme stylesheets
* @param array $styles default stylesheet dependencies
* @return array
* @since 1.0.0
* @version 1.0.0
*/
function lp_child_styles( $styles ) {
if ( ! is_admin() ) {
$styles[] = array( 'lp-parent-style', get_template_directory_uri() . '/assets/public/css/style.css', );
} else {
$styles[] = array( 'lp-parent-admin-style', get_template_directory_uri() . '/assets/admin/css/admin.css', );
}
return $styles;
}
add_filter( 'launchpad_stylesheet_dependencies', 'lp_child_styles' );
/**
* Automatically load parent styles as dependencies to child theme stylesheets
* @param array $styles default stylesheet dependencies
* @return array
* @since 1.0.0
* @version 1.0.0
*/
function lp_child_scripts( $scripts ) {
$suffix = ( defined( 'WP_DEBUG' ) && WP_DEBUG ) ? '' : '.min';
$scripts[] = array( 'launchpad', get_template_directory_uri() . '/js/wp-launchpad' . $suffix . '.js', array('jquery') );
return $scripts;
}
add_filter( 'launchpad_javascript_dependencies', 'lp_child_scripts' );
/**
* Ensure images load properly on admin settings screen
* @param array $options Layout options data
* @return array
* @since 1.0.0
* @version 1.0.0
*/
function lp_child_layout_options( $options ) {
foreach ( $options as $key => &$val ) {
$val = str_replace( get_stylesheet_directory_uri(), get_template_directory_uri(), $val );
}
return $options;
}
add_filter( 'launchpad_layout_options', 'lp_child_layout_options' );