SHOW:
|
|
- or go back to the newest paste.
1 | <?php | |
2 | /* | |
3 | Plugin Name: Petfinder Listings | |
4 | Plugin URI: http://www.unboxinteractive.com/wordpress/petfinder-listings-plugin/ | |
5 | Description: The Petfinder Listings plugin takes advantage of the Petfinder API and can be integrated into your site without coding. | |
6 | Version: 1.0.10 | |
7 | Author: Bridget Wessel | |
8 | Author URI: http://www.unboxinteractive.com/ | |
9 | License: GPLv2 | |
10 | */ | |
11 | ||
12 | /* Copyright 2014 Bridget Wessel (email : bridget@unboxinteractive.com) | |
13 | ||
14 | This program is free software; you can redistribute it and/or modify | |
15 | it under the terms of the GNU General Public License, version 2, as | |
16 | published by the Free Software Foundation. | |
17 | ||
18 | This program is distributed in the hope that it will be useful, | |
19 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
21 | GNU General Public License for more details. | |
22 | ||
23 | You should have received a copy of the GNU General Public License | |
24 | along with this program; if not, write to the Free Software | |
25 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
26 | */ | |
27 | ||
28 | /********** Add default styles ************/ | |
29 | ||
30 | ini_set("allow_url_fopen", true); | |
31 | ini_set("allow_url_include", true); | |
32 | ||
33 | ||
34 | function petfinder_listings_styles(){ | |
35 | wp_register_style('petfinder-listings-style', plugins_url( 'petfinder.css', __FILE__ )); | |
36 | wp_enqueue_style('petfinder-listings-style'); | |
37 | } | |
38 | add_action('init', 'petfinder_listings_styles'); | |
39 | ||
40 | ||
41 | /********** Add js to switch out photos ***********/ | |
42 | function petfinder_listings_scripts() { | |
43 | if (!is_admin()){ | |
44 | wp_register_script( 'petfinder_listings_scripts', plugins_url( '/petfinder.js', __FILE__ )); | |
45 | wp_enqueue_script( 'petfinder_listings_scripts' ); | |
46 | } | |
47 | } | |
48 | ||
49 | add_action('wp_enqueue_scripts', 'petfinder_listings_scripts', 10, 1); | |
50 | ||
51 | //add defaults to an array | |
52 | $petf_options = array( | |
53 | 'apikey' => 'default', | |
54 | 'shelter_id' => 'default', | |
55 | 'thumbnail' => 'pnt', | |
56 | 'large_image' => 'pn', | |
57 | 'powered_by' => 'Yes' | |
58 | ); | |
59 | ||
60 | include( dirname(__FILE__) . '/featuredpet-widget.php' ); | |
61 | ||
62 | //add settings to database if not already set | |
63 | ||
64 | add_option('Petfinder-Listings', $petf_options); | |
65 | $petf_options = get_option('Petfinder-Listings'); | |
66 | ||
67 | if(!isset($petf_options["powered_by"])){ | |
68 | $petf_options["powered_by"] = "Yes"; | |
69 | } | |
70 | ||
71 | // create custom plugin settings menu | |
72 | ||
73 | add_action('admin_menu', 'petf_admin_page'); | |
74 | add_action( 'widgets_init', create_function('', 'return register_widget("Petfinder_Listings_Featured_Pet");') ); | |
75 | ||
76 | function petf_admin_page() { | |
77 | add_options_page('Petfinder Listings Plugin Settings', 'Petfinder Listings', 'manage_options', 'petf', 'petf_options_page'); | |
78 | } | |
79 | ||
80 | // Add Settings to Plugin Menu | |
81 | $pluginName = plugin_basename( __FILE__ ); | |
82 | ||
83 | add_filter( 'plugin_action_links_' . $pluginName, 'petf_pluginActions' ); | |
84 | ||
85 | function petf_pluginActions( $links ) { | |
86 | $settings_link = | |
87 | '<a href="' . get_admin_url( null, 'options-general.php' ) . "?page=petf".'">' . | |
88 | __('Settings') . '</a>'; | |
89 | array_unshift( $links, $settings_link ); | |
90 | return $links; | |
91 | } | |
92 | ||
93 | ||
94 | ||
95 | //write settings page | |
96 | function petf_options_page() { | |
97 | global $petf_options; | |
98 | if(isset($_POST['save_changes'])) { | |
99 | check_admin_referer('petfinder-listings-update_settings'); | |
100 | ||
101 | $petf_options['apikey'] = trim($_POST['apikey']); | |
102 | $petf_options['shelter_id'] = trim($_POST['shelter_id']); | |
103 | $petf_options['thumbnail'] = trim($_POST['thumbnail']); | |
104 | $petf_options['large_image'] = trim($_POST['large_image']); | |
105 | $petf_options['powered_by'] = trim($_POST['powered_by']); | |
106 | ||
107 | update_option('Petfinder-Listings', $petf_options); | |
108 | ||
109 | echo "<div class=\"error\">Your changes have been saved successfully!</div>"; | |
110 | } | |
111 | ?> | |
112 | <div class="wrap"> | |
113 | ||
114 | <h2>Petfinder Settings</h2> | |
115 | ||
116 | <form name="petfinder-options" action="options-general.php?page=petf" method="post"> | |
117 | <?php | |
118 | if ( function_exists( 'wp_nonce_field' ) ) | |
119 | wp_nonce_field( 'petfinder-listings-update_settings' ); ?> | |
120 | ||
121 | <table class="form-table"> | |
122 | <tr valign="top"> | |
123 | <th scope="row">Your Petfinder API Key (go <a href="http://www.petfinder.com/developers/api-docs" target="_blank">here</a> to get one)</th> | |
124 | <td><input type="text" name="apikey" value="<?php echo $petf_options["apikey"] ?>" /></td> | |
125 | </tr> | |
126 | ||
127 | <tr valign="top"> | |
128 | <th scope="row">Shelter ID</th> | |
129 | <td><input type="text" name="shelter_id" value="<?php echo $petf_options["shelter_id"] ?>" /></td> | |
130 | </tr> | |
131 | ||
132 | <tr valign="top"> | |
133 | <th scope="row">Thumbnail Size (select fixed side size, other side varies depending on ratio of original photo)</th> | |
134 | <td><select name="thumbnail"> | |
135 | <option value="t" <?php echo $petf_options["thumbnail"] == "t" ? "selected='selected'" : ""?>>scaled to 50 pixels tall</option> | |
136 | <option value="pnt" <?php echo $petf_options["thumbnail"] == "pnt" ? "selected='selected'" : ""?>>scaled to 60 pixels wide</option> | |
137 | <option value="fpm" <?php echo $petf_options["thumbnail"] == "fpm" ? "selected='selected'" : ""?>>scaled to 95 pixels wide</option> | |
138 | </select></td> | |
139 | </tr> | |
140 | ||
141 | <tr valign="top"> | |
142 | <th scope="row">Large Image Size</th> | |
143 | <td><select name="large_image"> | |
144 | <option value="x" <?php echo $petf_options["large_image"] == "x" ? "selected='selected'" : "" ?>>original, up to 500x500</option> | |
145 | <option value="pn" <?php echo $petf_options["large_image"] == "pn" ? "selected='selected'" : "" ?>>up to 320x250</option> | |
146 | </select></td> | |
147 | </tr> | |
148 | ||
149 | <tr> | |
150 | <th scope="row">Include Powered by Petfinder at bottom of page. Petfinder provides a great, free service for shelters and it is highly recommended you leave this on your Petfinder pages.</th> | |
151 | <td><input type="radio" value="Yes" name="powered_by" <?php echo ( $petf_options["powered_by"] == "Yes" )? "checked=\"checked\"" : "" ?>>Yes <input type="radio" value="No" name="powered_by" <?php echo ($petf_options["powered_by"] == "No")? "checked=\"checked\"" : "" ?>>No</td> | |
152 | </tr> | |
153 | ||
154 | <tr> | |
155 | <th colspan="2"><p>After saving, create a page with the shortcode [shelter_list] in the content. View this page to see your listings.</p> | |
156 | <p>You can also add the following options to your shortcode<br />[shelter_list shelter_id="WI185" breed="Italian Greyhound" count=75 animal="dog" include_info="no" css_class="igs" contact="Barb Smith"] </p></th> | |
157 | </tr> | |
158 | ||
159 | ||
160 | ||
161 | </table> | |
162 | ||
163 | <p class="submit"> | |
164 | <input type="hidden" name="save_changes" value="1" /> | |
165 | <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" /> | |
166 | </p> | |
167 | ||
168 | </form> | |
169 | </div> | |
170 | ||
171 | <?php } // end function petf_options_page | |
172 | ||
173 | ||
174 | ||
175 | ||
176 | /* | |
177 | For use later - need to convert SimpleXMLElement to array and then change all display data to use array instead of object | |
178 | ||
179 | function sort_by_date($petA, $petB) { | |
180 | if ( (string)$petA->lastUpdate == (string)$petB->lastUpdate ){ | |
181 | return 0; | |
182 | }else if ( (string)$petA->lastUpdate < (string)$petB->lastUpdate ){ | |
183 | - | function sort_pets_new($a,$b){ |
183 | + | |
184 | }else{ | |
185 | - | return strcmp($a->id, $b->id); |
185 | + | |
186 | } | |
187 | }*/ | |
188 | ||
189 | add_shortcode('shelter_list','petf_shelter_list'); | |
190 | ||
191 | /** Using shortcode shelter_list grab all animals for this shelter. | |
192 | * Available Options: shelter_id (if want to list animals from shelter not set in Petfinder Listings settings), breed, count, animal, include_info, css_class and contact. | |
193 | * Breed can be inclusive or exclusive by adding ! before breed name. ***/ | |
194 | function petf_shelter_list( $atts ) { | |
195 | ||
196 | global $petf_options; | |
197 | ||
198 | extract( shortcode_atts( array( | |
199 | 'shelter_id' => $petf_options['shelter_id'], | |
200 | 'breed' => '', | |
201 | 'count' => 75, | |
202 | 'animal' => '', | |
203 | 'include_info' => 'yes', | |
204 | 'css_class' => 'pets', | |
205 | 'contact' => '', | |
206 | 'include_mixes' => 'no', | |
207 | 'status' => 'A', | |
208 | 'sort_by_date' => false | |
209 | ), $atts, 'shelter_list' ) ); | |
210 | //get the xml | |
211 | $response = wp_remote_get( "http://api.petfinder.com/shelter.getPets?key=" . trim($petf_options["apikey"]) . "&count=" . trim(intval($count)) . "&id=" . trim($shelter_id) . "&status=" . trim($status) . "&output=full", array("timeout" => 120) ); | |
212 | //echo "http://api.petfinder.com/shelter.getPets?key=" . trim($petf_options["apikey"]) . "&count=" . trim(intval($count)) . "&id=" . trim($shelter_id) . "&status=" . trim($status) . "&output=full"; | |
213 | $xml = simplexml_load_string(wp_remote_retrieve_body($response)); | |
214 | ||
215 | //print_r($xml); | |
216 | if( $xml->header->status->code == "100"){ | |
217 | $output_buffer = ""; | |
218 | if( count( $xml->pets->pet ) > 0 ){ | |
219 | $output_buffer .= "<div class=\"" . $css_class . "\">"; | |
220 | $pets = $xml->pets->pet; | |
221 | /*var_dump($pets); | |
222 | if($sort_by_date){ | |
223 | usort($pets, 'sort_by_date'); | |
224 | }*/ | |
225 | ||
226 | ||
227 | foreach( $pets as $dog ){ | |
228 | $bigfile = ""; | |
229 | ||
230 | $continue = false; | |
231 | if(($animal == "" || strtolower( $dog->animal ) == strtolower( $animal )) && ( $contact == "" || strtolower( $dog->contact->name ) == strtolower( $contact ) ) ){ | |
232 | if( $breed != "" ){ | |
233 | foreach( $dog->breeds->breed as $this_breed ){ | |
234 | if( strpos( $breed, "!" ) === false ){ | |
235 | if( strtolower($breed) == strtolower( $this_breed ) && ( $dog->mix == "no" || ( $dog->mix == "yes" && $include_mixes == "yes" ) ) ){ | |
236 | $continue = true; | |
237 | break; //looking for specific breed and it was found | |
238 | } | |
239 | }else{ | |
240 | if( strtolower( str_replace( "!", "", $breed ) ) == strtolower( $this_breed ) && $dog->mix == "no" ){ | |
241 | break; //looking for other breeds and this breed was found | |
242 | }else{ | |
243 | $continue = true; | |
244 | } | |
245 | } | |
246 | } | |
247 | }else{ | |
248 | $continue = true; | |
249 | } | |
250 | if( $continue ){ | |
251 | $output_buffer .= "<div class=\"dog " . $dog->animal . "\"><div class=\"name\"><a name=\"" . $dog->id . "\">". $dog->name . "</a></div>"; | |
252 | $output_buffer .= "<div class=\"images\">"; | |
253 | $firsttime = true; | |
254 | if(count($dog->media->photos) > 0){ | |
255 | foreach( $dog->media->photos->photo as $photo ){ | |
256 | //$output_buffer .= $photo["size"]; | |
257 | if( $photo['size'] == $petf_options["large_image"] ){ | |
258 | if( $firsttime ){ | |
259 | $output_buffer .= "<img class=\"petfinder-big-img\" id=\"img_". $dog->id . "\" src=\"" . $photo . "\" alt=\" . $dog->name . \">"; | |
260 | } | |
261 | $bigfile = $photo; | |
262 | } | |
263 | if( $photo['size'] == $petf_options["thumbnail"] ){ | |
264 | if( $firsttime ){ | |
265 | $output_buffer .= "<div class=\"petfinder-thumbnails\">"; | |
266 | $firsttime = false; | |
267 | } | |
268 | $output_buffer .= "<img class=\"petfinder-thumbmail\" onclick=\"switchbigimg('img_" . $dog->id . "', '" . $bigfile . "');return false;\" src=\"" . $photo . "\" alt=\" . $dog->name . \">"; | |
269 | } | |
270 | } | |
271 | } | |
272 | if( !$firsttime ){ | |
273 | //not first time so there are thumbnails to wrap up in a div. Closing petfinder-thumbnails | |
274 | $output_buffer .= "</div>"; | |
275 | } | |
276 | if($include_info == "yes"){ | |
277 | ||
278 | $output_buffer .= "<ul class=\"pet-options\">"; | |
279 | ||
280 | $firsttime = true; | |
281 | foreach( $dog->breeds->breed as $this_breed ){ | |
282 | if($firsttime){ | |
283 | $output_buffer .= "<li class=\"breeds\">"; | |
284 | $firsttime = false; | |
285 | }else{ | |
286 | $output_buffer .= ", "; | |
287 | } | |
288 | $output_buffer .= $this_breed; | |
289 | } | |
290 | if(!$firsttime){ | |
291 | $output_buffer .= "</li>"; | |
292 | } | |
293 | ||
294 | $icons = ""; | |
295 | foreach( $dog->options->option as $option ){ | |
296 | switch($option){ | |
297 | case "noCats": | |
298 | $icons .= "<img src=\"http://www.petfinder.com/images/search/no-cat.gif\" width=\"36\" height=\"21\" alt=\"Prefers home without cats\" title=\"Prefers home without cats\" />"; | |
299 | break; | |
300 | case "noDogs": | |
301 | $icons .= "<img src=\"http://www.petfinder.com/images/search/no-dogs.gif\" width=\"41\" height=\"21\" alt=\"Prefers home without dogs\" title=\"Prefers home without dogs\" />"; | |
302 | break; | |
303 | case "noKids": | |
304 | $icons .= "<img src=\"http://www.petfinder.com/images/search/no-kids.gif\" width=\"34\" height=\"21\" alt=\"Prefers home without small kids\" title=\"Prefers home without small kids\" />"; | |
305 | break; | |
306 | case "specialNeeds": | |
307 | $icons .= "<img src=\"http://www.petfinder.com/images/search/spec_needs.gif\" width=\"18\" height=\"20\" alt=\"Special Needs\" title=\"Special Needs\" />"; | |
308 | case "altered": | |
309 | $output_buffer .= "<li class=\"altered\">Spayed/Neutered</li>"; | |
310 | break; | |
311 | case "hasShots": | |
312 | $output_buffer .= "<li class=\"hasShots\">Up-to-date with routine shots</li>"; | |
313 | break; | |
314 | case "housebroken": | |
315 | $output_buffer .= "<li class=\"housebroken\">Housebroken</li>"; | |
316 | break; | |
317 | } | |
318 | } | |
319 | if($icons != ""){ | |
320 | $output_buffer .= "<li class=\"icon-options\">" . $icons . "</li>"; | |
321 | } | |
322 | $output_buffer .= "</ul>"; | |
323 | } | |
324 | $output_buffer .= "</div>"; //close images | |
325 | switch ($dog->size){ | |
326 | case "L": | |
327 | $size = "Large"; | |
328 | break; | |
329 | case "M": | |
330 | $size = "Medium"; | |
331 | break; | |
332 | case "S": | |
333 | $size = "Small"; | |
334 | break; | |
335 | default: | |
336 | $size = "Not known"; | |
337 | break; | |
338 | } | |
339 | $output_buffer .= "<div class=\"description\">" . $dog->description . "</div><div class=\"features\">" . $dog->age . ", " . (($dog->sex == "M") ? "Male" : "Female") . ", " . $size . "</div></div>"; | |
340 | $output_buffer .= "<div style=\"clear: both; \"></div>"; | |
341 | } | |
342 | } //animal does not match | |
343 | } | |
344 | if($petf_options['powered_by'] == "Yes"){ | |
345 | $output_buffer .= "<div class=\"powered_by\">Powered by <a href=\"http://www.petfinder.com\" target=\"_blank\">Petfinder.com</a></div>"; | |
346 | } | |
347 | $output_buffer .= "</div>"; | |
348 | }else{ | |
349 | $output_buffer .= "No pets are listed for this shelter at this time. Please check back soon."; | |
350 | } | |
351 | }else if($xml->header->status->code == "201"){ | |
352 | $output_buffer = "No results found for this shelter. Please check back soon!"; | |
353 | }else{ | |
354 | $output_buffer = "Petfinder is down for the moment. Please check back shortly."; | |
355 | } | |
356 | ||
357 | return $output_buffer; | |
358 | } | |
359 | ||
360 | ||
361 | add_shortcode('get_pet','petf_get_pet'); | |
362 | ||
363 | /** Using shortcode get_pet grab one pet from petfinder. | |
364 | * Available Options: pet_id *required*, include_info, css_class. ***/ | |
365 | function petf_get_pet( $atts ) { | |
366 | ||
367 | global $petf_options; | |
368 | ||
369 | extract( shortcode_atts( array( | |
370 | 'pet_id' => 1234, | |
371 | 'include_info' => 'yes', | |
372 | 'css_class' => 'pets' | |
373 | ), $atts, 'get_pet' ) ); | |
374 | ||
375 | $output_buffer = ""; | |
376 | if(is_numeric($pet_id) && intval($pet_id) > 0 ){ | |
377 | $response = wp_remote_get( "http://api.petfinder.com/pet.get?key=" . $petf_options["apikey"] . "&id=" . $pet_id ); | |
378 | /***** Uncomment line below to view XML from Petfinder above results on page. *****/ | |
379 | //echo "http://api.petfinder.com/pet.get?key=" . $petf_options["apikey"] . "&id=" . $pet_id; | |
380 | $xml = simplexml_load_string(wp_remote_retrieve_body($response)); | |
381 | //print_r($xml); | |
382 | if( $xml->header->status->code == "100"){ | |
383 | if( count( $xml->pet ) > 0 ){ | |
384 | $output_buffer .= "<div class=\"" . $css_class . "\">"; | |
385 | foreach( $xml->pet as $dog ){ | |
386 | $output_buffer .= "<div class=\"dog\"><div class=\"name\"><a name=\"" . $dog->id . "\">". $dog->name . "</a></div>"; | |
387 | $output_buffer .= "<div class=\"images\">"; | |
388 | $firsttime = true; | |
389 | if(count($dog->media->photos) > 0){ | |
390 | foreach( $dog->media->photos->photo as $photo ){ | |
391 | //$output_buffer .= $photo["size"]; | |
392 | if( $photo['size'] == $petf_options["large_image"] ){ | |
393 | if( $firsttime ){ | |
394 | $output_buffer .= "<img class=\"petfinder-big-img\" id=\"img_". $dog->id . "\" src=\"" . $photo . "\" alt=\" . $dog->name \">"; | |
395 | } | |
396 | $bigfile = $photo; | |
397 | } | |
398 | if( $photo['size'] == $petf_options["thumbnail"] ){ | |
399 | if( $firsttime ){ | |
400 | $output_buffer .= "<div class=\"petfinder-thumbnails\">"; | |
401 | $firsttime = false; | |
402 | } | |
403 | $output_buffer .= "<img class=\"petfinder-thumbmail\" onclick=\"switchbigimg('img_" . $dog->id . "', '" . $bigfile . "');return false;\" src=\"" . $photo . "\" alt=\" . $dog->name . \">"; | |
404 | } | |
405 | } | |
406 | } | |
407 | if( !$firsttime ){ | |
408 | //not first time so there are thumbnails to wrap up in a div. Closing petfinder-thumbnails | |
409 | $output_buffer .= "</div>"; | |
410 | } | |
411 | if($include_info == "yes"){ | |
412 | ||
413 | $output_buffer .= "<ul class=\"pet-options\">"; | |
414 | ||
415 | $firsttime = true; | |
416 | foreach( $dog->breeds->breed as $this_breed ){ | |
417 | if($firsttime){ | |
418 | $output_buffer .= "<li class=\"breeds\">"; | |
419 | $firsttime = false; | |
420 | }else{ | |
421 | $output_buffer .= ", "; | |
422 | } | |
423 | $output_buffer .= $this_breed; | |
424 | } | |
425 | if(!$firsttime){ | |
426 | $output_buffer .= "</li>"; | |
427 | } | |
428 | ||
429 | $icons = ""; | |
430 | foreach( $dog->options->option as $option ){ | |
431 | switch($option){ | |
432 | case "noCats": | |
433 | $icons .= "<img src=\"http://www.petfinder.com/images/search/no-cat.gif\" width=\"36\" height=\"21\" alt=\"Prefers home without cats\" title=\"Prefers home without cats\" />"; | |
434 | break; | |
435 | case "noDogs": | |
436 | $icons .= "<img src=\"http://www.petfinder.com/images/search/no-dogs.gif\" width=\"41\" height=\"21\" alt=\"Prefers home without dogs\" title=\"Prefers home without dogs\" />"; | |
437 | break; | |
438 | case "noKids": | |
439 | $icons .= "<img src=\"http://www.petfinder.com/images/search/no-kids.gif\" width=\"34\" height=\"21\" alt=\"Prefers home without small kids\" title=\"Prefers home without small kids\" />"; | |
440 | break; | |
441 | case "specialNeeds": | |
442 | $icons .= "<img src=\"http://www.petfinder.com/images/search/spec_needs.gif\" width=\"18\" height=\"20\" alt=\"Special Needs\" title=\"Special Needs\" />"; | |
443 | case "altered": | |
444 | - | |
444 | + | |
445 | break; | |
446 | case "hasShots": | |
447 | $output_buffer .= "<li class=\"hasShots\">Up-to-date with routine shots</li>"; | |
448 | break; | |
449 | case "housebroken": | |
450 | $output_buffer .= "<li class=\"housebroken\">Housebroken</li>"; | |
451 | break; | |
452 | - | $numpets = count($pets)-1; |
452 | + | |
453 | - | for( $inc = $numpets; $inc >= 0; $inc-- ){ |
453 | + | |
454 | if($icons != ""){ | |
455 | - | $dog = $pets[$inc]; |
455 | + | |
456 | } | |
457 | $output_buffer .= "</ul>"; | |
458 | } | |
459 | $output_buffer .= "</div>"; //close images | |
460 | switch ($dog->size){ | |
461 | case "L": | |
462 | $size = "Large"; | |
463 | break; | |
464 | case "M": | |
465 | $size = "Medium"; | |
466 | break; | |
467 | case "S": | |
468 | $size = "Small"; | |
469 | break; | |
470 | default: | |
471 | $size = "Not known"; | |
472 | break; | |
473 | } | |
474 | $output_buffer .= "<div class=\"description\">" . $dog->description . "</div><div class=\"features\">" . $dog->age . ", " . (($dog->sex == "M") ? "Male" : "Female") . ", " . $size . "</div></div>"; | |
475 | $output_buffer .= "<div style=\"clear: both; \"></div>"; | |
476 | } | |
477 | if($petf_options['powered_by'] == "Yes"){ | |
478 | $output_buffer .= "<div class=\"powered_by\">Powered by <a href=\"http://www.petfinder.com\" target=\"_blank\">Petfinder.com</a></div>"; | |
479 | } | |
480 | $output_buffer .= "</div>"; | |
481 | }else{ | |
482 | $output_buffer .= "This pet was not found on Petfinder."; | |
483 | } | |
484 | }else if($xml->header->status->code == "201"){ | |
485 | $output_buffer = "No results found for this pet. Please check back soon!"; | |
486 | }else{ | |
487 | $output_buffer = "Petfinder is down for the moment. Please check back shortly."; | |
488 | } | |
489 | }else{ | |
490 | $output_buffer .= "Invalid Pet ID supplied."; | |
491 | } | |
492 | return $output_buffer; | |
493 | } |