'array', 'sanitize_callback' => array( 'Nodebook_Settings', 'sanitize' ), 'default' => Nodebook_Settings::defaults(), ) ); } public static function regenerate_key() { if ( ! current_user_can( 'manage_options' ) ) { wp_die( esc_html__( 'You are not allowed to do this.', 'nodebook' ), 403 ); } check_admin_referer( 'nodebook_inbound_key' ); Nodebook_Inbound::regenerate(); Nodebook_Admin::redirect( Nodebook_Admin::url( 'nodebook-integrations' ) . '#nb-int-webhook', 'newkey' ); } /** What works and what silently doesn't. */ private static function status_card() { $labels = array( 'ok' => __( 'OK', 'nodebook' ), 'warn' => __( 'Check', 'nodebook' ), 'bad' => __( 'Problem', 'nodebook' ), ); echo '

' . esc_html__( 'Status', 'nodebook' ) . '

'; } public static function test_alert() { if ( ! current_user_can( 'manage_options' ) ) { wp_die( esc_html__( 'You are not allowed to do this.', 'nodebook' ), 403 ); } check_admin_referer( 'nodebook_test_alert' ); $ok = Nodebook_Setup::send_test(); Nodebook_Admin::redirect( Nodebook_Admin::url( 'nodebook-settings' ) . '#nb-status', $ok ? 'mailok' : 'mailfail' ); } public static function test_weekly() { if ( ! current_user_can( 'manage_options' ) ) { wp_die( esc_html__( 'You are not allowed to do this.', 'nodebook' ), 403 ); } check_admin_referer( 'nodebook_test_weekly' ); $ok = Nodebook_Weekly::send( true ); Nodebook_Admin::redirect( Nodebook_Admin::url( 'nodebook-settings' ) . '#nb-signals', $ok ? 'weeklyok' : 'mailfail' ); } private static function name( $key, $multi = false ) { return Nodebook_Settings::OPTION . '[' . $key . ']' . ( $multi ? '[]' : '' ); } /** "Node on your phone": the app's address, connect a phone (code + QR), connected phones. */ private static function phone_row() { $owner = Nodebook_Node::owner(); $me = get_current_user_id() === $owner; echo '

' . esc_html__( 'Today, people waiting, tasks and contacts in your pocket, with one-tap call and WhatsApp. Press “Connect a phone” and scan the code with your phone’s camera. The app has a private address that is not linked anywhere: anyone else who finds it sees “page not found”.', 'nodebook' ) . '

'; if ( $me ) { echo '
'; } else { echo '

' . esc_html( sprintf( /* translators: %s: name */ __( 'Only %s, who Node works for, can connect a phone.', 'nodebook' ), Nodebook_Node::user_first( $owner ) ) ) . '

'; } $devices = Nodebook_App::devices( $owner ); if ( $devices ) { echo ''; } } /** Forms that sit outside the settings form (nested forms are not allowed). */ private static function phone_forms() { foreach ( array_keys( Nodebook_App::devices() ) as $sel ) { echo ''; } } /** AJAX: a fresh code (and link) to connect a phone. */ public static function app_code() { check_ajax_referer( 'nodebook_ajax', 'nonce' ); if ( ! current_user_can( 'manage_options' ) ) { wp_send_json_error( null, 403 ); } $r = Nodebook_App::create_code( get_current_user_id() ); if ( is_wp_error( $r ) ) { wp_send_json_error( array( 'message' => $r->get_error_message() ) ); } wp_send_json_success( $r ); } public static function app_forget() { if ( ! current_user_can( 'manage_options' ) ) { wp_die( esc_html__( 'Sorry, you are not allowed to do that.', 'nodebook' ), 403 ); } check_admin_referer( 'nodebook_app_forget' ); Nodebook_App::forget( isset( $_POST['selector'] ) ? sanitize_key( wp_unslash( $_POST['selector'] ) ) : '' ); Nodebook_Admin::redirect( Nodebook_Admin::url( 'nodebook-settings' ) . '#nb-phone', 'saved' ); } public static function page() { if ( ! current_user_can( 'manage_options' ) ) { return; } $s = Nodebook_Settings::all(); Nodebook_Admin::header( __( 'Settings', 'nodebook' ) ); settings_errors(); echo '
'; self::status_card(); ?>

> > id="nb-permissions"> >

'; Nodebook_Admin::footer(); } }