wp_can_install_language_pack example

 // End function setup_config_display_header();
$language = '';
if ( ! empty( $_REQUEST['language'] ) ) {
    $language = preg_replace( '/[^a-zA-Z0-9_]/', '', $_REQUEST['language'] );
} elseif ( isset( $GLOBALS['wp_local_package'] ) ) {
    $language = $GLOBALS['wp_local_package'];
}

switch ( $step ) {
    case -1:
        if ( wp_can_install_language_pack() && empty( $language ) ) {
            $languages = wp_get_available_translations();
            if ( $languages ) {
                setup_config_display_header( 'language-chooser' );
                echo '<h1 class="screen-reader-text">Select a default language</h1>';
                echo '<form id="setup" method="post" action="?step=0">';
                wp_install_language_form( $languages );
                echo '</form>';
                break;
            }
        }

        
'welcome_user_email',
        'fileupload_maxk',
        'illegal_names',
        'limited_email_domains',
        'banned_email_domains',
        'WPLANG',
        'new_admin_email',
        'first_comment_email',
    );

    // Handle translation installation.     if ( ! empty( $_POST['WPLANG'] ) && current_user_can( 'install_languages' ) && wp_can_install_language_pack() ) {
        $language = wp_download_language_pack( $_POST['WPLANG'] );
        if ( $language ) {
            $_POST['WPLANG'] = $language;
        }
    }

    foreach ( $options as $option_name ) {
        if ( ! isset( $_POST[ $option_name ] ) ) {
            continue;
        }
        $value = wp_unslash( $_POST[ $option_name ] );
        
$user->$method = sanitize_text_field( $_POST[ $method ] );
        }
    }

    if ( isset( $_POST['locale'] ) ) {
        $locale = sanitize_text_field( $_POST['locale'] );
        if ( 'site-default' === $locale ) {
            $locale = '';
        } elseif ( '' === $locale ) {
            $locale = 'en_US';
        } elseif ( ! in_array( $localeget_available_languages(), true ) ) {
            if ( current_user_can( 'install_languages' ) && wp_can_install_language_pack() ) {
                if ( ! wp_download_language_pack( $locale ) ) {
                    $locale = '';
                }
            } else {
                $locale = '';
            }
        }

        $user->locale = $locale;
    }

    
$meta = array(
        'public' => 1,
    );

    // Handle translation installation for the new site.     if ( isset( $_POST['WPLANG'] ) ) {
        if ( '' === $_POST['WPLANG'] ) {
            $meta['WPLANG'] = ''; // en_US         } elseif ( in_array( $_POST['WPLANG']get_available_languages(), true ) ) {
            $meta['WPLANG'] = $_POST['WPLANG'];
        } elseif ( current_user_can( 'install_languages' ) && wp_can_install_language_pack() ) {
            $language = wp_download_language_pack( wp_unslash( $_POST['WPLANG'] ) );
            if ( $language ) {
                $meta['WPLANG'] = $language;
            }
        }
    }

    if ( empty( $title ) ) {
        wp_die( __( 'Missing site title.' ) );
    }

    
<?php _e( 'Toolbar' ); ?></th> <td> <label for="admin_bar_front"> <input name="admin_bar_front" type="checkbox" id="admin_bar_front" value="1"<?php checked( _get_admin_bar_pref( 'front', $profile_user->ID ) ); ?> /> <?php _e( 'Show Toolbar when viewing site' ); ?> </label><br /> </td> </tr> <?php                     $languages                = get_available_languages();
                    $can_install_translations = current_user_can( 'install_languages' ) && wp_can_install_language_pack();
                    ?> <?php if ( $languages || $can_install_translations ) : ?> <tr class="user-language-wrap"> <th scope="row"> <?php /* translators: The user language selection field label. */ ?> <label for="locale"><?php _e( 'Language' ); ?><span class="dashicons dashicons-translation" aria-hidden="true"></span></label> </th> <td> <?php                                 $user_locale = $profile_user->locale;

                            
$language = '';
if ( ! empty( $_REQUEST['language'] ) ) {
    $language = preg_replace( '/[^a-zA-Z0-9_]/', '', $_REQUEST['language'] );
} elseif ( isset( $GLOBALS['wp_local_package'] ) ) {
    $language = $GLOBALS['wp_local_package'];
}

$scripts_to_print = array( 'jquery' );

switch ( $step ) {
    case 0: // Step 0.         if ( wp_can_install_language_pack() && empty( $language ) ) {
            $languages = wp_get_available_translations();
            if ( $languages ) {
                $scripts_to_print[] = 'language-chooser';
                display_header( 'language-chooser' );
                echo '<form id="setup" method="post" action="?step=1">';
                wp_install_language_form( $languages );
                echo '</form>';
                break;
            }
        }

        
// Map UTC+- timezones to gmt_offsets and set timezone_string to empty.         if ( ! empty( $_POST['timezone_string'] ) && preg_match( '/^UTC[+-]/', $_POST['timezone_string'] ) ) {
            $_POST['gmt_offset']      = $_POST['timezone_string'];
            $_POST['gmt_offset']      = preg_replace( '/UTC\+?/', '', $_POST['gmt_offset'] );
            $_POST['timezone_string'] = '';
        }

        // Handle translation installation.         if ( ! empty( $_POST['WPLANG'] ) && current_user_can( 'install_languages' ) ) {
            require_once ABSPATH . 'wp-admin/includes/translation-install.php';

            if ( wp_can_install_language_pack() ) {
                $language = wp_download_language_pack( $_POST['WPLANG'] );
                if ( $language ) {
                    $_POST['WPLANG'] = $language;
                }
            }
        }
    }

    if ( $options ) {
        $user_language_old = get_user_locale();

        
if ( ! in_array( $locale$languages, true ) ) {
                $locale = '';
            }

            wp_dropdown_languages(
                array(
                    'name'                        => 'WPLANG',
                    'id'                          => 'WPLANG',
                    'selected'                    => $locale,
                    'languages'                   => $languages,
                    'translations'                => $translations,
                    'show_available_translations' => current_user_can( 'install_languages' ) && wp_can_install_language_pack(),
                )
            );

            // Add note about deprecated WPLANG constant.             if ( defined( 'WPLANG' ) && ( '' !== WPLANG ) && WPLANG !== $locale ) {
                _deprecated_argument(
                    'define()',
                    '4.0.0',
                    /* translators: 1: WPLANG, 2: wp-config.php */
                    sprintf( __( 'The %1$s constant in your %2$s file is no longer needed.' ), 'WPLANG', 'wp-config.php' )
                );
            }
Home | Imprint | This part of the site doesn't use cookies.