WordPress.org

Make WordPress Core

Ticket #10977: wp_list_pages-no_leading_exclude_comma.patch

File wp_list_pages-no_leading_exclude_comma.patch, 774 bytes (added by kevinB, 6 years ago)

wp_list_pages(): prevent leading comma in exclude argument

  • post-template.php

     
    757757        // sanitize, mostly to keep spaces out 
    758758        $r['exclude'] = preg_replace('/[^0-9,]/', '', $r['exclude']); 
    759759 
    760         // Allow plugins to filter an array of excluded pages 
    761         $r['exclude'] = implode(',', apply_filters('wp_list_pages_excludes', explode(',', $r['exclude']))); 
     760        // Allow plugins to filter an array of excluded pages (but don't put a nullstring into the array) 
     761        $exclude_array = ( $r['exclude'] ) ? explode(',', $r['exclude']) : array(); 
     762        $r['exclude'] = implode( ',', apply_filters('wp_list_pages_excludes', $exclude_array) ); 
    762763 
    763764        // Query pages. 
    764765        $r['hierarchical'] = 0;