Changeset 5339
- Timestamp:
- 04/15/2017 03:01:20 PM (7 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/rosetta/inc
- Files:
-
- 8 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/rosetta/inc/class-plugin.php
r4110 r5339 6 6 7 7 /** 8 * @var Plugin The singleton instance.8 * @var \WordPressdotorg\Rosetta\Plugin The singleton instance. 9 9 */ 10 10 private static $instance; … … 20 20 * Returns always the same instance of this plugin. 21 21 * 22 * @return Plugin22 * @return \WordPressdotorg\Rosetta\Plugin 23 23 */ 24 24 public static function get_instance() { -
sites/trunk/wordpress.org/public_html/wp-content/plugins/rosetta/inc/site/class-global-wordpress-org.php
r4096 r5339 2 2 namespace WordPressdotorg\Rosetta\Site; 3 3 4 use WordPressdotorg\Rosetta\Admin\Network\Locale_Associations; 5 use WordPressdotorg\Rosetta\Admin\Network\Locale_Associations_View; 6 use WordPressdotorg\Rosetta\Database\Tables; 4 7 use WordPressdotorg\Rosetta\Jetpack; 5 8 use WP_Site; … … 43 46 add_action( 'wpmu_new_blog', [ $jetpack_connector, 'schedule_connect_event' ], 20, 1 ); 44 47 add_action( $jetpack_connector->get_connect_event_name(), [ $jetpack_connector, 'connect_site' ] ); 48 49 add_action( 'wpmu_new_blog', [ $this, 'set_new_blog_lang_id' ], 30, 1 ); 50 51 add_action( 'network_admin_menu', function() { 52 $locale_associations = new Locale_Associations( new Locale_Associations_View() ); 53 $locale_associations->register(); 54 } ); 55 } 56 57 /** 58 * Sets 'lang_id' for new sites. 59 * 60 * @param int $blog_id ID of the new site. 61 */ 62 public function set_new_blog_lang_id( $blog_id ) { 63 global $wpdb; 64 65 $site = get_site( $blog_id ); 66 $subdomain = strtok( $site->domain, '.' ); 67 68 $lang_id = $wpdb->get_var( $wpdb->prepare( 'SELECT locale_id FROM ' . Tables::LOCALES . ' WHERE subdomain = %s', $subdomain ) ); 69 if ( ! $lang_id ) { 70 return; 71 } 72 73 update_blog_details( $blog_id, [ 'lang_id' => $lang_id ] ); 45 74 } 46 75 }
Note: See TracChangeset
for help on using the changeset viewer.