| Server IP : 38.190.208.107 / Your IP : 216.73.217.46 Web Server : nginx/1.28.1 System : Linux ht2026040333114 6.1.0-10-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.37-1 (2023-07-03) x86_64 User : root ( 0) PHP Version : 8.2.28 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv,eval,assert,passthru,system,exec,shell_exec,popen,proc_open MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wwwroot/wp.3/wp-content/plugins/js_composer/include/autoload/ |
Upload File : |
<?php
/**
* Autoload preset for vendors.
*
* @note we require our autoload files everytime and everywhere after plugin load.
* @since 4.8
*/
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* Singleton to hold all vendor presets
*
* @since 4.8
*/
class Vc_Vendor_Preset {
/**
* Instance of Vc_Vendor_Preset
*
* @var Vc_Vendor_Preset
*/
private static $instance;
/**
* Collection of vendor presets
*
* @var array
*/
private static $presets = [];
/**
* Get instance of Vc_Vendor_Preset.
*
* @return \Vc_Vendor_Preset
*/
public static function getInstance() {
if ( ! self::$instance ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Protected constructor.
*/
protected function __construct() {
}
/**
* Add vendor preset to collection
*
* @param string $title
* @param string $shortcode
* @param array $params
* @param bool $default_value
*
* @return bool
* @since 4.8
*/
public function add( $title, $shortcode, $params, $default_value = false ) {
if ( ! $title || ! is_string( $title ) || ! $shortcode || ! is_string( $shortcode ) || ! $params || ! is_array( $params ) ) {
return false;
}
$preset = [
'shortcode' => $shortcode,
'default' => $default_value,
'params' => $params,
'title' => $title,
];
// @codingStandardsIgnoreLine
$id = md5( serialize( $preset ) );
self::$presets[ $id ] = $preset;
return true;
}
/**
* Get specific vendor preset
*
* @param string $id
*
* @return mixed array|false
* @since 4.8
*/
public function get( $id ) {
if ( isset( self::$presets[ $id ] ) ) {
return self::$presets[ $id ];
}
return false;
}
/**
* Get all vendor presets for specific shortcode
*
* @param string $shortcode
*
* @return array
* @since 4.8
*/
public function getAll( $shortcode ) {
$list = [];
foreach ( self::$presets as $id => $preset ) {
if ( $shortcode === $preset['shortcode'] ) {
$list[ $id ] = $preset;
}
}
return $list;
}
/**
* Get all default vendor presets
*
* Include only one default preset per shortcode
*
* @return array
* @since 4.8
*/
public function getDefaults() {
$list = [];
$added = [];
foreach ( self::$presets as $id => $preset ) {
if ( $preset['default'] && ! in_array( $preset['shortcode'], $added, true ) ) {
$added[] = $preset['shortcode'];
$list[ $id ] = $preset;
}
}
return $list;
}
/**
* Get ID of default preset for specific shortcode
*
* If multiple presets are default, return first
*
* @param string $shortcode
*
* @return string|null
* @since 4.8
*/
public function getDefaultId( $shortcode ) {
foreach ( self::$presets as $id => $preset ) {
if ( $shortcode === $preset['shortcode'] && $preset['default'] ) {
return $id;
}
}
return null;
}
}