Created
December 18, 2024 16:50
-
-
Save nathaningram/ab293e6e21b2d23335a1bd60e348eb3c to your computer and use it in GitHub Desktop.
Starter Site 2024 Course - MU Looker Dashboard iFrame
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ////////////////////////////////////////////////////////////////////////////// | |
| // Looker Dashboard Iframe Shortcode | |
| ////////////////////////////////////////////////////////////////////////////// | |
| // Function to generate the iframe HTML | |
| function bww_looker_dashboard_shortcode() { | |
| // Retrieve the fields from the Meta Box settings page | |
| $all_options = get_option('site-info'); | |
| $iframe_height = $all_options['bww_looker_iframe_height'] ?? ''; | |
| $iframe_src = $all_options['bww_site_looker'] ?? ''; | |
| // Validate the fields | |
| if (empty($iframe_height) || empty($iframe_src)) { | |
| return ''; // Return nothing if either field is empty | |
| } | |
| // Build the iframe HTML | |
| $iframe = sprintf( | |
| '<iframe width="100%%" height="%s" src="%s" frameborder="0" style="border:0" allowfullscreen></iframe>', | |
| esc_attr($iframe_height), | |
| esc_url($iframe_src) | |
| ); | |
| return $iframe; | |
| } | |
| // Register the shortcode | |
| add_shortcode('looker-dashboard', 'bww_looker_dashboard_shortcode'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment