Browse Source

Merge pull request #119 from Automattic/103-intergalactic-2-bg-fix

Intergalactic 2: Update Custom Colours so background colour will be applied
Laurel 7 năm trước cách đây
mục cha
commit
fe08c5d41b
2 tập tin đã thay đổi với 31 bổ sung2 xóa
  1. 15 1
      intergalactic-2/inc/wpcom.php
  2. 16 1
      intergalactic-2/js/customizer.js

+ 15 - 1
intergalactic-2/inc/wpcom.php

@@ -65,4 +65,18 @@ function intergalactic_2_wpcom_body_classes( $classes ) {
 
 	return $classes;
 }
-add_filter( 'body_class', 'intergalactic_2_wpcom_body_classes' );
+add_filter( 'body_class', 'intergalactic_2_wpcom_body_classes' );
+
+/**
+* Make sure background colours work for users without Custom Colours.
+*
+*/
+function intergalactic_2_background_fix() {
+	$background_color = get_theme_mod( 'background_color','ffffff' );
+	$background_styles = '.entry-content-wrapper {';
+	$background_styles .= 'background-color: #' . $background_color . '; ';
+	$background_styles .= '}';
+
+	wp_add_inline_style( 'intergalactic-2-style', $background_styles );
+}
+add_action( 'wp_enqueue_scripts', 'intergalactic_2_background_fix' );

+ 16 - 1
intergalactic-2/js/customizer.js

@@ -39,4 +39,19 @@
 			}
 		} );
 	} );
-} )( jQuery );
+
+	// Background Colour
+	wp.customize( 'background_color', function( value ) {
+		value.bind( function( to ) {
+			if ( '' === to ) {
+				$( '.entry-content-wrapper' ).css( {
+					'background-color' : '#ffffff',
+				} );
+			} else {
+				$( '.entry-content-wrapper' ).css( {
+					'background-color' : to,
+				} );
+			}
+		} );
+	} );
+} )( jQuery );