Making WordPress.org

Changeset 8430


Ignore:
Timestamp:
03/09/2019 01:13:13 PM (7 years ago)
Author:
ocean90
Message:

Rosetta: Check if the provided locale exists before adding the association.

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/rosetta/inc/admin/network
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/rosetta/inc/admin/network/class-locale-associations-view.php

    r7174 r8430  
    7878                    '<div class="notice notice-error"><p>%s</p></div>',
    7979                    __( 'Please provide a locale and a subdomain.', 'rosetta' )
     80                );
     81                break;
     82            case 'add-association|locale_does_not_exist' :
     83                printf(
     84                    '<div class="notice notice-error"><p>%s</p></div>',
     85                    __( 'The locale does not exist yet.', 'rosetta' )
    8086                );
    8187                break;
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/rosetta/inc/admin/network/class-locale-associations.php

    r6641 r8430  
    119119        $subdomain = sanitize_text_field( $_POST['subdomain'] );
    120120
     121        if ( 0 !== strpos( $locale, 'test' ) ) {
     122            $locales = get_available_languages();
     123            if ( ! in_array( $locale, $locales, true ) ) {
     124                return new WP_Error( 'locale_does_not_exist' );
     125            }
     126        }
     127
    121128        $result = $wpdb->insert( Tables::LOCALES, [
    122129            'locale'    => $locale,
Note: See TracChangeset for help on using the changeset viewer.