WPDKUIComponents::enqueue PHP 메소드

enqueue() 공개 메소드

Load a single components WPDKUIComponents::init()->enqueue( WPDKUIComponents::TOOLTIP ); Load one or more components WPDKUIComponents::init()->enqueue( array( WPDKUIComponents::MODAL, WPDKUIComponents::TOOLTIP ) ); Or... like kind of magic WPDKUIComponents::init()->enqueue( WPDKUIComponents::MODAL, WPDKUIComponents::TOOLTIP );
부터: 1.5.0
public enqueue ( string | array $component_handles )
$component_handles string | array One or more Component handle
    public function enqueue($component_handles)
    {
        // Handles, one or more
        $handles = (array) $component_handles;
        // Magic
        if (func_num_args() > 1) {
            $handles = func_get_args();
        }
        foreach ($handles as $handle) {
            // Javascript part
            if (isset($this->components[$handle]['js'])) {
                // Check for dependences
                if (isset($this->components[$handle]['deps'])) {
                    // Recursive into the dependence and check if register
                    $this->enqueue($this->components[$handle]['deps']);
                }
                $this->enqueue_scripts[] = $handle;
            } else {
                wp_enqueue_script($handle);
            }
            // CSS style part
            if (isset($this->components[$handle]['css'])) {
                // Check dependences
                if (isset($this->components[$handle]['deps'])) {
                    // Recursive into the dependence and check if register
                    $this->enqueue($this->components[$handle]['deps']);
                }
                $this->enqueue_styles[] = $handle;
            } else {
                wp_enqueue_style($handle);
            }
        }
        // Makes unique
        $this->enqueue_scripts = array_unique($this->enqueue_scripts);
        $this->enqueue_styles = array_unique($this->enqueue_styles);
    }