$34 GRAYBYTE WORDPRESS FILE MANAGER $17

SERVER : premium201.web-hosting.com #1 SMP Wed Mar 26 12:08:09 UTC 2025
SERVER IP : 104.21.43.35 | ADMIN IP 216.73.216.180
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : mail

/home/bravrvjk/itiministry.org/wp-content/plugins/give/src/Framework/

HOME
Current File : /home/bravrvjk/itiministry.org/wp-content/plugins/give/src/Framework//EnqueueScript.php
<?php

namespace Give\Framework;

use function wp_set_script_translations;

/**
 * This class use to register script.
 * This class internally uses asset information to set script dependencies and version generated by @wordpress/dependency-extraction-webpack-plugin package.
 * It also handles script translation registration.
 *
 * @since 2.19.6
 */
class EnqueueScript
{
    /**
     * @var string
     */
    private $scriptId;

    /**
     * @var string
     */
    private $relativeScriptPath;

    /**
     * @var string
     */
    private $absoluteScriptPath;

    /**
     * @var array
     */
    private $scriptDependencies = [];

    /**
     * @var string
     */
    private $version = '';

    /**
     * @var bool
     */
    private $loadScriptInFooter = false;

    /**
     * @var bool
     */
    private $registerTranslations = false;

    /**
     * @var string
     */
    private $localizeScriptParamName;

    /**
     * @var mixed
     */
    private $localizeScriptParamData;

    /**
     * @var string
     */
    private $pluginDirPath;

    /**
     * @var string
     */
    private $pluginDirUrl;

    /**
     * @var string
     */
    private $textDomain;

    /**
     * @since 2.19.6
     *
     * @param string $scriptId
     * @param string $scriptPath
     * @param string $pluginDirPath
     * @param string $pluginDirUrl
     * @param string $textDomain
     */
    public function __construct($scriptId, $scriptPath, $pluginDirPath, $pluginDirUrl, $textDomain)
    {
        $this->pluginDirPath = trailingslashit($pluginDirPath);
        $this->pluginDirUrl = trailingslashit($pluginDirUrl);
        $this->textDomain = $textDomain;
        $this->scriptId = $scriptId;
        $this->relativeScriptPath = $scriptPath;
        $this->absoluteScriptPath = $this->pluginDirPath . $this->relativeScriptPath;
    }

    /**
     * @since 2.19.6
     *
     * @param string $version
     *
     * @return $this
     */
    public function version($version)
    {
        $this->version = $version;
        return $this;
    }

    /**
     * @since 2.19.6
     * @return $this
     */
    public function loadInFooter()
    {
        $this->loadScriptInFooter = true;
        return $this;
    }

    /**
     * @since 2.19.6
     *
     * @param array $scriptDependencies
     *
     * @return $this
     */
    public function dependencies(array $scriptDependencies)
    {
        $this->scriptDependencies = $scriptDependencies;
        return $this;
    }

    /**
     * @since 4.0.0 added registration of style sheets generated by wordpress/scripts
     * @since 2.19.6
     * @return $this
     */
    public function register()
    {
        $scriptUrl = $this->pluginDirUrl . $this->relativeScriptPath;
        $scriptAsset = $this->getAssetFileData();

        $stylePath = $this->getStylePath();
        $styleUrl = $this->getStyleUrl();

        if (file_exists($stylePath)) {
            wp_register_style(
                $this->scriptId,
                $styleUrl,
                [],
                $scriptAsset['version']
            );
        }

        $stylePathIndex = $this->getStylePath('style-');
        $styleUrlIndex = $this->getStyleUrl('style-');

        if (file_exists($stylePathIndex)) {
            wp_register_style(
                'style-' . $this->scriptId,
                $styleUrlIndex,
                [],
                $scriptAsset['version']
            );
        }

        wp_register_script(
            $this->scriptId,
            $scriptUrl,
            $scriptAsset['dependencies'],
            $scriptAsset['version'],
            $this->loadScriptInFooter
        );

        if ($this->registerTranslations) {
            wp_set_script_translations(
                $this->scriptId,
                $this->textDomain,
                $this->pluginDirPath . 'languages'
            );
        }

        if ($this->localizeScriptParamData) {
            wp_localize_script(
                $this->scriptId,
                $this->localizeScriptParamName,
                $this->localizeScriptParamData
            );
        }

        return $this;
    }

    /**
     * This function should be called after enqueue or register function.
     *
     * @since 2.19.6
     * @return $this
     */
    public function registerTranslations()
    {
        $this->registerTranslations = true;

        return $this;
    }

