Cannot set language in Edit Site view
-
This is a bug report with a potential fix.
In my multisite configuration, when attempting to set the Language (or any field) under the MultilingualPress tab within Network Admin > Sites > Edit Site, the behavior appears broken. Upon clicking “Save Changes,” the fields are always changed on the “main/first” site with an id of 1 and not the site actually being edited.
I tracked this down to code within Mlp_Network_Site_Settings_Controller. The function get_blog_id() only gets the correct blog id with GET requests while updating site settings happens with a POST with no query params to /wp-admin/admin-post.php. When no site id is found, the function defaults to get_current_blog_id(), which in the Network Admin panel, is almost always 1.
I fixed this issue with the following patch to Mlp_Network_Site_Settings_Controller.
/** * @return int */ private function get_blog_id() { $blog_id = absint( filter_input( INPUT_GET, 'id' ) ); if ($blog_id === 0) { $blog_id = absint( filter_input( INPUT_POST, 'id' ) ); } return $blog_id ? $blog_id : get_current_blog_id(); }
If the site id doesn’t exist within GET, it will look in the POST.
Thanks.
- The topic ‘Cannot set language in Edit Site view’ is closed to new replies.