Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Link to create new translation from edit screen is broken for pages #184

Closed
hatsumatsu opened this issue May 27, 2022 · 6 comments
Closed
Assignees
Labels

Comments

@hatsumatsu
Copy link
Contributor

Describe the bug

In v2.5.4 the link to create a new translation for a page in the edit screen seems to be broken. When creating/editing a page the link next to the select/search field for remote posts points to /wp-admin/post-new.php instead of /wp-admin/post-new.php?post_type=page.

To Reproduce
Steps to reproduce the behavior:

  1. Create a new page
  2. Click on the flag icon in the MSLS meta box next to the select field to create a new translation in a remote site.
  3. The link points to the New post screen in the remote site instead of the New page screen

Expected behaviour
The link points to /wp-admin/post-new.php?post_type=page

Screenshots

Environment (please complete the following information):

  • Plugin Version 2.5.4
@lloc lloc self-assigned this May 30, 2022
@lloc lloc added the Bug label May 30, 2022
@lloc
Copy link
Owner

lloc commented Jun 1, 2022

@hatsumatsu I believe that the fix in 2.5.5 solved that problem, right?

@hatsumatsu
Copy link
Contributor Author

@lloc In a quick test it appears that 2.5.5 is affected, too.

@hatsumatsu
Copy link
Contributor Author

@lloc were you able to reproduce the problem in 2.5.5 or is there anything I can help fixing it?

@arnowelzel
Copy link
Contributor

arnowelzel commented Sep 4, 2022

I have the same problem with 2.5.5 - and it does not only affect pages but all posts which are not "post" type, since the parameter post_type is always missing for the "new" button if the post is saved and not a new one.

Also see https://wordpress.org/support/topic/bug-adding-translation-for-saved-pages-always-links-to-post-as-type

@arnowelzel
Copy link
Contributor

I isolated the cause for this, but I don't have a solution yet.

\lloc\Msls\MslsAdminIcon::create uses \lloc\Msls\MslsPostType::get_request to determine the post type using the following code:

	/**
	 * @return string
	 */
	public function get_request(): string {
		$request   = MslsPlugin::get_superglobals( [ 'post_type' ] );
		$post_type = ! empty( $request['post_type'] ) ? esc_attr( $request['post_type'] ) : 'post';

		return in_array( $post_type, $this->get() ) ? $post_type : '';
	}

For new pages, this is page, but if the page is saved it will return post regardless of what kind of post type is edited. It seems only the request parameters are used then and not the real type of the post being edited.

@arnowelzel
Copy link
Contributor

Ok, I found a solution and will create a pull request for that.

@lloc lloc closed this as completed in 7d9e365 Sep 5, 2022
lloc added a commit that referenced this issue Sep 5, 2022
Fix #184 - use type of post and not only request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants