array( 'success', __( 'All set. Nodebook is ready for your business; you can change any of this under Settings and Modules.', 'nodebook' ) ), ); } public static function save() { if ( ! current_user_can( 'manage_options' ) ) { wp_die( esc_html__( 'You are not allowed to do this.', 'nodebook' ), 403 ); } check_admin_referer( 'nodebook_welcome' ); // phpcs:disable WordPress.Security.NonceVerification.Missing -- verified just above. $key = static function ( $k ) { return isset( $_POST[ $k ] ) ? sanitize_key( wp_unslash( $_POST[ $k ] ) ) : ''; }; $features = array(); foreach ( array( 'deals', 'gatherings', 'growth', 'abilities' ) as $f ) { if ( isset( $_POST['f_seen'][ $f ] ) ) { $features[ $f ] = ! empty( $_POST['f'][ $f ] ); } } $in = array( 'niche' => $key( 'niche' ), 'team_size' => $key( 'team_size' ), 'woo_capture' => $key( 'woo_capture' ), 'personality' => $key( 'personality' ), 'morning' => ! empty( $_POST['morning'] ), 'fields' => ! empty( $_POST['fields'] ), 'features' => $features, ); // phpcs:enable Nodebook_Presets::apply( $in ); Nodebook_Admin::redirect( Nodebook_Admin::url( 'nodebook-today' ), 'welcome' ); } public static function page() { if ( ! current_user_can( 'manage_options' ) ) { return; } $presets = Nodebook_Presets::all(); $niche = Nodebook_Niche::current(); $detected = Nodebook_Niche::detect(); $again = Nodebook_Presets::done(); $features = Nodebook_Presets::current_features(); $s = Nodebook_Settings::all(); $woo = Nodebook_Woocommerce::active(); $ai = Nodebook_Modules::get( 'abilities' ) && '' === Nodebook_Modules::problem( 'abilities' ); $name = Nodebook_Node::user_first( get_current_user_id() ); $defaults = array(); foreach ( $presets as $k => $p ) { $defaults[ $k ] = $p['features']; } echo '

' . esc_html__( 'Set up Nodebook', 'nodebook' ) . '

'; echo '
' . esc_html( Nodebook_Admin::brand_name() ) . ''; echo '' . esc_html( $again ? __( 'Cancel', 'nodebook' ) : __( 'Skip for now', 'nodebook' ) ) . '
'; echo ''; echo '
'; wp_nonce_field( 'nodebook_welcome' ); // 1. Business. self::step_open( 'business', Nodebook_Node::say( /* translators: %s: first name */ $name ? sprintf( __( 'Hi %s! I’m Node 👋 What kind of business is this?', 'nodebook' ), $name ) : __( 'Hi! I’m Node 👋 What kind of business is this?', 'nodebook' ), __( 'What kind of business is this?', 'nodebook' ) ), __( 'It sets the words Nodebook uses, which screens you see and what is switched on. You can change it later.', 'nodebook' ) ); echo '
'; foreach ( $presets as $k => $p ) { $why = $k === $detected ? Nodebook_Presets::reason( $k ) : ''; echo ''; } echo '
'; self::step_close(); // 2. Team. self::step_open( 'team', __( 'Who will use Nodebook?', 'nodebook' ), __( 'Just you: no owners or “Mine / Everyone” switches. A team: everyone gets their own list of people to follow up.', 'nodebook' ) ); $team = '' !== (string) $s['team_size'] ? $s['team_size'] : ( count( Nodebook_Team::users() ) > 1 ? 'team' : 'solo' ); echo '
'; foreach ( array( 'solo' => array( 'smile', __( 'Just me', 'nodebook' ), __( 'Simple and personal.', 'nodebook' ) ), 'team' => array( 'users', __( 'Me and my team', 'nodebook' ), __( 'Owners, assignments and a list for each of you.', 'nodebook' ) ), ) as $k => $o ) { echo ''; } echo '
'; self::step_close(); // 3. Shop customers (only with WooCommerce). if ( $woo ) { self::step_open( 'shop', __( 'When should shop customers become contacts?', 'nodebook' ), __( 'You can import past orders whenever you like, under Import & Export.', 'nodebook' ) ); $cap = in_array( $s['woo_capture'], array( 'orders', 'paid', 'off' ), true ) ? $s['woo_capture'] : 'paid'; echo '
'; foreach ( array( 'orders' => array( __( 'Every buyer', 'nodebook' ), __( 'As soon as they check out, paid or not.', 'nodebook' ) ), 'paid' => array( __( 'Only paid orders', 'nodebook' ), __( 'Once the payment is in.', 'nodebook' ) ), 'off' => array( __( 'Not automatically', 'nodebook' ), __( 'Only people from forms, bookings and imports.', 'nodebook' ) ), ) as $k => $o ) { echo ''; } echo '
'; self::step_close(); } // 4. What to switch on. self::step_open( 'features', __( 'Here’s what I’d switch on for you', 'nodebook' ), __( 'Based on your kind of business. Flip anything you like: it can all be changed later under Settings and Modules, and switching something off keeps its data.', 'nodebook' ) ); $rows = array( 'deals' => array( 'target', __( 'Deals and a pipeline', 'nodebook' ), __( 'Track sales from first contact to won, in a pipeline.', 'nodebook' ) ), 'gatherings' => array( 'calendar', __( 'Gatherings', 'nodebook' ), __( 'Retreats, workshops, trips and events with a roster, deposits and balances.', 'nodebook' ) ), 'growth' => array( 'activity', __( 'Growth tips', 'nodebook' ), __( 'What helps you get found on Google and in AI answers, checked once a day.', 'nodebook' ) ), ); if ( $ai ) { $rows['abilities'] = array( 'sparkles', __( 'AI assistants', 'nodebook' ), __( 'Let AI assistants connected to WordPress look up contacts and add notes, as you.', 'nodebook' ) ); } echo ''; // Suggested fields, per kind of business. echo '
'; foreach ( array_keys( $presets ) as $k ) { $fields = array_keys( Nodebook_Props::presets( $k ) ); $have = array_map( 'strtolower', wp_list_pluck( Nodebook_Props::defs( 'contact' ), 'label' ) ); $fields = array_values( array_filter( $fields, static function ( $l ) use ( $have ) { return ! in_array( strtolower( $l ), $have, true ); } ) ); echo '
'; if ( $fields ) { echo ''; } echo '
'; } echo '
'; self::step_close(); // 5. Node. self::step_open( 'node', __( 'Last one: how should I talk to you?', 'nodebook' ), __( 'I sit on Today and in the corner of every screen, pointing out the few things that deserve your attention.', 'nodebook' ) ); $pers = in_array( $s['node_personality'], array( 'playful', 'calm', 'off' ), true ) ? $s['node_personality'] : 'playful'; echo '
'; foreach ( array( 'playful' => array( 'happy', __( 'Playful', 'nodebook' ), __( 'A bit of fun and the odd emoji 🎉', 'nodebook' ) ), 'calm' => array( 'calm', __( 'Calm', 'nodebook' ), __( 'Short and to the point.', 'nodebook' ) ), 'off' => array( 'sleep', __( 'No Node', 'nodebook' ), __( 'Just the lists, thanks.', 'nodebook' ) ), ) as $k => $o ) { echo ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- blob() escapes its own attributes. } echo '
'; echo ''; self::step_close( true ); echo ''; echo '
'; } private static function step_open( $key, $title, $lead ) { echo '
' . ( Nodebook_Node::on() || ! Nodebook_Presets::done() ? Nodebook_Node::blob( 'hello', 52 ) : '' ) . '

' . esc_html( $title ) . '

' . esc_html( $lead ) . '

'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- blob() escapes its own attributes. } private static function step_close( $last = false ) { echo '
'; echo $last ? '' : ''; echo '
'; } }