one big "Connect to PostaraMail" button. * Connected -> Overview | Sync | Forms | Existing users | Advanced. */ if ( ! defined( 'ABSPATH' ) ) { exit; } class PostaraMail_Admin { /** Tab slug => translated label. A method (not a constant) so the strings are real gettext calls. */ private static function tabs() { return array( 'overview' => __( 'Overview', 'postaramail' ), 'sync' => __( 'Sync', 'postaramail' ), 'forms' => __( 'Forms', 'postaramail' ), 'existing' => __( 'Existing users', 'postaramail' ), 'advanced' => __( 'Advanced', 'postaramail' ), ); } public static function init() { add_action( 'admin_menu', array( __CLASS__, 'menu' ) ); add_action( 'admin_enqueue_scripts', array( __CLASS__, 'assets' ) ); add_action( 'admin_notices', array( __CLASS__, 'setup_notice' ) ); add_action( 'admin_init', array( __CLASS__, 'privacy_text' ) ); add_action( 'wp_ajax_postaramail_test', array( __CLASS__, 'ajax_test' ) ); foreach ( array( 'sync', 'forms', 'existing', 'send_existing', 'advanced', 'refresh', 'push_now', 'rescan' ) as $a ) { add_action( 'admin_post_postaramail_save_' . $a, array( __CLASS__, 'save_' . $a ) ); } } public static function menu() { add_menu_page( 'PostaraMail', 'PostaraMail', 'manage_options', 'postaramail', array( __CLASS__, 'page' ), 'dashicons-email-alt', 58 ); } public static function assets( $hook ) { if ( 'toplevel_page_postaramail' !== $hook ) { return; } wp_enqueue_style( 'postaramail-admin', POSTARAMAIL_WP_URL . 'assets/admin.css', array(), POSTARAMAIL_WP_VERSION ); wp_enqueue_style( 'postaramail-form', POSTARAMAIL_WP_URL . 'assets/form.css', array(), POSTARAMAIL_WP_VERSION ); wp_enqueue_script( 'postaramail-admin', POSTARAMAIL_WP_URL . 'assets/admin.js', array(), POSTARAMAIL_WP_VERSION, true ); wp_localize_script( 'postaramail-admin', 'PostaraMailAdmin', array( 'ajax' => admin_url( 'admin-ajax.php' ), 'nonce' => wp_create_nonce( 'postaramail_test' ), ) ); } public static function setup_notice() { if ( ! current_user_can( 'manage_options' ) || PostaraMail_API::configured() ) { return; } $screen = function_exists( 'get_current_screen' ) ? get_current_screen() : null; if ( $screen && 'toplevel_page_postaramail' === $screen->id ) { return; } echo '
' . wp_kses( sprintf( /* translators: %s: link to the PostaraMail screen */ __( 'PostaraMail is almost ready. Connect your account in one click to start collecting subscribers.', 'postaramail' ), esc_url( admin_url( 'admin.php?page=postaramail' ) ) ), array( 'strong' => array(), 'a' => array( 'href' => array() ), ) ) . '
' . __( 'When a visitor subscribes through a PostaraMail form, agrees to receive emails when registering or ordering, or answers “yes” to our email news question, their email address and name are sent to PostaraMail (postaramail.com, operated by PostaraAI LLC) so we can send them the emails they agreed to, together with the wording they agreed to. The visitor’s IP address may be passed on once, only to work out their country; PostaraMail keeps the country, not the IP address. Existing users of this site may be listed in PostaraMail as “not asked yet” and are not emailed until they say yes. This site keeps no subscriber list of its own. Every email includes an unsubscribe link.', 'postaramail' ) . '
' ) ); } } // ---------- Small helpers ---------- private static function url( $tab = 'overview', $extra = array() ) { return add_query_arg( array_merge( array( 'page' => 'postaramail', 'tab' => $tab, ), $extra ), admin_url( 'admin.php' ) ); } private static function post_url( $action ) { return admin_url( 'admin-post.php' ); } private static function form_open( $action, $tab ) { echo ''; } // ---------- Forms ---------- private static function tab_forms( $me ) { self::form_open( 'forms', 'forms' ); echo '' . esc_html__( 'Use the block “PostaraMail Signup Form” in the editor, or paste this shortcode into any page or post:', 'postaramail' ) . '
'; echo '[postaramail_form]' . esc_html__( 'Options:', 'postaramail' ) . ' title="Join the list" button="Subscribe" name="no" automation="12" color="#ff6a0d"
' . esc_html__( 'The form always asks for consent. Your privacy policy link is added automatically when your site has one.', 'postaramail' ) . '
'; echo '' . esc_html__( 'These people are never added silently. They are only added when they say “yes”.', 'postaramail' ) . '
'; echo '' . esc_html__( 'Ask these roles', 'postaramail' ) . '
' . sprintf( /* translators: %d: number */ esc_html__( 'Sending now: %d emails still to go (about 20 every 15 minutes).', 'postaramail' ), (int) $c['queued'] ) . '
'; } echo '' . esc_html__( 'Each person gets this once, ever, from your own site, with a Yes and a No link. If they do nothing they are not added and not asked again.', 'postaramail' ) . '
'; self::form_open( 'send_existing', 'existing' ); echo ''; echo '' . ( isset( $info['via'] ) && 'connect' === $info['via'] ? esc_html__( 'Connected with one click. This site can add contacts and read your automations, nothing else.', 'postaramail' ) : esc_html__( 'Connected with an API key.', 'postaramail' ) ) . '
'; echo '' . esc_html__( 'Only needed if one-click connect does not suit you. Create a key in PostaraMail under Settings → API keys (Pro and Scale plans).', 'postaramail' ) . '
'; echo '' . esc_html__( 'Leave blank to keep the current key.', 'postaramail' ) . '
'; echo '' . esc_html__( 'Leave blank unless support tells you otherwise. Must start with https://', 'postaramail' ) . '