-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
72 lines (54 loc) · 1.93 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
<?php
/**
* Functions and definitions.
*
* @package stmark
*/
add_action( 'wp_enqueue_scripts', 'stmark_styles' );
add_filter( 'post_class', 'smcs_post_classes', 10, 3 );
function stmark_styles() {
global $post;
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
wp_enqueue_style( 'child-styles', get_theme_file_uri( "style{$suffix}.css" ), array( 'avada-stylesheet' ) );
wp_register_style( 'sm-form-styles', get_theme_file_uri( 'css/' . sm_get_asset_rev( 'sm-forms' ) . '.css' ), array( 'child-styles' ) );
if ( is_singular( array( 'registration_pages', 'smcs_athletics', 'gravityview', 'sc_event' ) ) ) {
wp_enqueue_style( 'sm-form-styles' );
}
if(sc_is_calendar_page()) {
wp_enqueue_style( 'sm-form-styles' );
}
$content = isset( $post->post_content ) ? $post->post_content : '';
if(sc_is_calendar_page() || is_singular('sc_event') || has_shortcode( $content, 'sc_events_list')) {
wp_enqueue_style( 'sm-form-styles' );
}
}
function smcs_post_classes( $classes, $class, $post_id ) {
if ( is_admin() ) {
return $classes;
}
if ( is_singular( array( 'registration_pages', 'smcs_athletics', 'gravityview' ) ) ) {
$classes[] = 'smcs-post';
}
return $classes;
}
/**
* Append Hash to assets filename to purge the browser cache when changed.
*/
function sm_get_asset_rev( $filename ) {
// if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
// return $filename;
// }
$version = 'cssVersion';
// Cache the decoded manifest so that we only read it in once.
static $manifest = null;
if ( null === $manifest ) {
$manifest_path = get_theme_file_path( 'package.json' );
$manifest = file_exists( $manifest_path ) ? json_decode( file_get_contents( $manifest_path ), true ) : [];
}
// If the manifest contains the requested file, return the hashed name.
if ( array_key_exists( $version, $manifest ) ) {
return $filename . '-' . $manifest[ $version ];
}
// File hash wasn't found.
return $filename;
}