403Webshell
Server IP : 192.158.238.246  /  Your IP : 3.19.244.133
Web Server : LiteSpeed
System : Linux uniform.iwebfusion.net 4.18.0-553.27.1.lve.1.el8.x86_64 #1 SMP Wed Nov 20 15:58:00 UTC 2024 x86_64
User : jenniferflocom ( 1321)
PHP Version : 8.1.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/jenniferflocom/public_html/wp-content/plugins/give/src/Framework/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/jenniferflocom/public_html/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 2.19.6
     * @return $this
     */
    public function register()
    {
        $scriptUrl = $this->pluginDirUrl . $this->relativeScriptPath;
        $scriptAsset = $this->getAssetFileData();

        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);

        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;
    }
}


Youez - 2016 - github.com/yon3zu
LinuXploit