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

91 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 // phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- Yes, a prefix of z is too short, but fixing this is a breaking change.
3
4 function z_get_zoninator() {
5 global $zoninator;
6 return $zoninator;
7 }
8
9 /**
10 * Get a list of all zones
11 *
12 * @return array List of all zones
13 */
14 function z_get_zones() {
15 return z_get_zoninator()->get_zones();
16 }
17
18 /**
19 * @param $zone int|string ID or Slug of the zone
20 * @return array Zone object
21 */
22 function z_get_zone( $zone ) {
23 return z_get_zoninator()->get_zone( $zone );
24 }
25
26 /**
27 * @param $zone int|string ID or Slug of the zone
28 * @param $args array override default zoninator args
29 * @return array List of orders post objects
30 */
31 function z_get_posts_in_zone( $zone, $args = array() ) {
32 return z_get_zoninator()->get_zone_posts( $zone, $args );
33 }
34
35 /**
36 * @param $zone int|string ID or Slug of the zone
37 * @return WP_Query List of orders post objects
38 */
39 function z_get_zone_query( $zone, $args = array() ) {
40 return z_get_zoninator()->get_zone_query( $zone, $args );
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 ) ) {
76 $post_id = $post->ID;
77 }
78 }
79
80 return $post_id;
81 }
82
83 /**
84 * Handy function to disable the locking mechanism
85 */
86 function z_disable_zoninator_locks() {
87 return -1;
88 }
89
90 // (Should probably publicly expose set_zone_posts as well, e.g. if we wanted to add a metabox on the Edit Post page)
91