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