Is there a tirck in the get_xxxx function in the general_template.php file?

The do_action:

do_action( 'get_header', $name );

its triggering the action get_header, so all actions attached using add_action to the action 'get_header' will be executed, its also passing the $name as parameter to the functions by example:

function my_function($name){
    echo "The Action sent me the name:".$name."!!";
}

add_action('get_header', 'my_function');

when the do_action( 'get_header', $name ); is executed my_function will be called with $name as a parameter, this way you can do “something” before the header template is loaded.

instruction 2 is not overriding instruction 1 its adding the default 'header.php' to the array as a fallback, if you are calling a custom header the $templates array will be like this (using get_header('custom');):

Array
(
    [0] => header-custom.php
    [1] => header.php
)

locate_template will try to find and load with require_once the first template, if it doesnt exist or it cant find it, it will fallback to header.php and try to load that one too.

tech