Source
File: wp-includes/class-wp-hook.php
public function add_filter( $tag, $function_to_add, $priority, $accepted_args ) {
$idx = _wp_filter_build_unique_id( $tag, $function_to_add, $priority );
$priority_existed = isset( $this->callbacks[ $priority ] );
$this->callbacks[ $priority ][ $idx ] = array(
'function' => $function_to_add,
'accepted_args' => $accepted_args,
);
// If we're adding a new priority to the list, put them back in sorted order.
if ( ! $priority_existed && count( $this->callbacks ) > 1 ) {
ksort( $this->callbacks, SORT_NUMERIC );
}
if ( $this->nesting_level > 0 ) {
$this->resort_active_iterations( $priority, $priority_existed );
}
}