-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfunctions.php
More file actions
168 lines (130 loc) · 4.39 KB
/
functions.php
File metadata and controls
168 lines (130 loc) · 4.39 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
<?php
add_theme_support( 'post-thumbnails' );
//enqueues scripts and styles
require_once("functions/functions-enqueue.php");
//require_once("xr/xr.php"); // oh yes, webxr is here, boyeee
//handles custom metaboxes for admin
require_once("functions/functions-metabox.php");
//enqueues scripts and styles
require_once("functions/functions-rest-endpoints.php");
// special class to register the restapi
//enqueues scripts and styles
//require_once("functions/functions-post-types.php");
require_once("functions/functions-rest-menus.php");
// custom functions to register fields into the restapi
require_once("functions/functions-rest-register.php");
require_once("functions/functions-rest-taxonomy.php");
require_once("functions/functions-navigation.php");
require_once("functions/functions-print.php");
require_once("functions/parsers.php");
require_once("profiler/profiler.php");
add_theme_support('post-thumbnails', array(
'post',
'page',
'social',
'profiles',
'resources'
));
/* OLD RELIABLE!
HASN'T CHANGED IN YEARS
RETURNS URL BY ID, AND OPTIONAL SIZE */
function getThumbnail($id,$use="full"){
global $post;
$img = wp_get_attachment_image_src( $id, $use);
if($img[0] !=""){
}
return $img;//$img[0];
}
/* PASS ID AND IT RETURNS OBJECT OF SIZES BY URL */
function getThumbnailVersions($id){
global $post;
$thumbnail_versions = array(); //creates the array of size by url
foreach(get_intermediate_image_sizes() as $key => $size){//loop through sizes
$img = wp_get_attachment_image_src($id,$size);//get the url
if(@$img[0] !=""){
$thumbnail_versions[$size]=$img[0];//sets size by url
}
}
return $thumbnail_versions;
}
//Embed Video Shortcode
function video_shortcode( $atts, $content = null ) {
//set default attributes and values
$values = shortcode_atts( array(
'url' => '#',
'className' => 'video-embed',
'aspect' => '56.25%'
), $atts );
ob_start();
?>
<div class="video-wrapper">
<iframe src="<?=$values['url']?>" class="<?=$values['className']?>"></iframe>
</div>
<?php
return ob_get_clean();
//return '<a href="'. esc_attr($values['url']) .'" target="'. esc_attr($values['target']) .'" class="btn btn-green">'. $content .'</a>';
}
add_shortcode( 'embed_video', 'video_shortcode' );
function add_category_to_page() {
// Add tag metabox to page
register_taxonomy_for_object_type('post_tag', 'page');
// Add category metabox to page
register_taxonomy_for_object_type('category', 'page');
}
// Add to the admin_init hook of your theme functions.php file
add_action( 'init', 'add_category_to_page' );
function buttonLink($id){
ob_start();
?>
<div id="button-container">
<div id="button_card" class="shadow">
<div class="front face">
<img src="/wp-content/uploads/2018/05/powersimple-emblem-01.svg"/>
</div>
<div class="back face">
<h2>Home</h2>
<p style="font-weight: 100; margin-top: -40px;">This isn't my logo, but it's a nice one to feature and show off this CSS!</p>
</div>
</div>
</div>
<?php
return ob_get_clean();
}
add_action( 'rest_api_init', 'register_video_meta' );
function register_video_meta() {
register_rest_field( 'page',
'video',
array(
'get_callback' => 'get_featured_video',
'update_callback' => null,
'schema' => null,
)
);
}
function display_videos($videos){
ob_start();
$default_video = $videos[0]['video_url'];
$default_video_title = $videos[0]['post_title'];
?>
<div id="videos">
<div id="video-player">
<iframe src="<?=$default_video?>?rel=0&fs=1" scrolling="no" frameborder="0" id="video" allowfullscreen></iframe>
</div>
<p id="video-title-display"><?=$default_video_title?></p>
<ul id="video-playlist">
<?php
foreach($videos as $key => $value){
extract($value);
$title_clean = str_replace('"','',$post_title);
$title_clean = str_replace("'","\'",$title_clean);
?>
<li><a href="#" onMouseover="displayTitle('Watch: <?=$title_clean?>');" onMouseOut="" onClick="play('<?=$video_url?>?rel=0', '<?=$title_clean ?>'); return false;" title="<?=$title_clean ?>"><img src="<?=$src?>" alt="<?=$title_clean?>"></a><span class="video-label"><?=$post_title?></span></li>
<?php
}
?>
</ul>
</div>
<?php
return ob_get_clean();
}
?>