'dashicons-building', 'abn_addon' => 'dashicons-plus-alt', 'abn_registration' => 'dashicons-id', 'business_name' => 'dashicons-store', 'ppsr_search' => 'dashicons-search', 'entity_monitoring' => 'dashicons-visibility', ); public function __construct( private readonly Plugin $plugin ) {} public static function url( array $args = array() ): string { return add_query_arg( array_merge( array( 'page' => self::SLUG ), $args ), admin_url( 'admin.php' ) ); } /** * @return array Tab slug => label. */ public static function tabs(): array { return array( 'connection' => __( 'Connection', 'businessapi-forms' ), 'products' => __( 'Products', 'businessapi-forms' ), 'notices' => __( 'ASIC notices', 'businessapi-forms' ), 'appearance' => __( 'Appearance', 'businessapi-forms' ), 'security' => __( 'Security', 'businessapi-forms' ), 'help' => __( 'Help', 'businessapi-forms' ), ); } public function register(): void { add_action( 'admin_menu', array( $this, 'menu' ) ); add_action( 'admin_post_' . self::SAVE_ACTION, array( $this, 'save' ) ); add_action( 'admin_post_' . self::REFRESH_ACTION, array( $this, 'refresh' ) ); add_action( 'admin_post_' . self::SITE_ACTION, array( $this, 'register_site' ) ); add_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ) ); add_filter( 'plugin_action_links_' . plugin_basename( BAPI_FORMS_FILE ), array( $this, 'action_links' ) ); } public function menu(): void { add_menu_page( __( 'BusinessAPI Forms', 'businessapi-forms' ), __( 'BusinessAPI Forms', 'businessapi-forms' ), 'manage_options', self::SLUG, array( $this, 'render' ), 'dashicons-building', 56 ); } /** Styles and script of this screen only, plus the colour picker on the Appearance tab. */ public function enqueue(): void { if ( self::SLUG !== ( isset( $_GET['page'] ) ? sanitize_key( wp_unslash( $_GET['page'] ) ) : '' ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended return; } $deps = array(); if ( 'appearance' === $this->current_tab() ) { wp_enqueue_style( 'wp-color-picker' ); $deps = array( 'jquery', 'wp-color-picker' ); } wp_enqueue_style( 'bapi-forms-admin', BAPI_FORMS_URL . 'assets/css/admin.css', array(), BAPI_FORMS_VERSION ); wp_enqueue_script( 'bapi-forms-admin', BAPI_FORMS_URL . 'assets/js/admin.js', $deps, BAPI_FORMS_VERSION, array( 'in_footer' => true ) ); wp_localize_script( 'bapi-forms-admin', 'bapiFormsAdmin', array( /* translators: 1: "White" or "Dark", 2: APCA contrast value, 3: the other text colour. */ 'lowText' => __( '%1$s text is hard to read on this colour (APCA Lc %2$s, under 45). Consider %3$s text or a different accent colour.', 'businessapi-forms' ), /* translators: %s: contrast ratio. */ 'fillText' => __( 'This colour is light on white (contrast %s:1, under 3:1), so buttons, selected options and focus rings may be hard to see. Text in the accent colour (links, step names) is darkened automatically to stay readable.', 'businessapi-forms' ), 'white' => Options::WHITE_TEXT, 'dark' => Options::DARK_TEXT, 'whiteName' => __( 'White', 'businessapi-forms' ), 'darkName' => __( 'Dark', 'businessapi-forms' ), 'bias' => Options::APCA_WHITE_BIAS, 'copied' => __( 'Copied', 'businessapi-forms' ), ) ); } public function action_links( array $links ): array { array_unshift( $links, sprintf( '%s', esc_url( self::url() ), esc_html__( 'Settings', 'businessapi-forms' ) ) ); return $links; } private function current_tab(): string { $tab = isset( $_GET['tab'] ) ? sanitize_key( wp_unslash( $_GET['tab'] ) ) : 'connection'; // phpcs:ignore WordPress.Security.NonceVerification.Recommended return isset( self::tabs()[ $tab ] ) ? $tab : 'connection'; } public function save(): void { if ( ! current_user_can( 'manage_options' ) ) { wp_die( esc_html__( 'You are not allowed to do this.', 'businessapi-forms' ), 403 ); } check_admin_referer( self::SAVE_ACTION ); $tab = isset( $_POST['tab'] ) ? sanitize_key( wp_unslash( $_POST['tab'] ) ) : ''; $errors = match ( $tab ) { 'connection' => $this->save_connection(), 'products' => $this->save_products(), 'notices' => $this->save_notices(), 'appearance' => $this->save_appearance(), default => array(), }; set_transient( 'bapi_forms_notice_' . get_current_user_id(), array( 'errors' => $errors ), 60 ); wp_safe_redirect( self::url( array( 'tab' => '' !== (string) $tab ? $tab : 'connection', 'updated' => 1, ) ) ); exit; } /** @return list */ private function save_connection(): array { $options = $this->plugin->options; $previous = $options->environment(); $errors = array(); $environment = isset( $_POST['environment'] ) && Options::ENV_LIVE === $_POST['environment'] ? Options::ENV_LIVE : Options::ENV_TEST; // phpcs:ignore WordPress.Security.NonceVerification.Missing -- verified in save(). $settings = array( 'environment' => $environment ); // Visitor protection (Connection tab). $cap = isset( $_POST['session_cap'] ) ? absint( wp_unslash( $_POST['session_cap'] ) ) : Options::DEFAULT_SESSION_CAP; // phpcs:ignore WordPress.Security.NonceVerification.Missing $settings['session_cap'] = min( $cap, 100000 ); $header = isset( $_POST['proxy_header'] ) ? sanitize_text_field( wp_unslash( $_POST['proxy_header'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Missing $settings['proxy_header'] = isset( Options::PROXY_HEADERS[ $header ] ) ? $header : ''; $hops = isset( $_POST['proxy_hops'] ) ? absint( wp_unslash( $_POST['proxy_hops'] ) ) : 1; // phpcs:ignore WordPress.Security.NonceVerification.Missing $settings['proxy_hops'] = min( Options::MAX_PROXY_HOPS, max( 1, $hops ) ); // Live never sells at $0: every enabled product needs a service price first. $unpriced = Options::ENV_LIVE === $environment ? $this->plugin->products->unpriced() : array(); if ( $unpriced ) { $settings['environment'] = $previous; $labels = array_map( fn ( $slug ) => (string) ( $this->plugin->products->all()[ $slug ]['label'] ?? $slug ), $unpriced ); $errors[] = sprintf( /* translators: %s: product names. */ __( 'Live mode was not switched on: these enabled products have no service price above $0 yet: %s.', 'businessapi-forms' ), implode( ', ', $labels ) ); $environment = $previous; } // Live needs 2FA for every admin and shop manager, the required checks and a clean plugin. $blockers = Options::ENV_LIVE === $environment && Options::ENV_LIVE !== $previous ? $this->plugin->security->live_blockers() : array(); if ( $blockers ) { $settings['environment'] = $previous; $environment = $previous; $errors[] = __( 'Live mode was not switched on:', 'businessapi-forms' ) . ' ' . implode( ' ', $blockers ); } // API keys: blank keeps the stored key, "remove" clears it. foreach ( array( Options::ENV_TEST, Options::ENV_LIVE ) as $env ) { $field = $env . '_key'; if ( ! empty( $_POST[ 'remove_' . $field ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing $settings[ $field ] = ''; continue; } $value = isset( $_POST[ $field ] ) ? trim( sanitize_text_field( wp_unslash( $_POST[ $field ] ) ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Missing if ( '' === $value ) { continue; } if ( ! Options::key_matches_environment( $value, $env ) ) { $errors[] = sprintf( /* translators: 1: environment name, 2: expected key prefix. */ __( 'The %1$s key was not saved. It must be a secret key starting with %2$s.', 'businessapi-forms' ), $env, 'bapi_sk_' . $env . '_' ); continue; } $settings[ $field ] = $value; } $this->plugin->prices->flush(); // The old key's cached prices. $options->update( $settings ); $this->plugin->capabilities->flush(); $this->plugin->prices->flush(); // First connection: register this site and server IP with Business API. foreach ( array( Options::ENV_TEST, Options::ENV_LIVE ) as $env ) { if ( empty( $settings[ $env . '_key' ] ) ) { continue; } $registered = $this->plugin->sites->register_if_missing( $env ); if ( null !== $registered && ! $registered->ok() ) { /* translators: %s: error from Business API. */ $errors[] = sprintf( __( 'This website could not be registered with Business API: %s', 'businessapi-forms' ), (string) $registered->error ); } elseif ( null !== $registered && 'rate_limited' === ( $registered->data['email'] ?? null ) ) { $errors[] = __( 'This website was registered, but Business API did not send another confirmation email yet. Please wait before requesting another email.', 'businessapi-forms' ); } } if ( $environment !== $previous && ! $options->has_key( $environment ) ) { $errors[] = __( 'There is no API key for the selected environment yet, so forms will not be served.', 'businessapi-forms' ); } return $errors; } /** @return list */ private function save_products(): array { // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- nonce verified in save(); only the keys are used, each through sanitize_key(). $submitted = isset( $_POST['products'] ) && is_array( $_POST['products'] ) ? array_map( 'sanitize_key', array_keys( wp_unslash( $_POST['products'] ) ) ) : array(); $products = array(); // Prices first, so a product priced in the same save can be switched on live. // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- verified in save(); each value cast below. $posted = isset( $_POST['pricing'] ) && is_array( $_POST['pricing'] ) ? wp_unslash( $_POST['pricing'] ) : array(); $pricing = array(); $errors = array(); foreach ( $this->plugin->products->all() as $slug => $product ) { $row = isset( $posted[ $slug ] ) && is_array( $posted[ $slug ] ) ? $posted[ $slug ] : array(); $raw = isset( $row['service'] ) && is_string( $row['service'] ) ? trim( str_replace( array( '$', ',' ), '', $row['service'] ) ) : ''; $service = '' === $raw ? 0.0 : ( is_numeric( $raw ) ? round( (float) $raw, 2 ) : -1.0 ); if ( $service < 0 || $service > 100000 ) { /* translators: %s: product name. */ $errors[] = sprintf( __( '%s: enter a service fee between $0 and $100,000.', 'businessapi-forms' ), $product['label'] ); $service = $this->plugin->options->service_fee( $slug ); } $pricing[ $slug ] = array( 'service' => $service ); } $this->plugin->options->update( array( 'pricing' => $pricing ) ); // In live mode, products that cannot be lodged live cannot be switched on. foreach ( array_keys( $this->plugin->products->all() ) as $slug ) { $wanted = in_array( $slug, $submitted, true ); $products[ $slug ] = $wanted && $this->plugin->products->eligibility( $slug )['allowed']; } // Add-ons follow their product. Pay first needs WooCommerce and, live, a service fee above $0. // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- verified in save(); values compared below. $posted_flows = isset( $_POST['flows'] ) && is_array( $_POST['flows'] ) ? wp_unslash( $_POST['flows'] ) : array(); $flows = array(); $woo = class_exists( 'WooCommerce' ) && $this->plugin->commerce->has_active(); foreach ( $this->plugin->products->all() as $slug => $product ) { if ( ! empty( $product['requires'] ) || Options::FLOW_PAY_FIRST !== ( $posted_flows[ $slug ] ?? '' ) ) { continue; } if ( ! $woo ) { /* translators: %s: product name. */ $errors[] = sprintf( __( '%s: "Pay first" needs WooCommerce. Kept on form first.', 'businessapi-forms' ), $product['label'] ); continue; } if ( $this->plugin->options->is_live() && $pricing[ $slug ]['service'] <= 0 ) { /* translators: %s: product name. */ $errors[] = sprintf( __( '%s: "Pay first" needs a service fee above $0 in live mode. Kept on form first.', 'businessapi-forms' ), $product['label'] ); continue; } $flows[ $slug ] = Options::FLOW_PAY_FIRST; } $this->plugin->options->update( array( 'products' => $products, 'flows' => $flows, 'release_offline' => ! empty( $_POST['release_offline'] ), // phpcs:ignore WordPress.Security.NonceVerification.Missing -- verified in save(). ) ); if ( $woo && class_exists( \BapiForms\Commerce\WooCommerce\PayFirstProducts::class ) ) { \BapiForms\Commerce\WooCommerce\PayFirstProducts::sync( 20 ); } return $errors; } /** @return list */ private function save_notices(): array { $fields = array( 'email', 'mobile', 'unit', 'street_number', 'street_name', 'street_type', 'suburb', 'state', 'postcode' ); $posted = isset( $_POST['asic_notices'] ) && is_array( $_POST['asic_notices'] ) ? wp_unslash( $_POST['asic_notices'] ) : array(); // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- sanitised per field below. $notices = array( 'mode' => isset( $posted['mode'] ) && Options::NOTICES_PARTNER === $posted['mode'] ? Options::NOTICES_PARTNER : Options::NOTICES_CLIENT ); foreach ( $fields as $field ) { $value = isset( $posted[ $field ] ) && is_string( $posted[ $field ] ) ? trim( sanitize_text_field( $posted[ $field ] ) ) : ''; if ( 'email' === $field ) { $value = sanitize_email( $value ); } elseif ( 'mobile' === $field ) { $value = (string) preg_replace( '/[\s()-]/', '', $value ); } elseif ( in_array( $field, array( 'state', 'street_type', 'street_name', 'suburb' ), true ) ) { $value = strtoupper( $value ); } $notices[ $field ] = $value; } $errors = Options::NOTICES_PARTNER === $notices['mode'] ? Options::validate_service_details( $notices ) : array(); if ( $errors ) { // Keep the previous ASIC notice settings untouched. return array_merge( array( __( 'ASIC notice settings were not saved:', 'businessapi-forms' ) ), $errors ); } $this->plugin->options->update( array( 'asic_notices' => $notices ) ); return array(); } /** @return list */ private function save_appearance(): array { $posted = isset( $_POST['branding'] ) && is_array( $_POST['branding'] ) ? wp_unslash( $_POST['branding'] ) : array(); // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- verified in save(), validated below. $input = array(); foreach ( array_keys( Options::BRANDING_DEFAULTS ) as $field ) { $input[ $field ] = isset( $posted[ $field ] ) && is_string( $posted[ $field ] ) ? sanitize_text_field( $posted[ $field ] ) : ''; } [ $clean, $errors ] = Options::validate_branding( $input ); if ( $errors ) { return array_merge( array( __( 'Appearance was not saved:', 'businessapi-forms' ) ), $errors ); } $this->plugin->options->update( array( 'branding' => $clean ) ); return array(); } /** "Register this site" on the Connection tab. */ public function register_site(): void { if ( ! current_user_can( 'manage_options' ) ) { wp_die( esc_html__( 'You are not allowed to do this.', 'businessapi-forms' ), 403 ); } check_admin_referer( self::SITE_ACTION ); $response = $this->plugin->sites->register(); $errors = $response->ok() ? array() : array( /* translators: %s: error from Business API. */ sprintf( __( 'This website could not be registered with Business API: %s', 'businessapi-forms' ), (string) $response->error ), ); set_transient( 'bapi_forms_notice_' . get_current_user_id(), array( 'errors' => $errors, 'email' => $response->ok() ? self::email_result( $response->data['email'] ?? null ) : null, ), 60 ); wp_safe_redirect( self::url( array( 'tab' => 'connection', 'registered' => $response->ok() ? 1 : 0, ) ) ); exit; } public function refresh(): void { if ( ! current_user_can( 'manage_options' ) ) { wp_die( esc_html__( 'You are not allowed to do this.', 'businessapi-forms' ), 403 ); } check_admin_referer( self::REFRESH_ACTION ); $this->plugin->capabilities->flush(); $this->plugin->prices->flush(); // Stale notices: re-learnt on the next refused call. delete_option( Sites::REFUSED_IP_OPTION ); delete_transient( 'bapi_forms_notice_' . get_current_user_id() ); $tab = isset( $_POST['tab'] ) ? sanitize_key( wp_unslash( $_POST['tab'] ) ) : 'connection'; wp_safe_redirect( self::url( array( 'tab' => $tab, 'refreshed' => 1, ) ) ); exit; } public function render(): void { if ( ! current_user_can( 'manage_options' ) ) { return; } $tab = $this->current_tab(); $notice = get_transient( 'bapi_forms_notice_' . get_current_user_id() ); delete_transient( 'bapi_forms_notice_' . get_current_user_id() ); ?>

render_environment_badge(); ?> render_messages( is_array( $notice ) ? $notice : array() ); ?> plugin ) )->render_content(); } elseif ( 'security' === $tab ) { ( new \BapiForms\Security\SecurityTab( $this->plugin->security ) )->render(); } else { $this->render_form( $tab ); } ?>
$this->render_products(), 'notices' => $this->render_notices(), 'appearance' => $this->render_appearance(), default => $this->render_connection(), }; submit_button( __( 'Save changes', 'businessapi-forms' ) ); ?>
plugin->options->has_key() ) { $this->render_website(); } ?> plugin->options->has_key() ) : ?>
plugin->options->is_live(); printf( '%s', $live ? 'bapi-forms-badge-live' : 'bapi-forms-badge-sandbox', $live ? esc_html__( 'Live', 'businessapi-forms' ) : esc_html__( 'Sandbox', 'businessapi-forms' ) ); } /** The /embed-sites `email` result: sent, rate_limited or null. */ private static function email_result( mixed $email ): ?string { return in_array( $email, array( 'sent', 'rate_limited' ), true ) ? $email : null; } private function render_messages( array $notice ): void { foreach ( $notice['errors'] ?? array() as $error ) { printf( '

%s

', esc_html( $error ) ); } if ( isset( $_GET['updated'] ) && empty( $notice['errors'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended printf( '

%s

', esc_html__( 'Settings saved.', 'businessapi-forms' ) ); } if ( ! empty( $_GET['registered'] ) && empty( $notice['errors'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended $email = $notice['email'] ?? null; if ( 'rate_limited' === $email ) { printf( '

%s

', esc_html__( 'Registered, but no new email was sent: Business API already sent several confirmation emails this hour. Please wait before requesting another email, or use the link in the last one.', 'businessapi-forms' ) ); } elseif ( 'sent' === $email ) { printf( '

%s

', esc_html__( 'Confirmation email sent to your Business API account owner. New entries work once the link in it is confirmed.', 'businessapi-forms' ) ); } else { $message = $this->plugin->options->is_live() ? __( 'Registered. Nothing new needed confirming.', 'businessapi-forms' ) : __( 'Registered for sandbox.', 'businessapi-forms' ); printf( '

%s

', esc_html( $message ) ); } } if ( isset( $_GET['refreshed'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended printf( '

%s

', esc_html__( 'Account status refreshed.', 'businessapi-forms' ) ); } } private function render_connection(): void { $options = $this->plugin->options; $environment = $options->environment(); $status = $options->has_key() ? $this->plugin->capabilities->status() : null; ?>

render_key_row( Options::ENV_TEST, __( 'Sandbox API key', 'businessapi-forms' ) ); ?> render_key_row( Options::ENV_LIVE, __( 'Live API key', 'businessapi-forms' ) ); ?>

plugin->sites->status(); $pill = static function ( string $status ): void { $map = array( Sites::ACTIVE => array( 'bapi-forms-ok', __( 'Active', 'businessapi-forms' ) ), Sites::PENDING => array( 'bapi-forms-warn', __( 'Awaiting email confirmation', 'businessapi-forms' ) ), Sites::NOT_REGISTERED => array( 'bapi-forms-error', __( 'Not registered', 'businessapi-forms' ) ), ); [ $class, $label ] = $map[ $status ] ?? $map[ Sites::NOT_REGISTERED ]; printf( '%s', esc_attr( $class ), esc_html( $label ) ); }; $complete = Sites::ACTIVE === $site['domain_status'] && Sites::ACTIVE === $site['ip_status']; ?>

plugin->options; $field = $environment . '_key'; $stored = $options->key( $environment ); ?> environment() === $environment ? '' : 'hidden'; ?>> key_is_constant( $environment ) ) : ?>

%s', esc_html__( 'No API key for this environment', 'businessapi-forms' ) ); return; } if ( ! $status['ok'] ) { printf( '%s %s', esc_html__( 'Not connected', 'businessapi-forms' ), esc_html( (string) $status['error'] ) ); return; } $name = trim( (string) ( $status['account']['companyName'] ?? '' ) ); $name = '' !== $name ? $name : (string) ( $status['account']['accountName'] ?? '' ); printf( '%s %s', esc_html__( 'Connected', 'businessapi-forms' ), esc_html( sprintf( /* translators: 1: account name, 2: time of last check. */ __( 'as %1$s (checked %2$s ago)', 'businessapi-forms' ), $name, human_time_diff( (int) $status['checked_at'] ) ) ) ); if ( false === ( $status['forms_enabled'] ?? null ) ) { printf( '

%s %s %s

', esc_html__( 'Forms not enabled', 'businessapi-forms' ), esc_html( \BapiForms\Account\Capabilities::forms_disabled_message() ), esc_url( \BapiForms\Frontend\RestController::bapi_origin() . '/dashboard' ), esc_html__( 'Open your Business API dashboard', 'businessapi-forms' ) ); } if ( ! $this->plugin->commerce->has_active() ) { printf( '

%s

', esc_html( sprintf( /* translators: %s: approved ecommerce plugins. */ __( 'Forms are not served until an approved ecommerce plugin is active (%s).', 'businessapi-forms' ), $this->plugin->commerce->approved_labels() ) ) ); } } private function render_products(): void { $registry = $this->plugin->products; $enabled = $this->plugin->options->enabled_products(); $is_live = $this->plugin->options->is_live(); $preview = array(); // Sandbox: preview live readiness so partners know what to sort out before going live. if ( ! $is_live && $this->plugin->options->has_key() ) { $preview = $this->plugin->capabilities->status()['products'] ?? array(); } ?>

all() as $slug => $product ) : ?> eligibility( $slug ); $allowed = $eligibility['allowed']; $checked = $allowed && ! empty( $enabled[ $slug ] ); $parent = $product['requires'] ? ( $registry->all()[ $product['requires'] ]['label'] ?? $product['requires'] ) : null; $live = $is_live ? null : ( $preview[ $product['capability'] ] ?? null ); $id = 'product-' . $slug; ?>

render_price_row( $slug ); ?> render_flow_row( $slug, $product ); ?>

$product Product definition. */ private function render_flow_row( string $slug, array $product ): void { $id = 'flow-' . $slug; if ( ! empty( $product['requires'] ) ) { $parent = (string) ( $this->plugin->products->all()[ $product['requires'] ]['label'] ?? $product['requires'] ); /* translators: %s: parent product name. */ echo '

' . esc_html( sprintf( __( 'When clients pay: follows %s.', 'businessapi-forms' ), $parent ) ) . '

'; return; } $flow = $this->plugin->options->flow( $slug ); ?>

get_status() ) { ?>

|

' . esc_html__( 'The shop product appears once this product is switched on and saved.', 'businessapi-forms' ) . '

'; } } /** * Service fee input, government fee (information or pass-through) and the partner's own * Business API cost and margin, for one product card. Margin is ex GST, assuming 10% GST. */ private function render_price_row( string $slug ): void { $options = $this->plugin->options; $prices = $this->plugin->prices; $service = $options->service_fee( $slug ); $your = $prices->your_price( $slug ); $money = static fn( float $v ): string => ( $v < 0 ? '-$' : '$' ) . number_format( abs( $v ), 2 ); $ex_gst = static fn( float $v ): float => $v / 1.1; // Taxes off in WooCommerce: no GST is charged or claimed, so no GST maths at all. $taxes = function_exists( 'wc_tax_enabled' ) && wc_tax_enabled(); $entered = $taxes && function_exists( 'wc_prices_include_tax' ) && wc_prices_include_tax(); $net = $entered ? $ex_gst( $service ) : $service; $asic = in_array( $slug, PriceList::ASIC_PAID_BY_PARTNER, true ); $by_bapi = in_array( $slug, PriceList::CHARGED_BY_BAPI, true ); $terms = 'business_name' === $slug ? PriceList::BN_TERMS : array( 0 ); $id = 'price-' . $slug; ?>

$

government_fee( $slug, array( 'company' => PriceList::V1_COMPANY_KEY ) ); if ( null !== $fee ) { /* translators: %s: amount. */ $fees[] = sprintf( __( '%s (proprietary company)', 'businessapi-forms' ), $money( $fee ) ); } } else { foreach ( $terms as $term ) { $fee = $prices->government_fee( $slug, array( 'term' => $term ? $term : 3 ) ); if ( null !== $fee ) { /* translators: 1: number of years, 2: amount. */ $fees[] = $term ? sprintf( __( '%1$d year %2$s', 'businessapi-forms' ), $term, $money( $fee ) ) : $money( $fee ); } } } $fee_text = $fees ? implode( '; ', $fees ) : __( 'unavailable right now', 'businessapi-forms' ); if ( $asic ) { /* translators: %s: fee amounts. */ echo esc_html( sprintf( __( 'ASIC fee %s, charged to your client at cost (ASIC bills you directly). Added automatically as a separate GST-free fee for each application.', 'businessapi-forms' ), $fee_text ) ); if ( 'company_registration' === $slug ) { echo ' ' . esc_html__( 'The form registers proprietary companies (Pty Ltd) only.', 'businessapi-forms' ); } } else { /* translators: %s: fee amount. */ echo esc_html( sprintf( __( 'PPSR search fee %s, charged to your client at cost (Business API bills you at cost). Added automatically as a separate GST-free fee for each application.', 'businessapi-forms' ), $fee_text ) ); } ?>

' . esc_html( $money( $taxes ? $net - $ex_gst( $your ) : $service - $your ) ) . '' ); } ?>

plugin->options->asic_notices(); $name = static fn( string $field ): string => 'asic_notices[' . $field . ']'; $hidden = Options::NOTICES_PARTNER === $notices['mode'] ? '' : ' hidden'; $text = function ( string $field, string $label, array $extra = array() ) use ( $notices, $name, $hidden ): void { $attrs = ''; foreach ( $extra as $attr => $value ) { $attrs .= sprintf( ' %s="%s"', esc_attr( $attr ), esc_attr( $value ) ); } printf( '', esc_attr( $field ), esc_html( $label ), esc_attr( $name( $field ) ), esc_attr( $notices[ $field ] ), $attrs, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- each name and value escaped above. '' === $hidden ? '' : ' hidden' ); }; ?>

'email', 'inputmode' => 'email', ) ); $text( 'mobile', __( 'Service mobile (optional)', 'businessapi-forms' ), array( 'autocomplete' => 'tel', 'inputmode' => 'tel', ) ); $text( 'unit', __( 'Unit / office (optional)', 'businessapi-forms' ) ); $text( 'street_number', __( 'Street number', 'businessapi-forms' ) ); $text( 'street_name', __( 'Street name', 'businessapi-forms' ) ); $text( 'street_type', __( 'Street type (e.g. ST, RD)', 'businessapi-forms' ) ); $text( 'suburb', __( 'Suburb', 'businessapi-forms' ) ); ?> > 'numeric', 'maxlength' => '4', 'pattern' => '[0-9]{4}', ) ); ?>
plugin->options->branding(); $primary = '' !== $branding['primary'] ? $branding['primary'] : self::DEFAULT_PRIMARY; $radius = '' !== $branding['radius'] ? $branding['radius'] : '8'; // '' follows the APCA recommendation (worked out by admin.js and by Business API). $on_primary = $branding['on_primary']; $text_labels = array( Options::WHITE_TEXT => __( 'White', 'businessapi-forms' ), Options::DARK_TEXT => __( 'Dark', 'businessapi-forms' ), ); ?>