Make WordPress Core

Ticket #42814: 42814.patch

File 42814.patch, 1.5 KB (added by Shital Patel, 6 years ago)

if it is array then use count function, otherwise set default variable value zero

  • src/wp-includes/post-template.php

     
    281281        if ( post_password_required( $post ) )
    282282                return get_the_password_form( $post );
    283283
    284         if ( $page > count( $pages ) ) // if the requested page doesn't exist
    285                 $page = count( $pages ); // give them the highest numbered page that DOES exist
     284        if(is_array($pages) ) {
     285                $pages_count = count( $pages );
     286        } else {
     287                $pages_count = 0;
     288        }
     289       
     290        if ( $page > $pages_count ) // if the requested page doesn't exist
     291                $page = $pages_count; // give them the highest numbered page that DOES exist
    286292
    287293        $content = $pages[$page - 1];
    288294        if ( preg_match( '/<!--more(.*?)?-->/', $content, $matches ) ) {
     
    304310                $teaser = '';
    305311
    306312        $output .= $teaser;
     313       
     314        if(is_array($content)) {
     315                $content_count = count($content);
     316        } else {
     317                $content_count = 0;
     318        }
    307319
    308         if ( count( $content ) > 1 ) {
     320        if ( $content_count > 1 ) {
    309321                if ( $more ) {
    310322                        $output .= '<span id="more-' . $post->ID . '"></span>' . $content[1];
    311323                } else {
     
    9971009 */
    9981010function post_custom( $key = '' ) {
    9991011        $custom = get_post_custom();
    1000 
     1012       
     1013        if(is_array($custom[$key])) {
     1014                $custom_count = count($custom[$key]);
     1015        } else {
     1016                $custom_count = 0;
     1017        }
     1018       
    10011019        if ( !isset( $custom[$key] ) )
    10021020                return false;
    1003         elseif ( 1 == count($custom[$key]) )
     1021        elseif ( 1 == $custom_count )
    10041022                return $custom[$key][0];
    10051023        else
    10061024                return $custom[$key];