Zodiac1978/html5-fallback-wpcf7

What is this if for?

Closed this issue · 3 comments

I'm wondering what this if should test.
get_locale() will return a string and so $ locale will always be set and not empty.

$locale = getJqueryUII18nLocale();
if ( $locale ) {
/* CDN */
//wp_enqueue_script( 'jquery-ui-i18n-'.$locale, 'http://jquery-ui.googlecode.com/svn/tags/latest/ui/i18n/jquery.ui.datepicker-'.$locale.'.js', array( 'jquery-ui-datepicker' ), $wp_jquery_ui_ver, true );
/* local */
wp_enqueue_script( 'jquery-ui-i18n-'.$locale, plugins_url( '/i18n/jquery.ui.datepicker-'.$locale.'.js' , __FILE__ ) , array( 'jquery-ui-datepicker' ), $wp_jquery_ui_ver, true );
}

$locale is empty when WP is set to English and there is no localization for the datepicker necessary.
See: https://github.com/Zodiac1978/html5-fallback-wpcf7/blob/master/html5-fallback-wpcf7.php#L72

Documentation for get_locale() is not so clean about it.

Then maybe write:

if ( ''  != $locale ) 

get_locale is not relevant here, it is line 72 of my own code (see my link above).

Your code enhancement is a good idea, but is doing exactly the same just better to read/understand.