-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin_functions.php
More file actions
41 lines (32 loc) · 1.07 KB
/
plugin_functions.php
File metadata and controls
41 lines (32 loc) · 1.07 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
<?php
function get_video_code($url) {
$code = '';
if (strpos($url, 'youtube') > 0) {
$parts = parse_url($url);
parse_str($parts['query'], $query);
$code = $query['v'];
}
if (strpos($url, 'youtu.be') > 0) {
$parts = parse_url($url);
$code = end(explode('/', $parts['path']));
}
return $code;
}
function is_shortcode($content) {
$pattern = get_shortcode_regex();
if ( preg_match_all( '/'. $pattern .'/s', $content, $matches ) && array_key_exists( 2, $matches ) ) {
return true;
}
return false;
}
function get_modified_date($post_id) {
$u_time = get_the_time('U', $post_id);
$u_modified_time = get_the_modified_time('U', $post_id);
if ($u_modified_time >= $u_time + 86400) {
$updated_date = get_the_modified_time('d/m/Y', $post_id);
} else {
$updated_date = get_the_time('d/m/Y', $post_id);
}
return $updated_date;
}
?>