• Hello,

    Hope you have a great day.
    May I ask the reason to have “} elseif ( !is_page() ) {” in line 142 in functions.php file in non-premium theme carton?

    please see code below

    function bavotasan_add_js() {
    	$bavotasan_theme_options = bavotasan_theme_options();
    	$var = array();
    
    	if ( is_singular() ) {
    		if ( get_option( 'thread_comments' ) )
    			wp_enqueue_script( 'comment-reply' );
    	} elseif (  !is_page()  ) { //This section here
    		//$var['loader'] = BAVOTASAN_THEME_URL . '/library/images/ajax-loader.gif';
    		//$var['more_text'] = '<em>' . __( 'No more posts.', 'carton' ) . '</em>';
    
    		//wp_enqueue_script( 'masonry', BAVOTASAN_THEME_URL .'/library/js/masonry.js', '', '3.1.1', true );
    	}

    Thanks very much.

    -AL

Viewing 1 replies (of 1 total)
  • I don’t think it serves a purpose at all, because the elseif block of code will never be executed.

    The reason is that is_singular returns TRUE if any of the following returns TRUE: is_single(), is_page()or is_attachment(). Therefore, the code will enter the if block even if !is_page() (in other words, the flow of control will enter the if block even if the elseif test case returns TRUE). Since it enters the if block, the flow of execution will then bypass the elseif test.

    My guess is that whoever wrote the function meant to write the if test as if ( is_single () ) { } and not as if ( is_singular() ) { }

Viewing 1 replies (of 1 total)
  • The topic ‘why we have " } elseif ( !is_page() ) {" line 142, functions.php’ is closed to new replies.