| Server IP : 47.82.179.145 / Your IP : 216.73.217.129 Web Server : nginx/1.26.3 System : Linux iZt4n9czhka2zvqfajdlr2Z 6.8.0-63-generic #66-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 13 20:25:30 UTC 2025 x86_64 User : www ( 1001) PHP Version : 8.3.30 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 MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wwwroot/scuipturepactory.com/wp-content/themes/plover/core/src/Assets/ |
Upload File : |
<?php
namespace Plover\Core\Assets;
use Plover\Core\Assets\Contract\IconSource;
use Plover\Core\Plover;
use Plover\Core\Toolkits\Arr;
use Plover\Core\Toolkits\Format;
/**
* Icon library and icons handler.
*
* @since 1.0.0
*/
class Icons {
/**
* Plover core.
*
* @var Plover
*/
protected $core;
/**
* Registered icon sources.
*
* @var array
*/
protected $sources = [];
/**
* Create icons instance.
*
* @param Plover $core
*/
public function __construct( Plover $core ) {
$this->core = $core;
$this->register_icon_source( new PrimitiveIconSource(), 11 );
}
/**
* @param IconSource $source
* @param int $priority
*
* @return void
*/
public function register_icon_source( IconSource $source, int $priority = 10 ) {
$this->sources[ $priority ][] = $source;
}
/**
* @param $library
* @param $slug
*
* @return string|null
*/
public function get_icon( $library, $slug ) {
$svg = $this->retrieve_from_icon_source( 'get_icon', $library, $slug );
if ( ! is_string( $svg ) ) {
return null;
}
return Format::sanitize_svg( $svg );
}
/**
* Get library info.
*
* @param $library
*
* @return mixed|null
*/
public function get_library( $library ) {
return $this->retrieve_from_icon_source( 'get_library', $library );
}
/**
* Get all libraries.
*
* @return array|mixed|null
*/
public function get_libraries() {
$libraries = $this->retrieve_all_from_icon_source( 'get_libraries' );
return apply_filters( 'plover_core_icon_libraries', $libraries );
}
/**
* @param $library
*
* @return array|null
*/
public function get_icons( $library ) {
$icons = $this->retrieve_from_icon_source( 'get_icons', $library );
if ( ! is_array( $icons ) ) {
$icons = [];
}
return apply_filters( "plover_core_{$library}_icons", $icons );
}
/**
* Retrieve data from the icon sources in order of priority.
*
* @param $method
* @param ...$args
*
* @return mixed|null
*/
protected function retrieve_from_icon_source( $method, ...$args ) {
$priorities = array_keys( $this->sources );
sort( $priorities );
foreach ( $priorities as $priority ) {
foreach ( $this->sources[ $priority ] as $source ) {
$data = call_user_func_array( [ $source, $method ], $args );
if ( $data ) {
return $data;
}
}
}
return null;
}
/**
* Retrieve all data from each icon source in order of priority.
*
* @param $method
* @param ...$args
*
* @return mixed|null
*/
protected function retrieve_all_from_icon_source( $method, ...$args ) {
$priorities = array_keys( $this->sources );
sort( $priorities );
$result = [];
foreach ( $priorities as $priority ) {
foreach ( $this->sources[ $priority ] as $source ) {
$data = call_user_func_array( [ $source, $method ], $args );
if ( is_array( $data ) ) {
$result = array_merge( $result, $data );
} else if ( $data ) {
$result[] = $data;
}
}
}
return $result;
}
}