-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.php
More file actions
129 lines (106 loc) · 3.05 KB
/
functions.php
File metadata and controls
129 lines (106 loc) · 3.05 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
<?php
/**
* The theme's functions file that loads on EVERY page, used for uniform functionality.
*
* @since 1.0.0
* @package RBM_Projects_Theme
*/
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
// Make sure PHP version is correct
if ( ! version_compare( PHP_VERSION, '5.3.0', '>=' ) ) {
wp_die( 'ERROR in RBM Projects theme: PHP version 5.3 or greater is required.' );
}
// Make sure no theme constants are already defined (realistically, there should be no conflicts)
if ( defined( 'THEME_VER' ) ||
defined( 'THEME_URL' ) ||
defined( 'THEME_DIR' ) ||
defined( 'THEME_FILE' ) ||
isset( $theme_fonts ) ) {
wp_die( 'ERROR in RBM Projects theme: There is a conflicting constant. Please either find the conflict or rename the constant.' );
}
/**
* Define Constants based on our Stylesheet Header. Update things only once!
*/
$theme_header = wp_get_theme();
define( 'THEME_VER', $theme_header->get( 'Version' ) );
define( 'THEME_URL', get_stylesheet_directory_uri() );
define( 'THEME_DIR', get_stylesheet_directory() );
/**
* Fonts for the theme. Must be hosted font (Google fonts for example).
*/
$theme_fonts = array(
'open-sans' => '//fonts.googleapis.com/css?family=Open+Sans:300italic,700,300,800',
'font-awesome' => '//maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css',
);
/**
* Register theme files.
*
* @since 1.0.0
*/
add_action( 'init', function () {
global $theme_fonts;
// Parent Style, because twentysixteen wasn't built with Child Themes in mind at all
wp_register_style(
'rbm-projects-parent-theme',
get_template_directory_uri() . '/style.css',
null,
defined( 'WP_DEBUG' ) && WP_DEBUG ? time() : THEME_VER
);
// Theme styles
wp_register_style(
'rbm-projects-theme',
THEME_URL . '/style.css',
array( 'rbm-projects-parent-theme' ),
defined( 'WP_DEBUG' ) && WP_DEBUG ? time() : THEME_VER
);
// Theme script
wp_register_script(
'rbm-projects-theme',
THEME_URL . '/assets/js/script.js',
array( 'jquery' ),
defined( 'WP_DEBUG' ) && WP_DEBUG ? time() : THEME_VER,
true
);
// Theme fonts
if ( ! empty( $theme_fonts ) ) {
foreach ( $theme_fonts as $ID => $link ) {
wp_register_style(
'rbm-projects-theme' . "-font-$ID",
$link
);
}
}
} );
/**
* Enqueue theme files.
*
* @since 1.0.0
*/
add_action( 'wp_enqueue_scripts', function () {
global $theme_fonts;
// Parent styles, because twentysixteen wasn't built with Child Themes in mind at all
wp_enqueue_style( 'rbm-projects-parent-theme' );
// Theme styles
wp_enqueue_style( 'rbm-projects-theme' );
// Theme script
wp_enqueue_script( 'rbm-projects-theme' );
// Theme fonts
if ( ! empty( $theme_fonts ) ) {
foreach ( $theme_fonts as $ID => $link ) {
wp_enqueue_style( 'rbm-projects-theme' . "-font-$ID" );
}
}
} );
/**
* Setup theme properties and stuff
*
* @since 1.0.0
* @return void
*/
add_action( 'after_setup_theme', function () {
// Add theme support
require_once __DIR__ . '/core/theme-support.php';
// Allow shortcodes in text widget
add_filter( 'widget_text', 'do_shortcode' );
} );