From e12808e45a9aa7bbda972eecef0a71a50bdb705b Mon Sep 17 00:00:00 2001 From: migbh <116078922+migbh@users.noreply.github.com> Date: Fri, 17 Feb 2023 15:58:58 +0100 Subject: [PATCH] let user display notice above embedded frame --- includes/class-power-bi-post-types.php | 17 +++++++++++++++++ includes/class-power-bi-settings.php | 8 ++++++++ includes/class-power-bi-shortcodes.php | 15 +++++++++++++-- includes/functions-power-bi-settings.php | 6 ++++++ 4 files changed, 44 insertions(+), 2 deletions(-) diff --git a/includes/class-power-bi-post-types.php b/includes/class-power-bi-post-types.php index b8534e1..2d8bb1c 100644 --- a/includes/class-power-bi-post-types.php +++ b/includes/class-power-bi-post-types.php @@ -126,6 +126,8 @@ public function power_bi_metaboxes() { // Start with an underscore to hide fields from custom fields list. $prefix = '_power_bi_'; $languages = $this->get_languages(); + $options = get_power_bi_plugin_settings(); + /** * Sample metabox to demonstrate the different conditions you can set. */ @@ -350,6 +352,21 @@ public function power_bi_metaboxes() { 'default' => '500px', 'type' => 'text', ) ); + + $metabox_settings->add_field( array( + 'name' => 'Display breakpoint notice above the embedded frame (on mobile)', + 'id' => $prefix . 'display_breakpoint_notice', + 'default' => '0', + 'type' => 'checkbox', + ) ); + + $metabox_settings->add_field( array( + 'name' => 'Breakpoint notice message', + 'desc' => 'Override global message informing the user that the embedded frame is best viewed on a large screen', + 'id' => $prefix . 'display_breakpoint_notice_message', + 'default' => $options['powerbi_mobile_breakpoint_notice_display_message'], + 'type' => 'text', + ) ); } public function set_custom_edit_powerbi_columns($columns) { diff --git a/includes/class-power-bi-settings.php b/includes/class-power-bi-settings.php index 92bff04..d4d2eba 100644 --- a/includes/class-power-bi-settings.php +++ b/includes/class-power-bi-settings.php @@ -68,6 +68,14 @@ public function settings_init( ) { 'power_bi_display_section' ); + add_settings_field( + 'powerbi_mobile_breakpoint_notice_display_message', + __( 'Enter message informing the user that the embedded frame is best viewed on a large screen (optional)', 'power-bi' ), + 'powerbi_mobile_breakpoint_notice_display_message_render', + 'power_bi', + 'power_bi_display_section' + ); + add_settings_section( 'power_bi_section', __( 'Azure Authorization', 'power-bi' ), diff --git a/includes/class-power-bi-shortcodes.php b/includes/class-power-bi-shortcodes.php index 813706c..ccdb9bf 100644 --- a/includes/class-power-bi-shortcodes.php +++ b/includes/class-power-bi-shortcodes.php @@ -48,11 +48,22 @@ public function power_bi_html( $atts ) { if ( empty( $id ) ) { return; } + $options = get_power_bi_plugin_settings(); $container_width = empty( $width ) ? get_post_meta( $id, '_power_bi_width', true ) : $width; $container_height = empty( $height ) ? get_post_meta( $id, '_power_bi_height', true ) : $height; - - return '
'; + + $html = ''; + if ( get_post_meta( $id, '_power_bi_display_breakpoint_notice', true ) ) { + $notice = get_post_meta( $id, '_power_bi_display_breakpoint_notice_message', true ); + $notice = (!empty( $notice )) ? $notice : $options['powerbi_mobile_breakpoint_notice_display_message']; + $html .= ''; + $html .= ''; + } + + $html .= ''; + + return $html; } public function power_bi_resource_html( $atts, $c ) { diff --git a/includes/functions-power-bi-settings.php b/includes/functions-power-bi-settings.php index cb931fd..aa0a389 100644 --- a/includes/functions-power-bi-settings.php +++ b/includes/functions-power-bi-settings.php @@ -22,7 +22,13 @@ function powerbi_mobile_breakpoint_render() { ?> + +