Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

let user display notice above embedded frame #37

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions includes/class-power-bi-post-types.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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) {
Expand Down
8 changes: 8 additions & 0 deletions includes/class-power-bi-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ),
Expand Down
15 changes: 13 additions & 2 deletions includes/class-power-bi-shortcodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 '<div id="powerbi-embedded-'. $id .'" class="powerbi-embed" style="height: ' . $container_height . '; width: ' . $container_width . ';" data-postid="' . $id . '"></div>';

$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 .= '<style>.powerbi-embed-notice {display:none} @media screen and (max-width:'. $options['powerbi_mobile_breakpoint'].'px) {.powerbi-embed-notice {display:block;text-align:center;}}</style>';
$html .= '<div id="powerbi-embedded-notice-'. $id .'" class="powerbi-embed-notice" style="padding:20px;">'.$notice.'</div>';
}

$html .= '<div id="powerbi-embedded-'. $id .'" class="powerbi-embed" style="height: ' . $container_height . '; width: ' . $container_width . ';" data-postid="' . $id . '"></div>';

return $html;
}

public function power_bi_resource_html( $atts, $c ) {
Expand Down
6 changes: 6 additions & 0 deletions includes/functions-power-bi-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@ function powerbi_mobile_breakpoint_render() {
?>
<input type="text" name="power_bi_settings[powerbi_mobile_breakpoint]" value="<?php echo $options['powerbi_mobile_breakpoint']; ?>">
<?php
}

function powerbi_mobile_breakpoint_notice_display_message_render() {
$options = get_power_bi_plugin_settings();
?>
<input type="text" name="power_bi_settings[powerbi_mobile_breakpoint_notice_display_message]" value="<?php echo $options['powerbi_mobile_breakpoint_notice_display_message']; ?>">
<?php
}

function power_bi_username_render() {
Expand Down