Index: src/wp-includes/general-template.php
===================================================================
--- src/wp-includes/general-template.php	(revision 36405)
+++ src/wp-includes/general-template.php	(working copy)
@@ -1812,9 +1812,25 @@
 		$cache = array();
 	}
 
-	// Quick check. If we have no posts at all, abort!
+    /**
+     * Filter the `get_calander` function's post type.
+     *
+     * @since 4.4
+     * @param string $post_type . The default is 'post'.
+     */
+    $post_type = apply_filters('get_calendar_post_type', 'post');
+
+    if ( ! post_type_exists( $post_type ) ) {
+
+        // set the post type back to 'post' if the filter value is not a valid post type
+        $post_type = 'post';
+
+    }
+
+    // Quick check. If we have no posts at all, abort!
 	if ( ! $posts ) {
-		$gotsome = $wpdb->get_var("SELECT 1 as test FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' LIMIT 1");
+        $prepared_query = $wpdb->prepare( "SELECT 1 as test FROM $wpdb->posts WHERE post_type = %s AND post_status = 'publish' LIMIT 1", $post_type );
+		$gotsome = $wpdb->get_var( $prepared_query );
 		if ( ! $gotsome ) {
 			$cache[ $key ] = '';
 			wp_cache_set( 'get_calendar', $cache, 'calendar' );
@@ -1855,18 +1871,21 @@
 	$last_day = date( 't', $unixmonth );
 
 	// Get the next and previous month and year with at least one post
-	$previous = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year
+	$previous_prepared_query = $wpdb->prepare( "SELECT MONTH(post_date) AS month, YEAR(post_date) AS year
 		FROM $wpdb->posts
 		WHERE post_date < '$thisyear-$thismonth-01'
-		AND post_type = 'post' AND post_status = 'publish'
+		AND post_type = %s AND post_status = 'publish'
 			ORDER BY post_date DESC
-			LIMIT 1");
-	$next = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year
+			LIMIT 1" , $post_type);
+    $previous = $wpdb->get_row( $previous_prepared_query );
+
+    $next_prepared_query = $wpdb->prepare("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year
 		FROM $wpdb->posts
 		WHERE post_date > '$thisyear-$thismonth-{$last_day} 23:59:59'
-		AND post_type = 'post' AND post_status = 'publish'
+		AND post_type = %s AND post_status = 'publish'
 			ORDER BY post_date ASC
-			LIMIT 1");
+			LIMIT 1", $post_type );
+	$next = $wpdb->get_row( $next_prepared_query );
 
 	/* translators: Calendar caption: 1: month name, 2: 4-digit year */
 	$calendar_caption = _x('%1$s %2$s', 'calendar caption');
@@ -1926,10 +1945,12 @@
 	$daywithpost = array();
 
 	// Get days with posts
-	$dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date)
+    $dayswithposts_prepared_query = $wpdb->prepare( "SELECT DISTINCT DAYOFMONTH(post_date)
 		FROM $wpdb->posts WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00'
-		AND post_type = 'post' AND post_status = 'publish'
-		AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59'", ARRAY_N);
+		AND post_type = %s AND post_status = 'publish'
+		AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59'", $post_type);
+	$dayswithposts = $wpdb->get_results( $dayswithposts_prepared_query , ARRAY_N);
+
 	if ( $dayswithposts ) {
 		foreach ( (array) $dayswithposts as $daywith ) {
 			$daywithpost[] = $daywith[0];
