PluginProbe
Zone Manager (Zoninator) / 0.7
Zone Manager (Zoninator) v0.7
trunk 0.1 0.10.0 0.10.1 0.10.2 0.11.0 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9
zoninator / functions.php

functions.php in Zone Manager (Zoninator) 0.7, at functions.php

86 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 function z_get_zoninator() {
4 global $zoninator;
5 return $zoninator;
6 }
7
8 /**
9 * Get a list of all zones
10 * @return array List of all zones
11 */
12 function z_get_zones() {
13 return z_get_zoninator()->get_zones();
14 }
15
16 /**
17 * @param $zone int|string ID or Slug of the zone
18 * @return array Zone object
19 */
20 function z_get_zone( $zone ) {
21 return z_get_zoninator()->get_zone( $zone );
22 }
23
24 /**
25 * @param $zone int|string ID or Slug of the zone
26 * @param $args array override default zoninator args
27 * @return array List of orders post objects
28 */
29 function z_get_posts_in_zone( $zone, $args = array() ) {
30 return z_get_zoninator()->get_zone_posts( $zone, $args );
31 }
32
33 /**
34 * @param $zone int|string ID or Slug of the zone
35 * @return WP_Query List of orders post objects
36 */
37 function z_get_zone_query( $zone, $args = array() ) {
38 return z_get_zoninator()->get_zone_query( $zone, $args );
39 }
40
41 /**
42 * @param $zone int|string ID or Slug of the zone
43 * @param $post_id int ID of the post (or, null if in The Loop)
44 * @return array|false Returns next post relative to post_id for the given zone
45 */
46 function z_get_next_post_in_zone( $zone, $post_id = 0 ) {
47 $post_id = z_get_loop_post_id_or_default( $post_id );
48 return z_get_zoninator()->get_next_post_in_zone( $zone, $post_id );
49 }
50
51 /**
52 * @param $zone int|string ID or Slug of the zone
53 * @param $post_id int ID of the post (or, null if in The Loop)
54 * @return array|false Returns previous post relative to post_id for the given zone
55 */
56 function z_get_prev_post_in_zone( $zone, $post_id = 0 ) {
57 $post_id = z_get_loop_post_id_or_default( $post_id );
58 return z_get_zoninator()->get_prev_post_in_zone( $zone, $post_id );
59 }
60
61 /**
62 * @param $post_id int ID of the post (or, null if in The Loop)
63 * @return array List of of zones that the given post is in
64 */
65 function z_get_post_zones( $post_id = 0 ) {
66 $post_id = z_get_loop_post_id_or_default( $post_id );
67 return z_get_zoninator()->get_zones_for_post( $post_id );
68 }
69
70 function z_get_loop_post_id_or_default( $post_id = 0 ) {
71 if( ! $post_id ) {
72 global $post;
73 if( $post && isset( $post->ID ) ) $post_id = $post->ID;
74 }
75 return $post_id;
76 }
77
78 /**
79 * Handy function to disable the locking mechanism
80 */
81 function z_disable_zoninator_locks() {
82 return -1;
83 }
84
85 // (Should probably publicly expose set_zone_posts as well, e.g. if we wanted to add a metabox on the Edit Post page)
86