enqueue example


    public $flex_height = false;

    /** * Enqueue control related scripts/styles. * * @since 4.3.0 */
    public function enqueue() {
        wp_enqueue_script( 'customize-views' );

        parent::enqueue();
    }

    /** * Refresh the parameters passed to the JavaScript via JSON. * * @since 4.3.0 * * @see WP_Customize_Control::to_json() */
    public function to_json() {
        parent::to_json();

        

    public $palette;

    /** * Enqueue control related scripts/styles. * * @since Twenty Twenty-One 1.0 * * @return void */
    public function enqueue() {
        parent::enqueue();

        // Enqueue the script.         wp_enqueue_script(
            'twentytwentyone-control-color',
            get_theme_file_uri( 'assets/js/palette-colorpicker.js' ),
            array( 'customize-controls', 'jquery', 'customize-base', 'wp-color-picker' ),
            wp_get_theme()->get( 'Version' ),
            false
        );
    }

    
'section' => 'background_image',
            )
        );
    }

    /** * Enqueue control related scripts/styles. * * @since 4.1.0 */
    public function enqueue() {
        parent::enqueue();

        $custom_background = get_theme_support( 'custom-background' );
        wp_localize_script(
            'customize-controls',
            '_wpCustomizeBackground',
            array(
                'defaults' => ! empty( $custom_background[0] ) ? $custom_background[0] : array(),
                'nonces'   => array(
                    'add' => wp_create_nonce( 'background-add' ),
                ),
            )
        );

function wp_enqueue_style( $handle$src = '', $deps = array()$ver = false, $media = 'all' ) {
    _wp_scripts_maybe_doing_it_wrong( __FUNCTION__, $handle );

    $wp_styles = wp_styles();

    if ( $src ) {
        $_handle = explode( '?', $handle );
        $wp_styles->add( $_handle[0]$src$deps$ver$media );
    }

    $wp_styles->enqueue( $handle );
}

/** * Removes a previously enqueued CSS stylesheet. * * @see WP_Dependencies::dequeue() * * @since 3.1.0 * * @param string $handle Name of the stylesheet to be removed. */
if ( $src ) {
            $wp_scripts->add( $_handle[0]$src$deps$ver );
        }
        if ( ! empty( $args['in_footer'] ) ) {
            $wp_scripts->add_data( $_handle[0], 'group', 1 );
        }
        if ( ! empty( $args['strategy'] ) ) {
            $wp_scripts->add_data( $_handle[0], 'strategy', $args['strategy'] );
        }
    }

    $wp_scripts->enqueue( $handle );
}

/** * Removes a previously enqueued script. * * @see WP_Dependencies::dequeue() * * @since 3.1.0 * * @param string $handle Name of the script to be removed. */
'currentImgSrc' => $this->get_current_image_src(),
                ),
                'nonces'   => array(
                    'add'    => wp_create_nonce( 'header-add' ),
                    'remove' => wp_create_nonce( 'header-remove' ),
                ),
                'uploads'  => $this->uploaded_headers,
                'defaults' => $this->default_headers,
            )
        );

        parent::enqueue();
    }

    /** * @global Custom_Image_Header $custom_image_header */
    public function prepare_control() {
        global $custom_image_header;
        if ( empty( $custom_image_header ) ) {
            return;
        }

        
true
        );
    }

    /** * Enqueues scripts for customize controls. * * @since 3.4.0 */
    public function enqueue_control_scripts() {
        foreach ( $this->controls as $control ) {
            $control->enqueue();
        }

        if ( ! is_multisite() && ( current_user_can( 'install_themes' ) || current_user_can( 'update_themes' ) || current_user_can( 'delete_themes' ) ) ) {
            wp_enqueue_script( 'updates' );
            wp_localize_script(
                'updates',
                '_wpUpdatesItemCounts',
                array(
                    'totals' => wp_get_update_data(),
                )
            );
        }

    public function add( $handle$src$deps = array()$ver = false, $args = null ) {
        if ( isset( $this->registered[ $handle ] ) ) {
            return false;
        }
        $this->registered[ $handle ] = new _WP_Dependency( $handle$src$deps$ver$args );

        // If the item was enqueued before the details were registered, enqueue it now.         if ( array_key_exists( $handle$this->queued_before_register ) ) {
            if ( ! is_null( $this->queued_before_register[ $handle ] ) ) {
                $this->enqueue( $handle . '?' . $this->queued_before_register[ $handle ] );
            } else {
                $this->enqueue( $handle );
            }

            unset( $this->queued_before_register[ $handle ] );
        }

        return true;
    }

    /** * Add extra item data. * * Adds data to a registered item. * * @since 2.6.0 * * @param string $handle Name of the item. Should be unique. * @param string $key The data key. * @param mixed $value The data value. * @return bool True on success, false on failure. */
Home | Imprint | This part of the site doesn't use cookies.