    /**
     * This function should be called after enqueue or register function.
     *
     * @param string $jsVariableName
     * @param mixed $data
     *
     * @return $this
     */
    public function registerLocalizeData($jsVariableName, $data)
    {
        $this->localizeScriptParamName = $jsVariableName;
        $this->localizeScriptParamData = $data;

        return $this;
    }

    /**
     * @since 2.19.6
     * @return $this
     */
    public function enqueue()
    {
        if (!wp_script_is($this->scriptId, 'registered')) {
            $this->register();
        }

        wp_enqueue_script($this->scriptId);

        if (wp_style_is($this->scriptId, 'registered')) {
            wp_enqueue_style($this->scriptId);
        }

        if (wp_style_is('style-' . $this->scriptId, 'registered')) {
            wp_enqueue_style('style-' . $this->scriptId);
        }

        return $this;
    }

    /**
     * @since 2.19.6
     * @return string
     */
    public function getScriptId()
    {
        return $this->scriptId;
    }

    /**
     * @since 2.19.6
     *
     * @return array
     */
    public function getAssetFileData()
    {
        $scriptAssetPath = trailingslashit(dirname($this->absoluteScriptPath))
            . basename($this->absoluteScriptPath, '.js')
            . '.asset.php';
        $scriptAsset = file_exists($scriptAssetPath)
            ? require($scriptAssetPath)
            : ['dependencies' => [], 'version' => $this->version ?: filemtime($this->absoluteScriptPath)];

        if ($this->scriptDependencies) {
            $scriptAsset['dependencies'] = array_merge($this->scriptDependencies, $scriptAsset['dependencies']);
        }

        return $scriptAsset;
    }

    /**
     * @since 4.0.0
     */
    public function getStylePath($prefix = ''): string
    {
        return trailingslashit(dirname($this->absoluteScriptPath))
            . trim($prefix . basename($this->relativeScriptPath, '.js')) . '.css';
    }

    /**
     * @since 4.0.0
     */
    public function getStyleUrl($prefix = ''): string
    {
        $cssFileName = trim($prefix . basename($this->relativeScriptPath, '.js')) . '.css';

        return $this->pluginDirUrl . str_replace(basename($this->relativeScriptPath), $cssFileName, $this->relativeScriptPath);
    }
}



Current_dir [ WRITEABLE ] Document_root [ WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
4 Apr 2026 1.57 AM
bravrvjk / bravrvjk
0755
Blocks
--
4 Apr 2026 1.57 AM
bravrvjk / bravrvjk
0755
Database
--
4 Apr 2026 1.57 AM
bravrvjk / bravrvjk
0755
DesignSystem
--
4 Apr 2026 1.57 AM
bravrvjk / bravrvjk
0755
Exceptions
--
4 Apr 2026 1.57 AM
bravrvjk / bravrvjk
0755
FieldsAPI
--
4 Apr 2026 1.57 AM
bravrvjk / bravrvjk
0755
FormDesigns
--
4 Apr 2026 1.57 AM
bravrvjk / bravrvjk
0755
Http
--
4 Apr 2026 1.57 AM
bravrvjk / bravrvjk
0755
LegacyPaymentGateways
--
4 Apr 2026 1.57 AM
bravrvjk / bravrvjk
0755
ListTable
--
4 Apr 2026 1.57 AM
bravrvjk / bravrvjk
0755
Migrations
--
4 Apr 2026 1.57 AM
bravrvjk / bravrvjk
0755
Models
--
4 Apr 2026 1.57 AM
bravrvjk / bravrvjk
0755
PaymentGateways
--
4 Apr 2026 1.57 AM
bravrvjk / bravrvjk
0755
Permissions
--
4 Apr 2026 1.57 AM
bravrvjk / bravrvjk
0755
QueryBuilder
--
4 Apr 2026 1.57 AM
bravrvjk / bravrvjk
0755
Receipts
--
4 Apr 2026 1.57 AM
bravrvjk / bravrvjk
0755
Routes
--
4 Apr 2026 1.57 AM
bravrvjk / bravrvjk
0755
Support
--
4 Apr 2026 1.57 AM
bravrvjk / bravrvjk
0755
TemplateTags
--
4 Apr 2026 1.57 AM
bravrvjk / bravrvjk
0755
ValidationRules
--
4 Apr 2026 1.57 AM
bravrvjk / bravrvjk
0755
Views
--
4 Apr 2026 1.57 AM
bravrvjk / bravrvjk
0755
WordPressLibraries
--
4 Apr 2026 1.57 AM
bravrvjk / bravrvjk
0755
WordPressShims
--
4 Apr 2026 1.57 AM
bravrvjk / bravrvjk
0755
EnqueueScript.php
6.572 KB
31 Mar 2025 11.17 PM
bravrvjk / bravrvjk
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025 CONTACT ME
Static GIF