Skip to content
Merged
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
10 changes: 10 additions & 0 deletions web/app/themes/mitlib-parent/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@
*/
require_once( 'lib/news.php' );

/**
* Define custom query params. Right now this is just the `v` parameter used by
* the map template.
*/
function register_params() {
global $wp;
$wp->add_query_var( 'v' );
}
add_action( 'init', 'Mitlib\Parent\register_params' );

/**
* Sets up theme defaults and registers the various WordPress features that it
* supports. This was function was borrowed from Twenty Twelve.
Expand Down
2 changes: 1 addition & 1 deletion web/app/themes/mitlib-parent/inc/content-location-2021.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Mitlib\Parent;

global $gStudy24Url;
$gStudy24Url = '/study/24x7/';

$mapPage = '/locations/#!';

Expand Down
2 changes: 1 addition & 1 deletion web/app/themes/mitlib-parent/inc/content-location.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Mitlib\Parent;

global $gStudy24Url;
$gStudy24Url = '/study/24x7/';

$mapPage = '/locations/#!';

Expand Down
36 changes: 24 additions & 12 deletions web/app/themes/mitlib-parent/templates/page-map-locations.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,17 @@

namespace Mitlib\Parent;

// phpcs:disable WordPress.Security.ValidatedSanitizedInput.InputNotValidated -- need to properly receive 'v' parameter.
$showMap = ( $_GET['v'] != '' ) && ( $_GET['v'] == 'map' ) ? 1 : 0;
// phpcs:enable
$v = get_query_var( 'v' );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a fantastic example of how clear multiline conditionals are so much clearer than the single line equivalent.

$show_map = 0;
if ( 'map' == $v ) {
$show_map = 1;
}

$gStudy24Url = '/study/24x7/';

get_header(); ?>
<script>
var showMap = <?php echo esc_js( $showMap ); ?>;
var showMap = <?php echo esc_js( $show_map ); ?>;
</script>

<?php get_template_part( 'inc/breadcrumbs' ); ?>
Expand Down Expand Up @@ -55,13 +59,15 @@

$mapImage = get_field( 'map_image' );

$val = '';
for ( $i = 1;$i <= $numMain;$i++ ) {
$img = get_field( 'main_image' . $i, $locationId );
if ( $img != '' ) {
$arMain[] = $img; }
}
$val = $arMain[ array_rand( $arMain ) ];
// $val = $arMain[0];
if ( 0 < count( $arMain ) ) {
$val = $arMain[ array_rand( $arMain ) ];
}
if ( $mapImage != '' ) {
// user override image.
$val = $mapImage;
Expand All @@ -76,8 +82,10 @@
$name = html_entity_decode( get_the_title() );

$displayPage = get_field( 'display_page' );
$pageID = $displayPage->ID;
$pageLink = get_permalink( $pageID );
$pageLink = get_permalink( $post );
if ( 'object' == gettype( $displayPage ) ) {
$pageLink = get_permalink( $displayPage->ID );
}
$directionsUrl = 'http://maps.google.com/maps?';
$directionsUrl .= 'daddr=' . $lat . ',' . $lng;
if ( $lat != '' && $lng != '' ) :
Expand Down Expand Up @@ -144,8 +152,10 @@
$study24 = get_field( 'study_24' );

$displayPage = get_field( 'display_page' );
$pageID = $displayPage->ID;
$pageLink = get_permalink( $pageID );
$pageLink = get_permalink( $post );
if ( 'object' == gettype( $displayPage ) ) {
$pageLink = get_permalink( $displayPage->ID );
}

$temp = $post;
$post = $temp;
Expand Down Expand Up @@ -203,8 +213,10 @@
$post = $temp;

$displayPage = get_field( 'display_page' );
$pageID = $displayPage->ID;
$pageLink = get_permalink( $pageID );
$pageLink = get_permalink( $post );
if ( 'object' == gettype( $displayPage ) ) {
$pageLink = get_permalink( $displayPage->ID );
}
?>
<li class="location-secondary">
<?php if ( 'stata' === $slug || 'building-9' === $slug ) : ?>
Expand Down
2 changes: 2 additions & 0 deletions web/app/themes/mitlib-parent/templates/page-study-spaces.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

namespace Mitlib\Parent;

$gStudy24Url = '/study/24x7/';

get_header(); ?>

<?php get_template_part( 'inc/breadcrumbs' ); ?>
Expand Down