cliffordp
12/1/2016 - 11:39 PM

The Events Calendar: a more-print-friendly (not perfect if a lot of events in a single month) version of Month View for Twenty Sixteen theme

The Events Calendar: a more-print-friendly (not perfect if a lot of events in a single month) version of Month View for Twenty Sixteen theme

<?php

/**
  * The Events Calendar: a more-print-friendly (not perfect if a lot of events in a single month) version of Month View for Twenty Sixteen theme
  *
  * From https://gist.github.com/cliffordp/edec7dff1e2d92333682759d0b8de7de
  *
  * Screenshots:
  *   Portrait -- before: https://cl.ly/2n283O373C13 and after: https://cl.ly/1W2U1t342u2x
  *   Landscape -- before: https://cl.ly/3u1C3V2a3v2s and after: https://cl.ly/473z0S2k3J1V
  *
  * @link https://wordpress.org/themes/twentysixteen/
  * @link https://www.tutorialspoint.com/css/css_paged_media.htm
  */
function cliff_print_friendly_month_view_2016_theme() {
	if ( ! is_post_type_archive( 'tribe_events' ) || ! function_exists( 'tribe_is_month' ) ) {
		return;
	}
	
	if ( ! tribe_is_month() ) {
		return;
	}
	
	echo PHP_EOL .
'<style type="text/css">
	@media print {
		/* if @page is uncommented, below, Headers and Footers in Chrome (e.g. date, page title, URL, page 1 of 1) should not print */
		/*
		@page {
			margin: 0.25in;
		}
		*/
				
		#site-header-menu,
		nav,
		#tribe-events-bar,
		#tribe_events_filters_wrapper,
		#tribe-events-footer,
		.tribe-events-button,
		footer {
			display: none !important;
		}
		
		header .site-branding,
		header.site-header,
		body.post-type-archive-tribe_events h2.tribe-events-page-title {
			margin: 0 auto;
			padding: 0;
			text-align: center;
		}
		
		body.post-type-archive-tribe_events #tribe-events-content .tribe-events-calendar td {
			height: 70px;
		}
		
		body.post-type-archive-tribe_events #tribe-events-content {
			margin: 0;
		}
	}
</style>' . PHP_EOL;
	return;
}
add_action( 'wp_head', 'cliff_print_friendly_month_view_2016_theme' );