-
Notifications
You must be signed in to change notification settings - Fork 1
/
functions.php
104 lines (84 loc) · 2.99 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
<?php
/**
* Functions and definitions
*
* @link https://developer.wordpress.org/themes/basics/theme-functions/
*
* @package Beflex
* @since 4.0.0
*/
if ( ! function_exists( 'beflextheme_support' ) ) :
/**
* Theme support
*/
function beflextheme_support() {
// Adding support for featured images.
add_theme_support( 'post-thumbnails' );
// Adding support for core block visual styles.
add_theme_support( 'wp-block-styles' );
// Adding support for responsive embedded content.
add_theme_support( 'responsive-embeds' );
// Add support for editor styles.
add_theme_support( 'editor-styles' );
// Add support theme for Sensei
add_theme_support( 'sensei' );
// Enqueue editor styles.
add_editor_style( get_template_directory_uri() . '/assets/css/style.min.css' );
add_editor_style( 'style.css' );
// Add support for custom units.
add_theme_support( 'custom-units' );
load_theme_textdomain( 'beflex', get_template_directory() . '/assets/lang/' );
load_theme_textdomain( 'sensei-lms', get_template_directory() . '/assets/sensei-lms-lang/' );
}
add_action( 'after_setup_theme', 'beflextheme_support' );
endif;
/**
* Enqueue scripts and styles.
*/
function beflextheme_scripts() {
// Enqueue theme stylesheets.
wp_enqueue_style( 'beflex-style', get_template_directory_uri() . '/assets/css/style.min.css', array(), wp_get_theme()->get( 'Version' ) );
wp_enqueue_style( 'beflex-sensei-style', get_template_directory_uri() . '/assets/css/style-sensei.min.css', array(), wp_get_theme()->get( 'Version' ) );
// Enqueue theme scripts.
wp_enqueue_script( 'beflex-script', get_template_directory_uri() . '/assets/js/theme.js', array( 'jquery' ), '', true );
}
add_action( 'wp_enqueue_scripts', 'beflextheme_scripts' );
/**
* Enqueue script for Gutenberg Editor
*/
function beflextheme_editor_scripts() {
wp_enqueue_script('beflex-gutenberg-animation-in', get_template_directory_uri() . '/assets/js/gutenberg-build/block-animation-in.js', ['wp-edit-post']);
wp_enqueue_script('beflex-gutenberg-hide-on-mobile', get_template_directory_uri() . '/assets/js/gutenberg-build/block-hide-on-mobile.js', ['wp-edit-post']);
}
add_action( 'enqueue_block_editor_assets', 'beflextheme_editor_scripts' );
/**
* Add class to body
*
* @param Array $classes Body classes.
* @return Array $classes Body classes.
*/
function beflex_add_custom_classes_to_body( $classes ) {
if ( ! is_admin() ) {
$classes[] = 'frontend';
}
return $classes;
}
add_filter( 'body_class', 'beflex_add_custom_classes_to_body' );
/**
* Création admin page for theme settings
*/
if( function_exists('acf_add_options_page') ) {
acf_add_options_page( array(
'page_title' => esc_html__('BeFlex Settings', 'beflex'),
'menu_title' => esc_html__('BeFlex Settings', 'beflex'),
'menu_slug' => 'theme-general-settings',
'parent_slug' => 'themes.php',
'capability' => 'edit_pages',
));
}
// Block patterns.
require_once 'inc/block-patterns.php';
// Theme blocks
require_once 'inc/blocks.php';
// Sensei functions
require_once 'sensei/functions.php';