# uicore-elements/1.0.6/includes/class-assets.php

UiCore Elements – Free widgets and templates for Elementor, version 1.0.6. 169 lines.

- Page: https://pluginprobe.com/plugins/uicore-elements/1.0.6/code/includes/class-assets.php
- Raw: https://pluginprobe.com/plugins/uicore-elements/1.0.6/raw/includes/class-assets.php
- Modified: 2024-07-01T13:36:36+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/uicore-elements/1.0.6/code/includes/class-assets.php#L10-L20`.

```php
<?php
namespace UiCoreElements;
use Elementor\Plugin;

/**
 * Scripts and Styles Class
 */
class Assets {

    function __construct() {
        if ( is_admin() ) {
            add_action( 'admin_enqueue_scripts', [ $this, 'register' ], 5 );
            add_action( 'elementor/editor/after_enqueue_scripts', function() {
                $this->register(true);
            }, 1 );
        } else {
            add_action( 'wp_enqueue_scripts', [ $this, 'register' ], 5 );
        }
    }

    /**
     * Register our app scripts and styles
     *
     * @param bool $editor If the scripts are meant for the Elementor editor's. Defaults to false.
     *
     * @return void
     */
    public function register(bool $editor = false) {
        $this->register_scripts( $this->get_scripts() );
        $this->register_styles( $this->get_styles() );

        // Elementor editor specific scripts
        if($editor){
            wp_enqueue_script('ui-nested-content', UICORE_ELEMENTS_ASSETS . '/js/utils/nested-content.js', [], UICORE_ELEMENTS_VERSION, true);
        }
    }

    /**
     * Register scripts
     *
     * @param  array $scripts
     *
     * @return void
     */
    private function register_scripts( $scripts ) {
        foreach ( $scripts as $handle => $script ) {
            $deps      = isset( $script['deps'] ) ? $script['deps'] : false;
            $in_footer = isset( $script['in_footer'] ) ? $script['in_footer'] : false;
            $version   = isset( $script['version'] ) ? $script['version'] : UICORE_ELEMENTS_VERSION;

            wp_register_script( $handle, $script['src'], $deps, $version, $in_footer );
        }
    }

    /**
     * Register styles
     *
     * @param  array $styles
     *
     * @return void
     */
    public function register_styles( $styles ) {
        foreach ( $styles as $handle => $style ) {
            $deps = isset( $style['deps'] ) ? $style['deps'] : false;

            wp_register_style( $handle, $style['src'], $deps, UICORE_ELEMENTS_VERSION );
        }
    }

    /**
     * Get all registered scripts
     *
     * @return array
     */
    public function get_scripts() {
        $prefix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';

        $scripts = [
            // libs
            'ui-e-countup' => [
                'src'       => UICORE_ELEMENTS_ASSETS . '/js/lib/countUp.umd.js',
                'version'   => UICORE_ELEMENTS_VERSION,
                'in_footer' => true
            ],
            'ui-e-odometer' => [
                'src'       => UICORE_ELEMENTS_ASSETS . '/js/lib/odometer.js',
                'version'   => UICORE_ELEMENTS_VERSION,
                'in_footer' => true
            ],
            // utils
            'ui-e-entrance' => [
                'src'       => UICORE_ELEMENTS_ASSETS . '/js/utils/global-entrances.js',
                'version'   => UICORE_ELEMENTS_VERSION,
                'in_footer' => true
            ],
            'ui-e-ajax-request' => [
                'src'       => UICORE_ELEMENTS_ASSETS . '/js/utils/ajax-request.js',
                'version'   => UICORE_ELEMENTS_VERSION,
                'in_footer' => true
            ],
            'ui-e-recaptcha' => [
                'src'       => 'https://www.google.com/recaptcha/api.js?render=explicit',
                'version'   => UICORE_ELEMENTS_VERSION,
                'in_footer' => false
            ],
            'ui-e-recaptcha-v3' => [
                'src'       => 'https://www.google.com/recaptcha/api.js?render=' . get_option('uicore_elements_recaptcha_site_key'),
                'version'   => UICORE_ELEMENTS_VERSION,
                'in_footer' => false
            ],
            'ui-e-repeater-custom-key' => [
                'src'       => UICORE_ELEMENTS_ASSETS . '/js/utils/repeater-custom-key.js',
                'version'   => UICORE_ELEMENTS_VERSION,
                'in_footer' => true
            ],
            /*
            'ui-e-nested-elements' => [
                //'src'       => \ELEMENTOR_ASSETS_URL . '/js/nested-elements.js',
                'src'       => UICORE_ELEMENTS_ASSETS . '/js/utils/nested-elements.js',
                'version'   => UICORE_ELEMENTS_VERSION,
                //'deps'      => ['elementor-common-modules'],
                'in_footer' => true
            ],
            */
            // components
            'ui-e-counter' => [
                'src'       => UICORE_ELEMENTS_ASSETS . '/js/utils/global-counter.js',
                'version'   => UICORE_ELEMENTS_VERSION,
                'deps'      => ['ui-e-countup'],
                'in_footer' => true
            ],
            'ui-e-carousel' => [
                'src'       => UICORE_ELEMENTS_ASSETS . '/js/utils/global-carousel.js',
                'version'   => UICORE_ELEMENTS_VERSION,
                'deps'      => ['elementor-frontend'],
                'in_footer' => true
            ],
        ];

        return $scripts;
    }

    /**
     * Get registered styles
     *
     * @return array
     */
    public function get_styles() {

        $styles = [
            'ui-e-animation' => [
                'src' =>  UICORE_ELEMENTS_ASSETS . '/css/utils/global-animations.css'
            ],
            'ui-e-entrance' => [
                'src' =>  UICORE_ELEMENTS_ASSETS . '/css/utils/global-entrances.css'
            ],
            // 'uicore_animate-settings' => [
            //     'src' =>  UICORE_ELEMENTS_ASSETS . '/css/settings.css'
            // ],
            // 'uicore_animate-admin' => [
            //     'src' =>  UICORE_ELEMENTS_ASSETS . '/css/admin.css'
            // ],
        ];

        return $styles;
    }

}

```
