Skip to content

Function

Add the blog signup form fields.

tml_ms_add_blog_signup_form_fields( string $form )

Parameters

$form string
The form name.

Source

function tml_ms_add_blog_signup_form_fields( $form ) {
    $current_network = get_network();

    // phpcs:disable WordPress.WP.I18n.MissingArgDomain, WordPress.WP.I18n.MissingTranslatorsComment -- these messages intentionally reuse WP core's translated wp-signup.php strings verbatim, not TML-specific strings; no translators comments since they never enter TML's own .pot.
    if ( ! is_subdomain_install() ) {
        $control_after = '<br />';
        if ( ! is_user_logged_in() ) {
            $control_after .= '<p>(<strong>' . sprintf( __( 'Your address will be %s.' ), $current_network->domain . $current_network->path . __( 'sitename' ) ) . '</strong>) ';
            $control_after .= __( 'Must be at least 4 characters, letters and numbers only. It cannot be changed, so choose carefully!' ) . '</p>';
        }
        // phpcs:enable WordPress.WP.I18n.MissingArgDomain, WordPress.WP.I18n.MissingTranslatorsComment

        tml_add_form_field(
            $form,
            'blogname',
            array(
                'type'        => 'text',
                'label'       => __( 'Site Name (subdirectory only):' ), // phpcs:ignore WordPress.WP.I18n.MissingArgDomain -- reusing WP core's translated string (see wp-signup.php), not a TML-specific string.
                'value'       => '',
                'id'          => 'blogname',
                'attributes'  => array(
                    'maxlength' => 60,
                ),
                'priority'    => 10,
                'render_args' => array(
                    'control_before' => '<span class="prefix_address">' . $current_network->domain . $current_network->path . '</span>',
                    'control_after'  => $control_after,
                ),
            )
        );
    } else {
        // phpcs:disable WordPress.WP.I18n.MissingArgDomain, WordPress.WP.I18n.MissingTranslatorsComment -- these messages intentionally reuse WP core's translated wp-signup.php strings verbatim, not TML-specific strings; no translators comments since they never enter TML's own .pot.
        $site_domain   = preg_replace( '|^www\.|', '', $current_network->domain );
        $control_after = '<span class="suffix_address">.' . $site_domain . '</span><br />';
        if ( ! is_user_logged_in() ) {
            $control_after .= '<p>(<strong>' . sprintf( __( 'Your address will be %s.' ), __( 'domain' ) . '.' . $site_domain . $current_network->path ) . '</strong>) ';
            $control_after .= __( 'Must be at least 4 characters, letters and numbers only. It cannot be changed, so choose carefully!' ) . '</p>';
        }
        // phpcs:enable WordPress.WP.I18n.MissingArgDomain, WordPress.WP.I18n.MissingTranslatorsComment

        tml_add_form_field(
            $form,
            'blogname',
            array(
                'type'        => 'text',
                'label'       => __( 'Site Domain (subdomain only):' ), // phpcs:ignore WordPress.WP.I18n.MissingArgDomain -- reusing WP core's translated string (see wp-signup.php), not a TML-specific string.
                'value'       => '',
                'id'          => 'blogname',
                'attributes'  => array(
                    'maxlength' => 60,
                ),
                'priority'    => 10,
                'render_args' => array(
                    'control_after' => $control_after,
                ),
            )
        );
    }

    tml_add_form_field(
        $form,
        'blog_title',
        array(
            'type'     => 'text',
            'label'    => __( 'Site Title:' ), // phpcs:ignore WordPress.WP.I18n.MissingArgDomain -- reusing WP core's translated "Site Title:" string (see wp-signup.php), not a TML-specific string.
            'id'       => 'blog_title',
            'priority' => 15,
        )
    );

    $language_field = tml_ms_render_blog_signup_language_field();
    if ( $language_field ) {
        tml_add_form_field(
            $form,
            'site_language',
            array(
                'type'     => 'custom',
                'content'  => $language_field,
                'priority' => 20,
            )
        );
    }

    tml_add_form_field(
        $form,
        'blog_public',
        array(
            'type'        => 'radio-group',
            // phpcs:disable WordPress.WP.I18n.MissingArgDomain -- these labels intentionally reuse WP core's translated wp-signup.php strings verbatim, not TML-specific strings.
            'label'       => __( 'Privacy:' ),
            'value'       => isset( $_POST['blog_public'] ) && '0' === $_POST['blog_public'] ? 0 : 1, // phpcs:ignore WordPress.Security.NonceVerification.Missing -- read-only: pre-fills the field's default selection, not processed/acted on.
            'options'     => array(
                '1' => __( 'Yes' ),
                '0' => __( 'No' ),
            ),
            'priority'    => 25,
            'render_args' => array(
                'control_before' => __( 'Allow search engines to index this site.' ) . '<br style="clear:both" />',
            ),
            // phpcs:enable WordPress.WP.I18n.MissingArgDomain
        )
    );

    tml_add_form_field(
        $form,
        'signup_blogform',
        array(
            'type'        => 'action',
            'render_args' => array( tml_get_errors() ),
        )
    );
}

Uses

Used by

Changelog

VersionDescription
7.0 Introduced.