| Server IP : 43.130.17.34 / Your IP : 216.73.217.6 Web Server : nginx/1.28.0 System : Linux VM-4-12-opencloudos 6.6.92-34.1.oc9.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jun 25 21:32:13 CST 2025 x86_64 User : www ( 1000) PHP Version : 8.0.26 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/yespkg.com/wp-content/plugins/admin-columns-pro.5.1.3/admin-columns/classes/ |
Upload File : |
<?php
namespace AC;
use AC\Admin\Helpable;
use AC\Admin\Menu;
use AC\Admin\Page;
use AC\Admin\PageCollection;
use AC\Asset\Enqueueables;
use AC\Asset\Location;
use AC\Asset\Script;
use AC\Asset\Style;
class Admin implements Registrable {
const NAME = 'codepress-admin-columns';
const QUERY_ARG_PAGE = 'page';
const QUERY_ARG_TAB = 'tab';
/**
* @var string
*/
private $parent_slug;
/**
* @var string
*/
private $menu_hook;
/**
* @var PageCollection
*/
private $pages;
/**
* @var Location\Absolute
*/
private $location;
public function __construct( $parent_slug, $menu_hook, PageCollection $pages, Location\Absolute $location ) {
$this->parent_slug = $parent_slug;
$this->menu_hook = $menu_hook;
$this->pages = $pages;
$this->location = $location;
}
/**
* @return Location\Absolute
*/
public function get_location() {
return $this->location;
}
/**
* @param string $slug
*
* @return Page|null
*/
public function get_page( $slug ) {
return $this->pages->get( $slug );
}
public function add_page( Page $page ) {
$this->pages->add( $page );
}
/**
* @param string $slug
*
* @return string
*/
protected function create_menu_link( $slug ) {
return add_query_arg(
[
self::QUERY_ARG_PAGE => self::NAME,
self::QUERY_ARG_TAB => $slug,
],
$this->parent_slug
);
}
/**
* @return Page
*/
private function get_current_page() {
$slug = filter_input( INPUT_GET, 'tab' );
if ( $this->pages->has( $slug ) ) {
return $this->pages->get( $slug );
}
return $this->pages->first();
}
/**
* @return Menu
*/
private function get_menu() {
$menu = new Menu();
$current_slug = $this->get_current_page()->get_slug();
foreach ( $this->pages->all() as $page ) {
$class = $current_slug === $page->get_slug()
? 'nav-tab-active'
: null;
$menu->add( new Menu\Item( $this->create_menu_link( $page->get_slug() ), $page->get_title(), $class ) );
}
return $menu;
}
public function register() {
add_action( $this->menu_hook, [ $this, 'register_menu' ] );
}
public function register_menu() {
$hook = add_submenu_page(
$this->parent_slug,
__( 'Admin Columns Settings', 'codepress-admin-columns' ),
__( 'Admin Columns', 'codepress-admin-columns' ),
Capabilities::MANAGE,
self::NAME,
[ $this, 'render' ]
);
add_action( "load-" . $hook, [ $this, 'scripts' ] );
}
public function render() {
?>
<div id="cpac" class="wrap">
<?= $this->get_menu()->render(); ?>
<?= $this->get_current_page()->render(); ?>
</div>
<?php
}
public function scripts() {
$page = $this->get_current_page();
if ( $page instanceof Enqueueables ) {
foreach ( $page->get_assets() as $asset ) {
$asset->enqueue();
}
}
if ( $page instanceof Helpable ) {
foreach ( $page->get_help_tabs() as $help ) {
get_current_screen()->add_help_tab( [
'id' => $help->get_id(),
'title' => $help->get_title(),
'content' => $help->get_content(),
] );
}
}
$assets = [
new Style( 'wp-pointer' ),
new Style( 'jquery-qtip2', $this->location->with_suffix( 'external/qtip2/jquery.qtip.min.css' ) ),
new Script( 'jquery-qtip2', $this->location->with_suffix( 'external/qtip2/jquery.qtip.min.js' ), [ 'jquery' ] ),
new Script( 'ac-admin-general', $this->location->with_suffix( 'assets/js/admin-general.js' ), [ 'jquery', 'wp-pointer', 'jquery-qtip2' ] ),
new Style( 'ac-admin', $this->location->with_suffix( 'assets/css/admin-general.css' ) ),
];
foreach ( $assets as $asset ) {
$asset->enqueue();
}
do_action( 'ac/admin_scripts' );
do_action( 'ac/admin_scripts/' . $page->get_slug() );
/**
* @deprecated 4.1
*/
do_action_deprecated( 'ac/settings/scripts', null, '4.1', 'ac/admin_scripts' );
}
}