note.php
43 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Custom Facebook Feed Item : Note Post Type |
| 5 | * Displays the feed note post type! |
| 6 | * |
| 7 | * @version 2.19 Custom Facebook Feed by Smash Balloon |
| 8 | */ |
| 9 | |
| 10 | // Don't load directly |
| 11 | if (! defined('ABSPATH')) { |
| 12 | die('-1'); |
| 13 | } |
| 14 | |
| 15 | $transient_name = 'cff_tle_' . $cff_post_id; |
| 16 | $transient_name = substr($transient_name, 0, 45); |
| 17 | if (false !== ( $cff_note_json = get_transient($transient_name) )) { |
| 18 | $cff_note_json = get_transient($transient_name); |
| 19 | |
| 20 | // Interpret data with JSON |
| 21 | $cff_note_obj = json_decode($cff_note_json); |
| 22 | $cff_note_object = $cff_note_obj->attachments->data[0]; |
| 23 | |
| 24 | $cff_note_title = isset($cff_note_object->title) ? htmlentities($cff_note_object->title, ENT_QUOTES, 'UTF-8') : ''; |
| 25 | $cff_note_description = isset($cff_note_object->description) ? htmlentities($cff_note_object->description, ENT_QUOTES, 'UTF-8') : ''; |
| 26 | $cff_note_link = isset($cff_note_object->url) ? $cff_note_object->url : ''; |
| 27 | $cff_note_media_src = isset($cff_note_object->media->image->src) ? $cff_note_object->media->image->src : false; |
| 28 | } else { |
| 29 | $attachment_data = ''; |
| 30 | if (isset($news->attachments->data[0])) { |
| 31 | $attachment_data = $news->attachments->data[0]; |
| 32 | $cff_note_title = isset($attachment_data->title) ? htmlentities($attachment_data->title, ENT_QUOTES, 'UTF-8') : ''; |
| 33 | $cff_note_description = isset($attachment_data->description) ? htmlentities($attachment_data->description, ENT_QUOTES, 'UTF-8') : ''; |
| 34 | $cff_note_link = isset($attachment_data->unshimmed_url) ? $attachment_data->unshimmed_url : ''; |
| 35 | $cff_note_media_src = ''; |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | ?> |
| 40 | <span class="cff-details"> |
| 41 | <span class="cff-note-title"><?php echo $cff_note_title ?></span> |
| 42 | <?php echo $cff_note_description ?> |
| 43 | </span> |