Use new code style
This commit is contained in:
@ -29,8 +29,7 @@ class User_Switching {
|
||||
public function __construct() {
|
||||
|
||||
add_action('plugins_loaded', array($this, 'register_forms'));
|
||||
|
||||
} // end __construct;
|
||||
}
|
||||
/**
|
||||
* Check if Plugin User Switching is activated
|
||||
*
|
||||
@ -39,8 +38,7 @@ class User_Switching {
|
||||
public function check_user_switching_is_activated(): bool {
|
||||
|
||||
return class_exists('user_switching');
|
||||
|
||||
} // end check_user_switching_is_activated;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register forms
|
||||
@ -51,11 +49,13 @@ class User_Switching {
|
||||
*/
|
||||
public function register_forms() {
|
||||
|
||||
wu_register_form('install_user_switching', array(
|
||||
'render' => array($this, 'render_install_user_switching'),
|
||||
));
|
||||
|
||||
} // end register_forms;
|
||||
wu_register_form(
|
||||
'install_user_switching',
|
||||
array(
|
||||
'render' => array($this, 'render_install_user_switching'),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Install Form of User Switching
|
||||
@ -79,26 +79,31 @@ class User_Switching {
|
||||
'classes' => 'button button-primary wu-w-full',
|
||||
'wrapper_classes' => 'wu-items-end wu-text-center wu-bg-gray-100',
|
||||
'html_attr' => array(
|
||||
'href' => add_query_arg(array(
|
||||
's' => 'user-switching',
|
||||
'tab' => 'search',
|
||||
'type' => 'tag'
|
||||
), network_admin_url('plugin-install.php')
|
||||
'href' => add_query_arg(
|
||||
array(
|
||||
's' => 'user-switching',
|
||||
'tab' => 'search',
|
||||
'type' => 'tag',
|
||||
),
|
||||
network_admin_url('plugin-install.php')
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$form = new \WP_Ultimo\UI\Form('install_user_switching', $fields, array(
|
||||
'views' => 'admin-pages/fields',
|
||||
'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0',
|
||||
'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid',
|
||||
'html_attr' => array(),
|
||||
));
|
||||
$form = new \WP_Ultimo\UI\Form(
|
||||
'install_user_switching',
|
||||
$fields,
|
||||
array(
|
||||
'views' => 'admin-pages/fields',
|
||||
'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0',
|
||||
'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid',
|
||||
'html_attr' => array(),
|
||||
)
|
||||
);
|
||||
|
||||
$form->render();
|
||||
|
||||
} // end render_install_user_switching;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function return should return the correct url
|
||||
@ -113,18 +118,12 @@ class User_Switching {
|
||||
|
||||
$user = new \WP_User($user_id);
|
||||
|
||||
if (!$this->check_user_switching_is_activated()) {
|
||||
|
||||
if ( ! $this->check_user_switching_is_activated()) {
|
||||
return wu_get_form_url('install_user_switching');
|
||||
|
||||
} else {
|
||||
|
||||
$link = \user_switching::switch_to_url($user);
|
||||
|
||||
return $link;
|
||||
|
||||
} // end if;
|
||||
|
||||
} // end render;
|
||||
|
||||
} // end class User_Switching;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user