How to number the options in a wp_dropdown_pages() select?

To change

<option value="http://someurl">item one</option>
<option value="http://someurl">item two</option>
<option value="http://someurl">item three</option>

to

<option value="http://someurl">1. item one</option>
<option value="http://someurl">2. item two</option>
<option value="http://someurl">3. item three</option>

we can utilize the list_pages filter from the Walker_PageDropdown::start_el() method.

Here’s an example:

// Add filter
add_filter( 'list_pages', 'wpse_itemize', 10, 2 );

// Display dropdown
wp_dropdown_pages();

// Remove filter
remove_filter( 'list_pages', 'wpse_itemize' );

where the callback is defined as:

function wpse_itemize( $title, $page )
{
    static $nr = 1;     
    return sprintf( '%d. %s', $nr++, $title );
}

Update

For the custom wp_dropdown_posts() function you could try:

if( function_exists( 'wp_dropdown_posts' ) )
{
    // Add filter
    add_filter( 'esc_html', 'wpse_itemize' );

    // Display dropdown
    wp_dropdown_posts();

    // Remove filter
    remove_filter( 'esc_html', 'wpse_itemize' );
}

where the callback is defined as:

function wpse_itemize( $safe_text )
{
    static $nr = 1;     
    return sprintf( '%d. %s', $nr++, $safe_text );
}

Note

I was just curious how we could add post post type support to wp_dropdown_pages() and got it through with this hack:

global $wp_post_types;
$wp_post_types['post']->hierarchical = true;
wp_dropdown_pages( [ 'post_type' => 'post' ] );
$wp_post_types['post']->hierarchical = false;

but I absolutely don’t recommend this, it was just a test to see if I could find “any” theoretical workaround.