forked from interglobalvision/pindropstudio-com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
executable file
·119 lines (86 loc) · 3.06 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<?php
// Enqueue
function scripts_and_styles_method() {
$templateuri = get_template_directory_uri() . '/js/';
// library.js is to bundle plugins. my.js is your scripts. enqueue more files as needed
$jslib = $templateuri . 'library.min.js';
wp_enqueue_script( 'jslib', $jslib,'','',true);
$myscripts = $templateuri . 'main.min.js';
wp_register_script( 'myscripts', $myscripts );
$is_admin = current_user_can('administrator') ? 1 : 0;
$jsVars = array(
'siteUrl' => home_url(),
'themeUrl' => get_template_directory_uri(),
'isAdmin' => $is_admin,
);
wp_localize_script( 'myscripts', 'WP', $jsVars );
wp_enqueue_script( 'myscripts', $myscripts,'','',true);
// enqueue stylesheet here. file does not exist until stylus file is processed
wp_enqueue_style( 'site', get_stylesheet_directory_uri() . '/css/site.min.css' );
// dashicons for admin
if(is_admin()){
wp_enqueue_style( 'dashicons' );
}
}
add_action('wp_enqueue_scripts', 'scripts_and_styles_method');
// Declare thumbnail sizes
get_template_part( 'lib/thumbnail-sizes' );
// Register Nav Menus
/*
register_nav_menus( array(
'menu_location' => 'Location Name',
) );
*/
// Add third party PHP libs
function cmb_initialize_cmb_meta_boxes() {
if (!class_exists( 'cmb2_bootstrap_202' ) ) {
require_once 'vendor/webdevstudios/cmb2/init.php';
require_once 'vendor/webdevstudios/cmb2-post-search-field/lib/init.php';
}
}
add_action( 'init', 'cmb_initialize_cmb_meta_boxes', 10 );
function composer_autoload() {
require_once( 'vendor/autoload.php' );
}
add_action( 'init', 'composer_autoload', 11 );
// Add libs
get_template_part( 'lib/custom-gallery' );
get_template_part( 'lib/post-types' );
get_template_part( 'lib/meta-boxes' );
get_template_part( 'lib/theme-options/theme-options' );
// Add custom functions
get_template_part( 'lib/functions-misc' );
get_template_part( 'lib/functions-render' );
get_template_part( 'lib/functions-custom' );
get_template_part( 'lib/functions-filters' );
get_template_part( 'lib/functions-hooks' );
get_template_part( 'lib/functions-utility' );
function fix_luminary_meta($post_id) {
if (get_post_type($post_id) === 'event' || get_post_type($post_id) === 'recording') {
$related_string = get_post_meta($post_id, '_igv_related_luminaries', true);
if ($related_string) {
$related_array = explode(', ', $related_string);
update_post_meta($post_id, '_igv_related_luminaries_array', $related_array);
}
}
// temp fix broken posts
$broken_posts = get_posts( array(
'post_type' => array('event', 'recording'),
'posts_per_page' => -1,
'meta_query' => array(
array(
'key' => '_igv_related_luminaries_array',
'compare' => 'NOT EXISTS',
),
),
));
foreach($broken_posts as $post) {
$related_string = get_post_meta($post->ID, '_igv_related_luminaries', true);
if ($related_string) {
$related_array = explode(', ', $related_string);
update_post_meta($post->ID, '_igv_related_luminaries_array', $related_array);
}
}
}
add_action('save_post', 'fix_luminary_meta', 11);
?>