-
Notifications
You must be signed in to change notification settings - Fork 50
/
functions.php
90 lines (78 loc) · 2.48 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
<?php
// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- Yes, a prefix of z is too short, but fixing this is a breaking change.
function z_get_zoninator() {
global $zoninator;
return $zoninator;
}
/**
* Get a list of all zones
*
* @return array List of all zones
*/
function z_get_zones() {
return z_get_zoninator()->get_zones();
}
/**
* @param $zone int|string ID or Slug of the zone
* @return array Zone object
*/
function z_get_zone( $zone ) {
return z_get_zoninator()->get_zone( $zone );
}
/**
* @param $zone int|string ID or Slug of the zone
* @param $args array override default zoninator args
* @return array List of orders post objects
*/
function z_get_posts_in_zone( $zone, $args = array() ) {
return z_get_zoninator()->get_zone_posts( $zone, $args );
}
/**
* @param $zone int|string ID or Slug of the zone
* @return WP_Query List of orders post objects
*/
function z_get_zone_query( $zone, $args = array() ) {
return z_get_zoninator()->get_zone_query( $zone, $args );
}
/**
* @param $zone int|string ID or Slug of the zone
* @param $post_id int ID of the post (or, null if in The Loop)
* @return array|false Returns next post relative to post_id for the given zone
*/
function z_get_next_post_in_zone( $zone, $post_id = 0 ) {
$post_id = z_get_loop_post_id_or_default( $post_id );
return z_get_zoninator()->get_next_post_in_zone( $zone, $post_id );
}
/**
* @param $zone int|string ID or Slug of the zone
* @param $post_id int ID of the post (or, null if in The Loop)
* @return array|false Returns previous post relative to post_id for the given zone
*/
function z_get_prev_post_in_zone( $zone, $post_id = 0 ) {
$post_id = z_get_loop_post_id_or_default( $post_id );
return z_get_zoninator()->get_prev_post_in_zone( $zone, $post_id );
}
/**
* @param $post_id int ID of the post (or, null if in The Loop)
* @return array List of of zones that the given post is in
*/
function z_get_post_zones( $post_id = 0 ) {
$post_id = z_get_loop_post_id_or_default( $post_id );
return z_get_zoninator()->get_zones_for_post( $post_id );
}
function z_get_loop_post_id_or_default( $post_id = 0 ) {
if ( ! $post_id ) {
global $post;
if ( $post && isset( $post->ID ) ) {
$post_id = $post->ID;
}
}
return $post_id;
}
/**
* Handy function to disable the locking mechanism
*/
function z_disable_zoninator_locks() {
return -1;
}
// (Should probably publicly expose set_zone_posts as well, e.g. if we wanted to add a metabox on the Edit Post page)