Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialRobert Mylne
13,708 PointsWindows 8 and Surface Bootstrap Compadibility
I am going through the WordPress lesson with Zac Gordon and the lesson doesn't cover this part:
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="../../assets/js/ie10-viewport-bug-workaround.js"></script>
How do I add this to what I have done?
// Javascript
function theme_js() {
global $wp_scripts;
wp_register_script( 'html5_shiv', 'https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js', '', '', false);
wp_register_script( 'respond_js', 'https://oss.maxcdn.com/respond/1.4.2/respond.min.js', '', '', false);
wp_register_script( 'respond_js', 'https://oss.maxcdn.com/respond/1.4.2/respond.min.js', '', '', false);
$wp_scripts->add_data( 'html5_shiv', 'conditional', 'It IE 9');
$wp_scripts->add_data( 'respond_js', 'conditional', 'It IE 9');
wp_enqueue_script( 'bootstrap_js', 'https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js', array('jquery'), '', true );
}
add_action( 'wp_enqueue_scripts', 'theme_js' );
4 Answers
Andrew Shook
31,709 Points// Javascript
function theme_js() {
global $wp_scripts;
wp_register_script( 'viewport_workaround', get_template_directory_uri() . '/assets/js/ie10-viewport-bug-workaround.js', '', '', true);
wp_register_script( 'html5_shiv', 'https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js', '', '', false);
wp_register_script( 'respond_js', 'https://oss.maxcdn.com/respond/1.4.2/respond.min.js', '', '', false);
wp_register_script( 'respond_js', 'https://oss.maxcdn.com/respond/1.4.2/respond.min.js', '', '', false);
$wp_scripts->add_data( 'html5_shiv', 'conditional', 'It IE 9');
$wp_scripts->add_data( 'respond_js', 'conditional', 'It IE 9');
$wp_scripts->add_data( 'viewport_workaround', 'conditional', 'IE 10');
wp_enqueue_script( 'bootstrap_js', 'https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js', array('jquery'), '', true );
}
add_action( 'wp_enqueue_scripts', 'theme_js' );
Darren Healy
Front End Web Development Techdegree Student 23,565 PointsThanks Andrew! Saved me on this one too.
Zac Gordon it's probably useful to include the windows 8 bug in the teachers notes.
Andrew Shook
31,709 PointsDarren, did you get my code to work? I never heard back from Robert, so I was never sure if it had worked correctly.
Darren Healy
Front End Web Development Techdegree Student 23,565 PointsYup, it worked for me. Corrected the issue I was having exactly and I haven't encountered any issues so far since.
Andrew Shook
31,709 PointsThanks for letting me know!
Guy Noda-Bailey
18,837 PointsAlso, I don't know why my download is different, but my version of bootstrap didn't have the ie10-viewport-bug-workaround.js included (it doesn't even have a folder called assets) so I copied the file from bootstrap's github and put it in my js folder.