PluginProbe
Zone Manager (Zoninator) / 0.4
Zone Manager (Zoninator) v0.4
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.4, at functions.php

87 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 * @return array List of orders post objects
27 */
28 function z_get_posts_in_zone( $zone, $args = array() ) {
29 // TODO: return only published posts by default
30 // TODO: ability to grab draft as well
31
32 return z_get_zoninator()->get_zone_posts( $zone );
33 }
34
35 /**
36 * @param $zone int|string ID or Slug of the zone
37 * @return array List of orders post objects
38 */
39 function z_get_zone_query( $zone ) {
40 return z_get_zoninator()->get_zone_query( $zone );
41 }
42
43 /**
44 * @param $zone int|string ID or Slug of the zone
45 * @param $post_id int ID of the post (or, null if in The Loop)
46 * @return array|false Returns next post relative to post_id for the given zone
47 */
48 function z_get_next_post_in_zone( $zone, $post_id = 0 ) {
49 $post_id = z_get_loop_post_id_or_default( $post_id );
50 return z_get_zoninator()->get_next_post_in_zone( $zone, $post_id );
51 }
52
53 /**
54 * @param $zone int|string ID or Slug of the zone
55 * @param $post_id int ID of the post (or, null if in The Loop)
56 * @return array|false Returns previous post relative to post_id for the given zone
57 */
58 function z_get_prev_post_in_zone( $zone, $post_id = 0 ) {
59 $post_id = z_get_loop_post_id_or_default( $post_id );
60 return z_get_zoninator()->get_prev_post_in_zone( $zone, $post_id );
61 }
62
63 /**
64 * @param $post_id int ID of the post (or, null if in The Loop)
65 * @return array List of of zones that the given post is in
66 */
67 function z_get_post_zones( $post_id = 0 ) {
68 $post_id = z_get_loop_post_id_or_default( $post_id );
69 return z_get_zoninator()->get_zones_for_post( $post_id );
70 }
71
72 function z_get_loop_post_id_or_default( $post_id = 0 ) {
73 if( ! $post_id ) {
74 global $post;
75 if( $post && isset( $post->ID ) ) $post_id = $post->ID;
76 }
77 return $post_id;
78 }
79
80 /**
81 * Handy function to disable the locking mechanism
82 */
83 function z_disable_zoninator_locks() {
84 return -1;
85 }
86
87 // (Should probably publicly expose set_zone_posts as well, e.g. if we wanted to add a metabox on the Edit Post page)