settings = $settings; $this->providers = $providers; } /** * Register hooks. * * @return void */ public function register() { add_action( 'admin_menu', array( $this, 'menu' ) ); add_action( 'admin_init', array( $this, 'setting' ) ); add_action( 'admin_enqueue_scripts', array( $this, 'assets' ) ); } /** * Add top-level menu. * * @return void */ public function menu() { add_menu_page( __( 'Anar Toolkit', 'anar-toolkit' ), __( 'Anar Toolkit', 'anar-toolkit' ), 'manage_options', 'anar-login', array( FeaturesPage::class, 'render' ), 'dashicons-shield-alt', 58 ); } /** * Register one sanitized option. * * @return void */ public function setting() { register_setting( 'anar_login', Settings::OPTION_KEY, array( 'type' => 'array', 'sanitize_callback' => array( $this, 'sanitize' ), 'default' => $this->settings->defaults(), ) ); } /** * Sanitize with the registered providers, so custom provider fields are stored too. * * @param mixed $input Raw settings. * @return array */ public function sanitize( $input ) { return $this->settings->sanitize( $input, $this->providers->all() ); } /** * Admin assets. * * @param string $hook Current page. * @return void */ public function assets( $hook ) { if ( false === strpos( $hook, 'anar-login-settings' ) ) { return; } if ( \Anar\Login\Infrastructure\Features::enabled( 'login' ) ) { wp_enqueue_media(); } wp_enqueue_style( 'anar-login-admin', ANAR_LOGIN_URL . 'assets/css/admin.css', array(), ANAR_LOGIN_VERSION ); wp_enqueue_script( 'anar-login-admin', ANAR_LOGIN_URL . 'assets/js/admin.js', array(), ANAR_LOGIN_VERSION, true ); wp_localize_script( 'anar-login-admin', 'AnarLoginAdmin', array( 'copied' => __( 'Copied ✓', 'anar-toolkit' ), 'failed' => __( 'Copy failed', 'anar-toolkit' ), 'restUrl' => esc_url_raw( rest_url( 'anar-login/v1/' ) ), 'nonce' => wp_create_nonce( 'wp_rest' ), 'sending' => __( 'Sending…', 'anar-toolkit' ), 'network' => __( 'Could not connect. Please try again.', 'anar-toolkit' ), ) ); } /** * Render settings application. * * @return void */ public function render() { if ( ! current_user_can( 'manage_options' ) ) { return; } $value = $this->settings->all(); $providers = $this->providers->all(); $direction = is_rtl() ? 'rtl' : 'ltr'; ?>

Anar Toolkit

v

MRNWP

section_header( __( 'General settings', 'anar-toolkit' ), __( 'Configure sign-in, registration, and the appearance of the form.', 'anar-toolkit' ), '⚙' ); ?>
toggle( 'allow_registration', __( 'Create accounts automatically', 'anar-toolkit' ), __( 'Create a new account when a verified user does not already have one.', 'anar-toolkit' ), $value ); ?>
'anar_login_settings[panel_page_id]', 'id' => 'anar-panel-page', 'selected' => absint( $value['panel_page_id'] ), 'show_option_none' => esc_html__( 'Not selected', 'anar-toolkit' ), 'option_none_value' => 0, 'echo' => 0, ) ); echo wp_kses( $pages_dropdown, array( 'select' => array( 'name' => true, 'id' => true, ), 'option' => array( 'value' => true, 'selected' => true, 'class' => true, ), ) ); ?>
>
toggle( 'replace_theme_login', __( 'Replace the theme’s login', 'anar-toolkit' ), __( 'For signed-out visitors, every WooCommerce login form and the theme’s login links (header account, side panels, WoodMart dropdowns) use the passwordless form.', 'anar-toolkit' ), $value ); ?> toggle( 'replace_wp_login', __( 'Also replace wp-login.php', 'anar-toolkit' ), __( 'Off by default. When on, the WordPress login page shows the passwordless form with a “Sign in with a password” link, so staff can always use their password.', 'anar-toolkit' ), $value ); ?> toggle( 'popup_enabled', __( 'Login popup', 'anar-toolkit' ), __( 'Open the sign-in form in a popup from any link to #anar-login, such as a menu item. The form loads only when it is first opened, so page speed is unaffected.', 'anar-toolkit' ), $value ); ?>

__( 'General', 'anar-toolkit' ), 'sms' => __( 'SMS', 'anar-toolkit' ), 'email' => __( 'Email', 'anar-toolkit' ), 'google' => __( 'Google sign-in', 'anar-toolkit' ), 'security' => __( 'Security', 'anar-toolkit' ), 'woocommerce' => __( 'WooCommerce', 'anar-toolkit' ), 'install' => __( 'Add to pages', 'anar-toolkit' ) ); $primary = array( 'general' => $flags['login'], 'sms' => ( $flags['login'] && 'email' !== $value['identity_mode'] ) || $flags['two_factor'] || $flags['reset'] || \Anar\Login\Infrastructure\Features::queue_needed(), 'email' => $flags['login'] && 'phone' !== $value['identity_mode'], 'google' => $flags['login'] && ! empty( $value['google_enabled'] ), 'security' => $flags['login'] || $flags['reset'] || $flags['two_factor'], 'woocommerce' => $flags['login'] && WooCommerce::active(), 'install' => $flags['login'] ); $first = true; foreach ( array( true => __( 'Connection settings', 'anar-toolkit' ), false => __( 'Other features', 'anar-toolkit' ) ) as $enabled => $heading ) { ?>
$label ) { if ( (bool) $primary[ $key ] !== (bool) $enabled || ( 'woocommerce' === $key && ! WooCommerce::active() ) ) { continue; } ?>

$value Values. * @return void */ private function toggle( $key, $title, $description, $value ) { ?>
$value Values. * @param int $min Min. * @param int $max Max. * @param string $suffix Suffix. * @return void */ private function number_field( $key, $label, $value, $min, $max, $suffix ) { ?>