@@ -23,7 +23,11 @@ function set_comment_geodata( $comment, $key, $geodata ) {
2323}
2424
2525function set_user_geodata ( $ id , $ key , $ geodata ) {
26- return Geo_Data::set_geodata ( 'user ' , $ id , $ key , $ geodata );
26+ $ user = sloc_get_user ( $ id );
27+ if ( $ user ) {
28+ return false ;
29+ }
30+ return Geo_Data::set_geodata ( 'user ' , $ user ->ID , $ key , $ geodata );
2731}
2832
2933function set_term_geodata ( $ id , $ key , $ geodata ) {
@@ -72,6 +76,9 @@ function get_array_post_geodata( $posts ) {
7276 */
7377function is_day_post ( $ post = null ) {
7478 $ post = get_post ( $ post );
79+ if ( ! $ post ) {
80+ return false ;
81+ }
7582 $ day = get_post_geodata ( $ post , 'day ' );
7683 if ( ! empty ( $ day ) ) {
7784 return $ day ;
@@ -121,8 +128,12 @@ function is_day_comment( $comment = null ) {
121128 * Wrapper around get_geodata for user IDs or objects
122129 *
123130 */
124- function get_user_geodata ( $ user_id , $ key = '' ) {
125- return Geo_Data::get_geodata ( 'user ' , $ user_id , $ key );
131+ function get_user_geodata ( $ user = null , $ key = '' ) {
132+ $ user = sloc_get_user ( $ user );
133+ if ( ! $ user ) {
134+ return false ;
135+ }
136+ return Geo_Data::get_geodata ( 'user ' , $ user ->ID , $ key );
126137}
127138
128139/*
@@ -133,27 +144,36 @@ function get_term_geodata( $term_id, $key = '' ) {
133144 return Geo_Data::get_geodata ( 'term ' , $ term_id , $ key );
134145}
135146
136- function set_post_weatherdata ( $ post_id , $ key , $ weather ) {
137- return Sloc_Weather_Data::set_object_weatherdata ( 'post ' , $ post_id , $ key , $ weather );
147+ function set_post_weatherdata ( $ post , $ key , $ weather ) {
148+ $ post = get_post ( $ post );
149+ if ( ! $ post ) {
150+ return false ;
151+ }
152+ return Sloc_Weather_Data::set_object_weatherdata ( 'post ' , $ post ->ID , $ key , $ weather );
138153}
139154
140155function set_comment_weatherdata ( $ comment_id , $ key , $ weather ) {
141156 return Sloc_Weather_Data::set_object_weatherdata ( 'comment ' , $ comment_id , $ key , $ weather );
142157}
143158
144- function set_user_weatherdata ( $ user_id , $ weather ) {
145- return Sloc_Weather_Data::set_object_weatherdata ( 'user ' , $ user_id , $ key , $ weather );
159+ function set_user_weatherdata ( $ user , $ weather ) {
160+ $ user = sloc_get_user ( $ user );
161+ if ( ! $ user ) {
162+ return false ;
163+ }
164+ return Sloc_Weather_Data::set_object_weatherdata ( 'user ' , $ user ->ID , $ key , $ weather );
146165}
147166
148167function set_term_weatherdata ( $ term_id , $ weather ) {
149168 return Sloc_Weather_Data::set_object_weatherdata ( 'term ' , $ term_id , $ key , $ weather );
150169}
151170
152- function get_post_weatherdata ( $ post_id = null , $ key = '' ) {
153- if ( ! $ post_id ) {
154- $ post_id = get_the_ID ();
171+ function get_post_weatherdata ( $ post = null , $ key = '' ) {
172+ $ post = get_post ( $ post );
173+ if ( ! $ post ) {
174+ return false ;
155175 }
156- return Sloc_Weather_Data::get_object_weatherdata ( 'post ' , $ post_id , $ key );
176+ return Sloc_Weather_Data::get_object_weatherdata ( 'post ' , $ post -> ID , $ key );
157177}
158178
159179function get_comment_weatherdata ( $ comment_id , $ key = '' ) {
@@ -164,19 +184,28 @@ function get_term_weatherdata( $term_id, $key = '' ) {
164184 return Sloc_Weather_Data::get_object_weatherdata ( 'term ' , $ term_id , $ key );
165185}
166186
167- function get_user_weatherdata ( $ user_id , $ key = '' ) {
168- return Sloc_Weather_Data::get_object_weatherdata ( 'user ' , $ user_id , $ key );
187+ function get_user_weatherdata ( $ user , $ key = '' ) {
188+ $ user = sloc_get_user ( $ user );
189+ if ( ! $ user ) {
190+ return false ;
191+ }
192+ return Sloc_Weather_Data::get_object_weatherdata ( 'user ' , $ user ->ID , $ key );
169193}
170194
171- function get_post_map ( $ post_id = null , $ args = array () ) {
172- if ( ! $ post_id ) {
173- $ post_id = get_the_ID ();
195+ function get_post_map ( $ post = null , $ args = array () ) {
196+ $ post = get_post ( $ post );
197+ if ( ! $ post ) {
198+ return false ;
174199 }
175- return Geo_Data::get_map ( 'post ' , $ post_id , $ args );
200+ return Geo_Data::get_map ( 'post ' , $ post -> ID , $ args );
176201}
177202
178- function get_user_map ( $ user_id , $ args = array () ) {
179- return Geo_Data::get_map ( 'user ' , $ user_id , $ args );
203+ function get_user_map ( $ user , $ args = array () ) {
204+ $ user = sloc_get_user ( $ user );
205+ if ( ! $ user ) {
206+ return false ;
207+ }
208+ return Geo_Data::get_map ( 'user ' , $ user ->ID , $ args );
180209}
181210
182211function get_comment_map ( $ comment_id , $ args = array () ) {
@@ -195,19 +224,24 @@ function get_simple_location( $object = null, $args = array() ) {
195224 return Geo_Data::get_location ( sloc_get_type_from_object ( $ object ), sloc_get_id_from_object ( $ object ), $ args );
196225}
197226
198- function get_post_location ( $ id = null , $ args = array () ) {
199- if ( ! $ id ) {
200- $ id = get_the_ID ();
227+ function get_post_location ( $ post = null , $ args = array () ) {
228+ $ post = get_post ( $ post );
229+ if ( ! $ post ) {
230+ return false ;
201231 }
202- return Geo_Data::get_location ( 'post ' , $ id , $ args );
232+ return Geo_Data::get_location ( 'post ' , $ post -> ID , $ args );
203233}
204234
205235function get_comment_location ( $ id , $ args = array () ) {
206236 return Geo_Data::get_location ( 'comment ' , $ id , $ args );
207237}
208238
209- function get_user_location ( $ id , $ args = array () ) {
210- return Geo_Data::get_location ( 'user ' , $ id , $ args );
239+ function get_user_location ( $ user , $ args = array () ) {
240+ $ user = sloc_get_user ( $ user );
241+ if ( ! $ user ) {
242+ return false ;
243+ }
244+ return Geo_Data::get_location ( 'user ' , $ user ->ID , $ args );
211245}
212246
213247function get_term_location ( $ id , $ args = array () ) {
0 commit comments