Skip to content

Commit

Permalink
jquery local + minor refactor for performance
Browse files Browse the repository at this point in the history
  • Loading branch information
milesimarco committed Nov 8, 2022
1 parent cb0a020 commit 0dcf68c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 35 deletions.
13 changes: 3 additions & 10 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ function version_child() {
wp_enqueue_style( 'pasw2015_styles-fonts', get_template_directory_uri() . '/font/css/font-awesome.min.css', array(), null, 'all' );
wp_enqueue_style( 'pasw2015_styles', get_stylesheet_uri() , array());
wp_enqueue_style( 'pasw2015_styles-print', get_template_directory_uri() . '/print.css', array(), null, 'print' );
wp_enqueue_script( 'pasw2015-script', get_template_directory_uri() . '/js/pasw2015.js', array( 'jquery' ), '20151227', true );
} );

add_action( 'after_setup_theme', function() {
Expand Down Expand Up @@ -225,7 +226,7 @@ function pasw2015_widgets_init() {
function comment_count_special($post_id, $comment_type)
{
$the_post_comments = get_comments('post_id=' . $post_id);
$comments_by_type = &separate_comments($the_post_comments);
$comments_by_type = separate_comments($the_post_comments);
return count($comments_by_type[$comment_type]);
}

Expand All @@ -235,7 +236,7 @@ function comment_count( $count )
{
global $id;
global $nearlysprung;
if ($nearlysprung->option['splitpings'] != "yes")
if ($nearlysprung && $nearlysprung->option['splitpings'] != "yes")
{
return $count;
}
Expand Down Expand Up @@ -384,14 +385,6 @@ function pasw2015_customizer_live_preview() {
}
add_action( 'customize_preview_init', 'pasw2015_customizer_live_preview' );

function pasw2015_scripts() {

// Load the theme custom script file.
wp_enqueue_script( 'pasw2015-script', get_template_directory_uri() . '/js/pasw2015.js', array( 'jquery' ), '20151227', true );

}
add_action( 'wp_enqueue_scripts', 'pasw2015_scripts' );

function wpgov_update() {

$options = array(
Expand Down
50 changes: 26 additions & 24 deletions header.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,34 @@
<link rel="profile" href="http://gmpg.org/xfn/11">
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">

<?php if ( is_singular() ) wp_enqueue_script( 'comment-reply' ); ?>

<?php if (get_option('pasw_fixedmenu') == 1) { ?>
<script src="<?php echo get_template_directory_uri() . '/js/jquery.min.js';?>"></script>
<script>
jQuery("document").ready(function($){
var nav = $('#topbar');
var width = (window.innerWidth > 0) ? window.innerWidth : screen.width;
$(window).scroll(function () {
if ($(this).scrollTop() > <?php echo get_custom_header()->height + 30; ?> && width >= 1024) {
nav.addClass("f-nav");
} else {
nav.removeClass("f-nav");
}
});

});
</script>
<?php
if ( is_user_logged_in() ) {
echo '<style>.f-nav { top:30px; }</style>';
}
}
<?php
wp_head();
include(TEMPLATEPATH . '/include/frontend/google-analytics.php');
?>
if ( is_singular() ) {
wp_enqueue_script( 'comment-reply' );
}
if (get_option('pasw_fixedmenu') == 1) {
?>
<script>
jQuery(document).ready(function($){
var nav = $('#topbar');
var width = (window.innerWidth > 0) ? window.innerWidth : screen.width;
$(window).scroll(function () {
if ($(this).scrollTop() > <?php echo get_custom_header()->height + 30; ?> && width >= 1024) {
nav.addClass("f-nav");
} else {
nav.removeClass("f-nav");
}
});

});
</script>
<?php
if ( is_user_logged_in() ) {
echo '<style>.f-nav { top:30px; }</style>';
}
}
?>

</head>

Expand Down
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
get_header();
echo 'error';
echo 'Please set your homepage';
get_footer();
?>

0 comments on commit 0dcf68c

Please sign in to comment.