Changeset 7097 for trunk/bp-core/bp-core-functions.php
- Timestamp:
- 05/22/2013 11:24:01 PM (13 years ago)
- File:
-
- 1 edited
-
trunk/bp-core/bp-core-functions.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core/bp-core-functions.php
r7093 r7097 1268 1268 */ 1269 1269 function bp_core_load_buddypress_textdomain() { 1270 $locale = apply_filters( 'buddypress_locale', get_locale() ); 1271 $mofile = sprintf( 'buddypress-%s.mo', $locale ); 1272 $mofile_global = WP_LANG_DIR . '/' . $mofile; 1273 $mofile_local = BP_PLUGIN_DIR . 'bp-languages/' . $mofile; 1274 1275 if ( file_exists( $mofile_global ) ) 1276 return load_textdomain( 'buddypress', $mofile_global ); 1277 elseif ( file_exists( $mofile_local ) ) 1278 return load_textdomain( 'buddypress', $mofile_local ); 1279 else 1280 return false; 1281 } 1282 add_action ( 'bp_core_loaded', 'bp_core_load_buddypress_textdomain' ); 1270 $locale = apply_filters( 'buddypress_locale', get_locale() ); 1271 $mofile = sprintf( 'buddypress-%s.mo', $locale ); 1272 $uploads_dir = wp_upload_dir(); 1273 1274 $translation_paths = array( 1275 WP_LANG_DIR . "/{$mofile}", 1276 BP_PLUGIN_DIR . "bp-languages/{$mofile}", 1277 $uploads_dir['basedir'] . "/buddypress/{$mofile}", 1278 ); 1279 1280 foreach ( $translation_paths as $path ) 1281 load_textdomain( 'buddypress', $path ); 1282 } 1283 add_action( 'bp_core_loaded', 'bp_core_load_buddypress_textdomain' ); 1283 1284 1284 1285 /** … … 1361 1362 } 1362 1363 add_action( 'wp_footer', 'bp_core_print_generation_time' ); 1364 1365 /** 1366 * Find out if there's a newer translation available for this site on translate.wordpress.org 1367 * 1368 * @since BuddyPress (1.8) 1369 */ 1370 function bp_core_check_for_updated_translation() { 1371 require( buddypress()->plugin_dir . 'bp-core/admin/bp-core-translations.php' ); 1372 1373 $locale = BP_Translate::get_locale(); 1374 if ( 'en_US' === $locale ) 1375 return; 1376 1377 // No point checking if we know there's an updated translation 1378 if ( bp_is_translation_update_pending() ) 1379 return; 1380 1381 $locale = BP_Translate::get_glotpress_locale(); 1382 if ( ! $locale ) 1383 return; 1384 1385 $url = 'https://translate.wordpress.org/projects/buddypress/%1$s/%2$s/default/export-translations?format=mo'; 1386 $args = bp_get_translation_version() ? array( 'headers' => 'If-Modified-Since: ' . gmdate( 'D, d M Y H:i:s', bp_get_translation_version() ) . ' GMT' ) : array(); 1387 1388 // Check version of translation on translate.wordpress.org 1389 $response = wp_remote_head( sprintf( $url, buddypress()->glotpress_version, $locale ), $args ); 1390 if ( is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) === 304 || wp_remote_retrieve_response_code( $response ) !== 200 ) 1391 return; 1392 1393 // An updated translation is available 1394 bp_update_option( '_bp_translation_pending', true ); 1395 } 1396 add_action( 'bp_translate_update_check', 'bp_core_check_for_updated_translation' );
Note: See TracChangeset
for help on using the changeset viewer.