Make WordPress Core

Ticket #23816: 23816.diff

File 23816.diff, 1.5 KB (added by rmccue, 10 years ago)

Fire an action if dependencies fail

  • wp-includes/class.wp-dependencies.php

    diff --git a/wp-includes/class.wp-dependencies.php b/wp-includes/class.wp-dependencies.php
    index c1bac65..67a1c48 100644
    a b class WP_Dependencies { 
    174174                                continue;
    175175
    176176                        $keep_going = true;
    177                         if ( !isset($this->registered[$handle]) )
     177                        if ( !isset($this->registered[$handle]) ) {
    178178                                $keep_going = false; // Item doesn't exist.
    179                         elseif ( $this->registered[$handle]->deps && array_diff($this->registered[$handle]->deps, array_keys($this->registered)) )
     179                        }
     180                        elseif ( $this->registered[$handle]->deps && $missing = array_diff($this->registered[$handle]->deps, array_keys($this->registered)) ) {
    180181                                $keep_going = false; // Item requires dependencies that don't exist.
    181                         elseif ( $this->registered[$handle]->deps && !$this->all_deps( $this->registered[$handle]->deps, true, $group ) )
     182
     183                                /**
     184                                 * Allow reporting of missing dependencies
     185                                 *
     186                                 * @param string $handle Script/style handle
     187                                 * @param array $missing List of missing dependencies
     188                                 */
     189                                do_action( 'wp_dependencies_missing_dependency', $handle, $missing, $this->registered[$handle] );
     190                        }
     191                        elseif ( $this->registered[$handle]->deps && !$this->all_deps( $this->registered[$handle]->deps, true, $group ) ) {
    182192                                $keep_going = false; // Item requires dependencies that don't exist.
     193                        }
    183194
    184195                        if ( ! $keep_going ) { // Either item or its dependencies don't exist.
    185196                                if ( $recursion )