Skip to content

Commit

Permalink
Hide nav (header) for LTI pages.
Browse files Browse the repository at this point in the history
Create session cookie in candela-lti.php.
Add function to check session in function.php (Bombadil).
Call function in header.php (Bombadil) to show nav or not.
  • Loading branch information
changemachine committed Jul 15, 2015
1 parent dcd0b70 commit 901257e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
15 changes: 10 additions & 5 deletions wp-content/plugins/candela-lti/candela-lti.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
// If file is called directly, abort.
if ( ! defined( 'ABSPATH' ) ) exit;

// session_start() called in pressbooks.php
if (!isset($_SESSION['LTI_session'])) {
session_start();
$_SESSION['LTI_session'] = array();
}

// Do our necessary plugin setup and add_action routines.
CandelaLTI::init();

Expand Down Expand Up @@ -114,26 +120,26 @@ public static function lti_launch() {
} else {
$slash = '/';
}

//-REMOVE DEFUNCT(?) 'content_only' REDIRECTS?
// todo make all the hide_* parameters copy over?
// If it's a deep LTI link default to showing content_only
wp_redirect( get_bloginfo('wpurl') . $slash . $page . "?content_only" );
//- wp_redirect( get_bloginfo('wpurl') . $slash . $page . "?content_only" );
exit;
}

// allows deep links with an LTI launch urls like:
// candela/api/lti/BLOGID?page_id=10
if ( ! empty($wp->query_vars['page_id'] ) && is_numeric($wp->query_vars['page_id']) ) {
switch_to_blog((int)$wp->query_vars['blog']);
wp_redirect( get_bloginfo('wpurl') . "?p=" . $wp->query_vars['page_id'] . "&content_only" );
//- wp_redirect( get_bloginfo('wpurl') . "?p=" . $wp->query_vars['page_id'] . "&content_only" );
exit;
}

// allows deep links with an LTI custom parameter like:
// custom_page_id=10
if ( ! empty($wp->query_vars['custom_page_id'] ) && is_numeric($wp->query_vars['custom_page_id']) ) {
switch_to_blog((int)$wp->query_vars['blog']);
wp_redirect( get_bloginfo('wpurl') . "?p=" . $wp->query_vars['custom_page_id'] . "&content_only" );
//- wp_redirect( get_bloginfo('wpurl') . "?p=" . $wp->query_vars['custom_page_id'] . "&content_only" );
exit;
}

Expand Down Expand Up @@ -643,4 +649,3 @@ public static function remove_db_table() {
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,7 @@ function add_iframe_resize_message() {
);

}

function LTI_display_header() {
isset($_SESSION['LTI_session']);
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
<a href="#main-content">Skip to main content</a>
</div>

<?php if (!isset($_GET['content_only'])) { ?>
<?php if(!LTI_display_header()){ ?>
<div class="row">
<nav role="navigation">
<!-- Book Title -->
Expand Down

0 comments on commit 901257e

Please sign in to comment.