-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
66 lines (48 loc) · 3.56 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
<?php
/*
_ _ _____ _ _ _ _ _ _
(_) | | | ____| | | (_) | | | | | | |
_ __ _ ___ ___ ___| |_ _ __ __ _ _ __| |__ ___| |__ _| | __| | | |_| |__ ___ _ __ ___ ___
| '_ \| |/ __/ _ \/ __| __| '__/ _` | '_ \___ \ / __| '_ \| | |/ _` | | __| '_ \ / _ \ '_ ` _ \ / _ \
| |_) | | (_| (_) \__ \ |_| | | (_| | |_) |__) | | (__| | | | | | (_| | | |_| | | | __/ | | | | | __/
| .__/|_|\___\___/|___/\__|_| \__,_| .__/____/ \___|_| |_|_|_|\__,_| \__|_| |_|\___|_| |_| |_|\___|
| | | |
|_| |_|
*************************************** WELCOME TO PICOSTRAP ***************************************
********************* THE BEST WAY TO EXPERIENCE SASS, BOOTSTRAP AND WORDPRESS *********************
PLEASE WATCH THE VIDEOS FOR BEST RESULTS:
https://www.youtube.com/playlist?list=PLtyHhWhkgYU8i11wu-5KJDBfA9C-D4Bfl
*/
// DE-ENQUEUE PARENT THEME BOOTSTRAP JS BUNDLE
add_action( 'wp_print_scripts', function(){
wp_dequeue_script( 'bootstrap5' );
//wp_dequeue_script( 'dark-mode-switch' ); //optionally
}, 100 );
// ENQUEUE THE BOOTSTRAP JS BUNDLE (AND EVENTUALLY MORE LIBS) FROM THE CHILD THEME DIRECTORY
add_action( 'wp_enqueue_scripts', function() {
//enqueue js in footer, defer
wp_enqueue_script( 'bootstrap5-childtheme', get_stylesheet_directory_uri() . "/js/bootstrap.bundle.min.js", array(), null, array('strategy' => 'defer', 'in_footer' => true) );
//optional: example of how to globally load js files eg lottie player
//wp_enqueue_script( 'lottie-player', 'https://unpkg.com/@lottiefiles/lottie-player@latest/dist/lottie-player.js', array(), null, array('strategy' => 'defer', 'in_footer' => true) );
}, 101);
// HACK HERE: ENQUEUE YOUR CUSTOM JS FILES, IF NEEDED
add_action( 'wp_enqueue_scripts', function() {
//UNCOMMENT next row to include the js/custom.js file globally
//wp_enqueue_script('custom', get_stylesheet_directory_uri() . '/js/custom.js', array(/* 'jquery' */), null, array('strategy' => 'defer', 'in_footer' => true) );
//UNCOMMENT next 3 rows to load the js file only on one page
//if (is_page('mypageslug')) {
// wp_enqueue_script('custom', get_stylesheet_directory_uri() . '/js/custom.js', array(/* 'jquery' */), null, array('strategy' => 'defer', 'in_footer' => true) );
//}
}, 102);
// OPTIONAL: ADD MORE NAV MENUS
//register_nav_menus( array( 'third' => __( 'Third Menu', 'picostrap' ), 'fourth' => __( 'Fourth Menu', 'picostrap' ), 'fifth' => __( 'Fifth Menu', 'picostrap' ), ) );
// THEN USE SHORTCODE: [lc_nav_menu theme_location="third" container_class="" container_id="" menu_class="navbar-nav"]
// CHECK PARENT THEME VERSION
add_action( 'admin_notices', function () {
if( (pico_get_parent_theme_version())>=3.0) return;
$message = __( 'This Child Theme requires at least Picostrap Version 3.0.0 in order to work properly. Please update the parent theme.', 'picostrap' );
printf( '<div class="%1$s"><h1>%2$s</h1></div>', esc_attr( 'notice notice-error' ), esc_html( $message ) );
} );
// FOR SECURITY: DISABLE APPLICATION PASSWORDS. Remove if needed (unlikely!)
add_filter( 'wp_is_application_passwords_available', '__return_false' );
// ADD YOUR CUSTOM PHP CODE DOWN BELOW /////////////////////////