' . esc_html($label) . ''); return $links; } /** Under the description, until the site is connected: where a free AguMail account starts. */ function agumail_onboarding_row_meta($meta, $file = '') { if ($file !== plugin_basename(AGUMAIL_FILE) || agumail_has_api_key() || !current_user_can(AGUMAIL_ADMIN_CAPABILITY)) { return $meta; } $meta[] = '' . esc_html__('Create a free AguMail account', 'agumail') . ' ' . esc_html__('(opens in a new tab)', 'agumail') . ''; return $meta; } // ───────────────────────────────────────────────────────────────────────────── // The connect notice. Its button starts the one-click connect straight away; // Dismiss is an admin action, so it passes the same nonce and capability // checks as every other. // ───────────────────────────────────────────────────────────────────────────── /** Whether the notice belongs on the screen being drawn. */ function agumail_onboarding_notice_due() { if (!current_user_can(AGUMAIL_ADMIN_CAPABILITY) || agumail_has_api_key() || get_option('agumail_connect_notice_dismissed') === 'yes') { return false; } return agumail_onboarding_screen_due(); } /** The Dashboard and the Plugins screen only. The AguMail page says it all already. */ function agumail_onboarding_screen_due() { $screen = function_exists('get_current_screen') ? get_current_screen() : null; return $screen && !empty($screen->id) && in_array($screen->id, array('dashboard', 'plugins'), true); } /** * A store connects in one click from the notice; any other site goes to the * AguMail page, where it connects with a key. Both offer a free account. */ function agumail_onboarding_notice() { if (!agumail_onboarding_notice_due()) { return; } $signup = '' . esc_html__('Create a free account', 'agumail') . ' ' . esc_html__('(opens in a new tab)', 'agumail') . ' '; if (agumail_woocommerce_active()) { $text = esc_html__('Connect AguMail to start syncing your customers, orders and carts.', 'agumail'); $start = '' . esc_html__('Connect to AguMail', 'agumail') . ' '; } else { $text = esc_html__('Grow your email list with AguMail: signup forms, popups and the forms you already have, with welcome emails that send themselves.', 'agumail'); $start = '' . esc_html__('Get started', 'agumail') . ' '; } echo '

' . $text . '

' // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- escaped above. . $start . $signup // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- built from escaped parts above. . '' . esc_html__('Dismiss', 'agumail') . '' . '

'; } /** Admin action: the notice stays away for good, and the merchant goes back to the page they were on. */ function agumail_onboarding_dismiss_notice() { update_option('agumail_connect_notice_dismissed', 'yes', false); $back = wp_get_referer(); return array('redirect' => $back ? $back : admin_url()); } // ───────────────────────────────────────────────────────────────────────────── // Store sync and the plan, said once each: held (the plan stopped carrying it), // resumed, offer (a site connected by key that has just gained WooCommerce) or // available (a store connected for forms and signups whose plan now carries // it). The AguMail page says it in its Connection section anyway. // ───────────────────────────────────────────────────────────────────────────── /** held, resumed, offer or available, when it belongs on the screen being drawn; '' otherwise. */ function agumail_onboarding_store_notice_due() { $notice = (string) get_option('agumail_store_notice', ''); if (!in_array($notice, array('held', 'resumed', 'offer', 'available'), true) || !current_user_can(AGUMAIL_ADMIN_CAPABILITY) || !agumail_has_api_key() || !agumail_woocommerce_active() || !agumail_onboarding_screen_due()) { return ''; } if ($notice === 'held' && !agumail_store_sync_held()) { return ''; } if (in_array($notice, array('offer', 'available'), true) && agumail_connection_platform() !== 'wordpress') { return ''; } return $notice; } function agumail_onboarding_store_notice() { $notice = agumail_onboarding_store_notice_due(); if ($notice === '') { return; } $dismiss = '' . esc_html__('Dismiss', 'agumail') . ''; if ($notice === 'held') { echo '

' . esc_html__('AguMail paused store sync: your plan does not include it.', 'agumail') . ' ' . esc_html__('Signups, forms and checkout subscribers keep going to AguMail. Orders and products wait, and go once your plan includes store sync.', 'agumail') . '

' . '' . esc_html__('See plans', 'agumail') . ' ' . esc_html__('(opens in a new tab)', 'agumail') . ' ' . $dismiss . '

'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- escaped above. } elseif ($notice === 'offer') { echo '

' . esc_html__('AguMail can sync your store too.', 'agumail') . ' ' . esc_html__('Recover abandoned carts, see the revenue your emails bring in and put your products in emails. Store sync is on AguMail\'s Commerce plans; your forms and signups keep working either way.', 'agumail') . '

' . '' . esc_html__('See plans', 'agumail') . ' ' . esc_html__('(opens in a new tab)', 'agumail') . ' ' . $dismiss . '

'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- escaped above. } elseif ($notice === 'resumed') { echo '

' . esc_html__('AguMail store sync is back on. Orders and products that waited are on their way.', 'agumail') . ' ' . $dismiss . '

'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- escaped above. } else { echo '

' . esc_html__('Your AguMail plan now includes store sync.', 'agumail') . ' ' . esc_html__('Sync your store to recover abandoned carts and see the revenue your emails bring in.', 'agumail') . '

' . '' . esc_html__('Sync your store', 'agumail') . ' ' . $dismiss . '

'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- escaped above. } } /** Admin action: the store notice goes, and the merchant goes back to the page they were on. */ function agumail_onboarding_dismiss_store_notice() { delete_option('agumail_store_notice'); $back = wp_get_referer(); return array('redirect' => $back ? $back : admin_url()); }