| 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/classes/Table/ |
Upload File : |
<?php
namespace ACP\Table;
use AC\Asset;
use AC\Form\Element\Select;
use AC\ListScreen;
use AC\ListScreenRepository\Filter;
use AC\ListScreenRepository\Sort;
use AC\ListScreenRepository\Storage;
use AC\PermissionChecker;
use AC\Registrable;
class Switcher implements Registrable {
/** @var Storage */
private $storage;
/** @var Asset\Location\Absolute */
private $location;
public function __construct( Storage $storage, Asset\Location\Absolute $location ) {
$this->storage = $storage;
$this->location = $location;
}
public function register() {
add_action( 'ac/admin_footer', [ $this, 'switcher' ] );
}
private function add_filter_args_to_url( $link ) {
if ( $post_status = filter_input( INPUT_GET, 'post_status', FILTER_SANITIZE_STRING ) ) {
$link = add_query_arg( [ 'post_status' => $post_status ], $link );
}
if ( $author = filter_input( INPUT_GET, 'author', FILTER_SANITIZE_STRING ) ) {
$link = add_query_arg( [ 'author' => $author ], $link );
}
return $link;
}
/**
* @param ListScreen $list_screen
*/
public function switcher( $list_screen ) {
if ( ! $list_screen ) {
return;
}
$list_screens = $this->storage->find_all( [
'key' => $list_screen->get_key(),
'filter' => new Filter\Permission( new PermissionChecker() ),
'sort' => new Sort\ManualOrder(),
] );
if ( $list_screens->count() > 1 ) : ?>
<form class="layout-switcher">
<label for="column-view-selector" class="label screen-reader-text">
<?php _e( 'Switch View', 'codepress-admin-columns' ); ?>
</label>
<span class="spinner"></span>
<?php
$options = [];
/** @var ListScreen $_list_screen */
foreach ( $list_screens as $_list_screen ) {
$options[ $this->add_filter_args_to_url( $_list_screen->get_screen_link() ) ] = $_list_screen->get_title() ? $_list_screen->get_title() : __( 'Original', 'codepress-admin-columns' );
}
$select = new Select( 'layout', $options );
$select->set_attribute( 'id', 'column-view-selector' )
->set_attribute( 'data-ac-tip', __( 'Switch View', 'codepress-admin-columns' ) )
->set_value( $this->add_filter_args_to_url( $list_screen->get_screen_link() ) );
echo $select->render();
?>
<script type="text/javascript">
jQuery( document ).ready( function( $ ) {
$( '.layout-switcher' ).change( function() {
var _select = $( this ).addClass( 'loading' ).find( 'select' ).attr( 'disabled', 1 );
window.location = _select.val();
} );
} );
</script>
</form>
<?php
endif;
}
}