Skip to content

Commit

Permalink
asset management for specific page templates
Browse files Browse the repository at this point in the history
  • Loading branch information
hasinhayder committed May 27, 2018
1 parent a16f154 commit 5728847
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 22 deletions.
58 changes: 36 additions & 22 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,42 @@ function launcher_setup_theme() {
add_action( "after_setup_theme", "launcher_setup_theme" );

function launcher_assets() {
wp_enqueue_style( "animate-css", get_theme_file_uri( "/assets/css/animate.css" ) );
wp_enqueue_style( "icomoon-css", get_theme_file_uri( "/assets/css/icomoon.css" ) );
wp_enqueue_style( "bootstrap-css", get_theme_file_uri( "/assets/css/bootstrap.css" ) );
wp_enqueue_style( "style-css", get_theme_file_uri( "/assets/css/style.css" ) );
wp_enqueue_style( "launcher", get_stylesheet_uri(), null, "0.1" );

wp_enqueue_script( "easing-jquery-js", get_theme_file_uri( "/assets/js/jquery.easing.1.3.js" ), array( "jquery" ), null, true );
wp_enqueue_script( "bootstrap-jquery-js", get_theme_file_uri( "/assets/js/bootstrap.min.js" ), array( "jquery" ), null, true );
wp_enqueue_script( "waypoint-jquery-js", get_theme_file_uri( "/assets/js/jquery.waypoints.min.js" ), array( "jquery" ), null, true );
wp_enqueue_script( "countdown-jquery-js", get_theme_file_uri( "/assets/js/simplyCountdown.js" ), array( "jquery" ), null, true );
wp_enqueue_script( "main-jquery-js", get_theme_file_uri( "/assets/js/main.js" ), array( "jquery" ), time(), true );


$launcher_year = get_post_meta( get_the_ID(), "year", true );
$launcher_month = get_post_meta( get_the_ID(), "month", true );
$launcher_day = get_post_meta( get_the_ID(), "day", true );

wp_localize_script( "main-jquery-js", "datedata", array(
"year" => $launcher_year,
"month" => $launcher_month,
"day" => $launcher_day,
) );

//echo basename(get_page_template());
//die();

if(is_page()){
$launcher_template_name = basename(get_page_template());
if($launcher_template_name == "launcher.php"){
wp_enqueue_style( "animate-css", get_theme_file_uri( "/assets/css/animate.css" ) );
wp_enqueue_style( "icomoon-css", get_theme_file_uri( "/assets/css/icomoon.css" ) );
wp_enqueue_style( "bootstrap-css", get_theme_file_uri( "/assets/css/bootstrap.css" ) );
wp_enqueue_style( "style-css", get_theme_file_uri( "/assets/css/style.css" ) );
wp_enqueue_style( "launcher", get_stylesheet_uri(), null, "0.1" );

wp_enqueue_script( "easing-jquery-js", get_theme_file_uri( "/assets/js/jquery.easing.1.3.js" ), array( "jquery" ), null, true );
wp_enqueue_script( "bootstrap-jquery-js", get_theme_file_uri( "/assets/js/bootstrap.min.js" ), array( "jquery" ), null, true );
wp_enqueue_script( "waypoint-jquery-js", get_theme_file_uri( "/assets/js/jquery.waypoints.min.js" ), array( "jquery" ), null, true );
wp_enqueue_script( "countdown-jquery-js", get_theme_file_uri( "/assets/js/simplyCountdown.js" ), array( "jquery" ), null, true );
wp_enqueue_script( "main-jquery-js", get_theme_file_uri( "/assets/js/main.js" ), array( "jquery" ), time(), true );

$launcher_year = get_post_meta( get_the_ID(), "year", true );
$launcher_month = get_post_meta( get_the_ID(), "month", true );
$launcher_day = get_post_meta( get_the_ID(), "day", true );

wp_localize_script( "main-jquery-js", "datedata", array(
"year" => $launcher_year,
"month" => $launcher_month,
"day" => $launcher_day,
) );
}else {
wp_enqueue_style( "bootstrap-css", get_theme_file_uri( "/assets/css/bootstrap.css" ) );
wp_enqueue_style( "launcher", get_stylesheet_uri(), null, "0.1" );

}
}


}

add_action( "wp_enqueue_scripts", "launcher_assets" );
Expand Down
18 changes: 18 additions & 0 deletions testtemplate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
/**
* Template Name: Test Template
*/
?>
<html>
<head>
<?php get_header(); ?>
</head>
<body <?php body_class(); ?> >

<h1>
<?php the_title(); ?>
</h1>

<?php get_footer(); ?>
</body>
</html>

0 comments on commit 5728847

Please sign in to comment.