__( 'Ready-made, one switch each. They add next steps to Today and send the few emails you always mean to send. Everything they do shows on the contact\'s timeline.', 'nodebook' ) ) ); echo '
'; echo '
' . wp_kses( Nodebook_Icons::svg( 'zap', 13 ), Nodebook_Icons::kses() ) . '' . esc_html__( 'Switched on', 'nodebook' ) . '' . esc_html( number_format_i18n( $on ) . ' / ' . number_format_i18n( count( $catalog ) ) ) . '' . esc_html__( 'Automations working for you', 'nodebook' ) . '
'; echo '
' . wp_kses( Nodebook_Icons::svg( 'check', 13 ), Nodebook_Icons::kses() ) . '' . esc_html__( 'Done for you', 'nodebook' ) . '' . esc_html( number_format_i18n( array_sum( $counts ) ) ) . '' . esc_html__( 'Next steps and emails in 30 days', 'nodebook' ) . '
'; echo '
'; $groups = array( 'task' => __( 'Next steps', 'nodebook' ), 'review' => __( 'Reviews', 'nodebook' ), 'email' => __( 'Emails', 'nodebook' ), ); foreach ( $groups as $kind => $title ) { echo '

' . esc_html( $title ) . '

'; if ( 'email' === $kind ) { echo '

' . esc_html__( 'Emails go out through your site\'s own mail. They are never sent to anyone whose email bounced or who marked it as spam.', 'nodebook' ) . '

'; } echo '
'; } Nodebook_Admin::footer(); } /** * One recipe: tile, name, what it does, a switch; and its settings in a fold-out. * * @param string $key Recipe. * @param array $r Catalog entry. * @param array $s Its settings. * @param int $count Times it ran in 30 days. */ private static function row( $key, array $r, array $s, $count ) { $is = ! empty( $s['on'] ); $uid = 'nb-auto-sw-' . $key; $line = $is ? ( $count /* translators: %s: number of times */ ? sprintf( _n( 'On · ran %s time in 30 days', 'On · ran %s times in 30 days', $count, 'nodebook' ), number_format_i18n( $count ) ) : __( 'On · nothing to do yet', 'nodebook' ) ) : __( 'Off', 'nodebook' ); $before = ! empty( $r['defaults']['before'] ); $has_days = isset( $s['days'] ) && ( (int) $r['defaults']['days'] > 0 || $before ); $has_settings = $has_days || isset( $s['subject'] ) || isset( $s['fields'] ); if ( 'review_ask' === $key && '' === (string) $s['url'] ) { $line = $is ? __( 'On · add your review link below to start', 'nodebook' ) : $line; } echo '
  • '; echo ''; wp_nonce_field( 'nodebook_recipe_' . $key ); echo '
    '; echo '
    ' . esc_html( $r['label'] ) . '' . esc_html( $r['does'] ) . '' . ( $is ? '' : '' ) . esc_html( $line ) . '
    '; echo '
    '; if ( $has_settings ) { if ( isset( $s['url'] ) ) { $host = (string) wp_parse_url( (string) $s['url'], PHP_URL_HOST ); /* translators: %s: website name of the review link */ $sum = '' !== $host ? sprintf( __( 'Review link: %s', 'nodebook' ), preg_replace( '/^www\./', '', $host ) ) : __( 'Add your review link', 'nodebook' ); } elseif ( isset( $s['fields'] ) ) { $watch = Nodebook_Recipes::watched_dates(); $when = (int) $s['days'] ? sprintf( /* translators: %s: number of days */ _n( '%s day before', '%s days before', (int) $s['days'], 'nodebook' ), number_format_i18n( (int) $s['days'] ) ) : __( 'on the day', 'nodebook' ); /* translators: 1: date names (Birthday, Anniversary), 2: when */ $sum = $watch ? sprintf( __( '%1$s, %2$s', 'nodebook' ), implode( ', ', $watch ), $when ) : __( 'Add a date field first', 'nodebook' ); } elseif ( isset( $s['subject'] ) ) { /* translators: %s: email subject */ $sum = sprintf( __( 'Email: “%s”', 'nodebook' ), $s['subject'] ); } else { /* translators: %s: number of days */ $sum = sprintf( _n( 'After %s day', 'After %s days', (int) $s['days'], 'nodebook' ), number_format_i18n( (int) $s['days'] ) ); } echo '
    ' . esc_html( $sum ) . '
    '; if ( isset( $s['url'] ) ) { echo ''; echo '

    ' . esc_html__( 'Google: open your Business Profile, choose "Ask for reviews" and copy the link. Tripadvisor, Trustpilot and Facebook links work too.', 'nodebook' ) . '

    '; } if ( isset( $s['fields'] ) ) { $dates = Nodebook_Recipes::date_fields(); if ( $dates ) { echo '
    ' . esc_html__( 'Which dates', 'nodebook' ) . ''; foreach ( $dates as $fk => $fl ) { echo ''; } echo '
    '; } echo '

    ' . esc_html__( 'Any date field on contacts can be remembered every year.', 'nodebook' ) . ' ' . esc_html__( 'Add a date field', 'nodebook' ) . '

    '; } if ( $has_days ) { echo ''; } if ( isset( $s['subject'] ) ) { echo ''; echo ''; $extra = array( 'won_thanks' => __( ', and {deal} for the deal.', 'nodebook' ), 'review_ask' => __( ', and {review_link} for your review link.', 'nodebook' ), ); echo '

    ' . esc_html__( 'You can use {first_name}, {name}, {site} and {my_name}', 'nodebook' ) . esc_html( $extra[ $key ] ?? '.' ) . '

    '; } echo '

    '; } echo '
  • '; } /** Save one recipe and come back to it. */ public static function save() { Nodebook_Admin::require_cap(); if ( ! current_user_can( 'manage_options' ) ) { wp_die( esc_html__( 'Only administrators can change automations.', 'nodebook' ), 403 ); } $key = isset( $_POST['key'] ) ? sanitize_key( wp_unslash( $_POST['key'] ) ) : ''; check_admin_referer( 'nodebook_recipe_' . $key ); $in = array( 'on' => ! empty( $_POST['on'] ), ); $cur = Nodebook_Recipes::get( $key ); // Fields not on the form keep their value. foreach ( array( 'days', 'subject', 'body', 'url' ) as $f ) { if ( isset( $_POST[ $f ] ) ) { $in[ $f ] = 'body' === $f ? sanitize_textarea_field( wp_unslash( $_POST[ $f ] ) ) : ( 'url' === $f ? esc_url_raw( wp_unslash( $_POST[ $f ] ) ) : sanitize_text_field( wp_unslash( $_POST[ $f ] ) ) ); } elseif ( isset( $cur[ $f ] ) ) { $in[ $f ] = $cur[ $f ]; } } if ( isset( $cur['fields'] ) ) { // The fold-out was submitted when "days" came with it; otherwise keep the picked dates. $in['fields'] = isset( $_POST['days'] ) ? ( isset( $_POST['fields'] ) ? array_map( 'sanitize_key', (array) wp_unslash( $_POST['fields'] ) ) : array() ) : $cur['fields']; } Nodebook_Recipes::save( $key, $in ); Nodebook_Admin::redirect( Nodebook_Admin::url( self::PAGE ) . '#nb-auto-' . $key, 'saved' ); } }