locator-summary.php
95 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Custom Feeds for Facebook Feed Locator Summary Template |
| 5 | * Creates the HTML for the feed locator summary |
| 6 | * |
| 7 | * @version 2.19 Custom Feeds for Facebook Pro by Smash Balloon |
| 8 | */ |
| 9 | |
| 10 | use CustomFacebookFeed\CFF_FB_Settings; |
| 11 | |
| 12 | if (! defined('ABSPATH')) { |
| 13 | exit; // Exit if accessed directly |
| 14 | } |
| 15 | $database_settings = get_option('cff_style_settings'); |
| 16 | $connected_accounts = (array)json_decode(stripcslashes(get_option('cff_connected_accounts'))); |
| 17 | |
| 18 | ?> |
| 19 | <div class="cff-feed-locator-summary-wrap"> |
| 20 | <h3><?php esc_html_e('Feed Finder Summary', 'custom-facebook-feed'); ?></h3> |
| 21 | <p><?php esc_html_e('The table below shows a record of all feeds found on your site. A feed may not show up here immediately after being created.', 'custom-facebook-feed'); ?></p> |
| 22 | <?php |
| 23 | if (! empty($locator_summary)) : ?> |
| 24 | <?php foreach ($locator_summary as $locator_section) : |
| 25 | if (! empty($locator_section['results'])) : ?> |
| 26 | <div class="cff-single-location"> |
| 27 | <h4><?php echo esc_html($locator_section['label']); ?></h4> |
| 28 | <table class="widefat striped"> |
| 29 | <thead> |
| 30 | <tr> |
| 31 | <th><?php esc_html_e('Type', 'custom-facebook-feed'); ?></th> |
| 32 | <th><?php esc_html_e('Sources', 'custom-facebook-feed'); ?></th> |
| 33 | <th><?php esc_html_e('Shortcode', 'custom-facebook-feed'); ?></th> |
| 34 | <th><?php esc_html_e('Location', 'custom-facebook-feed'); ?></th> |
| 35 | </tr> |
| 36 | </thead> |
| 37 | <tbody> |
| 38 | |
| 39 | <?php |
| 40 | $atts_for_page = array(); |
| 41 | foreach ($locator_section['results'] as $result) : |
| 42 | $should_add = true; |
| 43 | if (! empty($atts_for_page[ $result['post_id'] ])) { |
| 44 | foreach ($atts_for_page[ $result['post_id'] ] as $existing_atts) { |
| 45 | if ($existing_atts === $result['shortcode_atts']) { |
| 46 | $should_add = false; |
| 47 | } |
| 48 | } |
| 49 | } |
| 50 | if ($should_add) { |
| 51 | $atts_for_page[ $result['post_id'] ][] = $result['shortcode_atts']; |
| 52 | $shortcode_atts = $result['shortcode_atts'] != '[""]' ? json_decode($result['shortcode_atts'], true) : []; |
| 53 | $shortcode_atts = is_array($shortcode_atts) ? $shortcode_atts : array(); |
| 54 | $display_terms = CFF_FB_Settings::feed_type_and_terms_display($connected_accounts, $result, $database_settings); |
| 55 | $comma_separated = implode(',', $display_terms['name']); |
| 56 | |
| 57 | $display = $comma_separated; |
| 58 | if (strlen($comma_separated) > 31) { |
| 59 | $display = '<span class="cff-condensed-wrap">' . esc_html(substr($comma_separated, 0, 30)) . '<a class="cff-locator-more" href="JavaScript:void(0);">...</a></span>'; |
| 60 | $comma_separated = '<span class="cff-full-wrap">' . esc_html($comma_separated) . '</span>'; |
| 61 | } else { |
| 62 | $comma_separated = ''; |
| 63 | } |
| 64 | $type = implode(',', $display_terms['type']); |
| 65 | |
| 66 | $full_shortcode_string = '[custom-facebook-feed'; |
| 67 | foreach ($shortcode_atts as $key => $value) { |
| 68 | $full_shortcode_string .= ' ' . esc_html($key) . '="' . esc_html($value) . '"'; |
| 69 | } |
| 70 | $full_shortcode_string .= ']'; |
| 71 | ?> |
| 72 | <tr> |
| 73 | <td><?php echo esc_html($type); ?></td> |
| 74 | <td><?php echo $display . $comma_separated; ?></td> |
| 75 | <td> |
| 76 | <span class="cff-condensed-wrap"><a class="cff-locator-more" href="JavaScript:void(0);"><?php esc_html_e('Show', 'custom-facebook-feed'); ?></a></span> |
| 77 | <span class="cff-full-wrap"><?php echo $full_shortcode_string; ?></span> |
| 78 | </td> |
| 79 | <td><a href="<?php echo esc_url(get_the_permalink($result['post_id'])); ?>" target="_blank" rel="noopener"><?php echo esc_html(get_the_title($result['post_id'])); ?></a></td> |
| 80 | </tr> |
| 81 | <?php |
| 82 | } |
| 83 | endforeach; ?> |
| 84 | |
| 85 | |
| 86 | </tbody> |
| 87 | </table> |
| 88 | </div> |
| 89 | |
| 90 | <?php endif; |
| 91 | endforeach; |
| 92 | else : ?> |
| 93 | <p><?php esc_html_e('Locations of your feeds are currently being detected. You\'ll see more information posted here soon!', 'custom-facebook-feed'); ?></p> |
| 94 | <?php endif; ?> |
| 95 | </div> |