public function __construct($base)
 {
     $this->base = $base;
     $this->admin = $base->admin;
     if (isset($_GET['delete_all'])) {
         check_admin_referer('bulk-pages');
         $this->sendback = remove_query_arg(array('trashed', 'untrashed', 'deleted', 'ids'), $this->admin->get_referer());
         if (strpos($this->sendback, 'page.php') !== false) {
             $this->sendback = ks_admin_url(KTAI_NOT_ECHO) . 'page-new.php';
         }
         $deleted = $this->delete_all();
         $this->sendback = add_query_arg('deleted', $deleted, $this->sendback);
         $this->admin->redirect($this->sendback);
         exit;
     }
     $this->search = isset($_GET['s']) ? stripslashes($_GET['s']) : '';
     $this->is_trash = isset($_GET['post_status']) && $_GET['post_status'] == 'trash' && function_exists('wp_trash_post');
 }
 public function bypass_admin_404()
 {
     global $Ktai_Style;
     // redirect to dashboard or login screen if accessed to non-existing URLs
     if (isset($Ktai_Style->admin)) {
         if (preg_match('!^' . ks_plugin_url(KTAI_NOT_ECHO) . KtaiStyle::ADMIN_DIR . '/!', $_SERVER['REQUEST_URI'])) {
             $sid = $Ktai_Style->admin->get_sid();
             if ($sid) {
                 $url = add_query_arg(KtaiStyle_Admin::SESSION_NAME, $sid, ks_admin_url(KTAI_NOT_ECHO));
             } else {
                 $url = ks_get_login_url();
             }
             wp_redirect($url);
             exit;
         }
     } elseif (preg_match('!wp-admin/!', $_SERVER['REQUEST_URI'])) {
         // cannot use is_admin()
         exit;
         // shut out access to non-existing admin screen
     }
 }
function ks_admin_link()
{
    $defaults = array('before' => '', 'after' => '', 'echo' => true, 'accesskey' => '', 'anchor' => __('Site Admin'));
    $r = _ks_parse_arg(func_get_args(), $defaults);
    if (isset($r['label'])) {
        $r['anchor'] = $r['label'];
    }
    $output = '';
    if (is_user_logged_in() && ($url = ks_admin_url(KTAI_NOT_ECHO))) {
        $output = $r['before'] . sprintf('<a href="%s"%s>%s</a>', $url, ks_accesskey_html($r['accesskey']), $r['anchor']) . $r['after'];
        if ($r['echo']) {
            echo $output;
        }
    }
    return $output;
}