-
Notifications
You must be signed in to change notification settings - Fork 0
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
Translating CET from ALB Window #3
Comments
Problem: When editing a CET from ALB window I need to tell WPML that post content is invalid so it allows to translate the new content.How to reproduce:
When changing and saving a CET from CPT screen with the "Update" button the changing for the translation is recognised. But I did not find where to hook and what to set to invalidate the post. Filter wpml_pb_shortcode_content_for_translationIn this filter we return '' for locked attributes. Is there a way to know the context the filter is called?
|
@InoPlugs I'll ask @strategio to look into this but I have some comments on the translation icon for CTEs
|
Hi @InoPlugs
I am not sure to follow your workflow. When you translate an ALB post, you should not translate the locked fields of the included CET. Anyway, I agree with @amElnagdy that we should not open a separate translation workflow for CET (i.e. editing via WP native CPT UI).
This filter has 2 parameters:
Maybe you could use the post ID to check which element you are currently filtering? The post ID should refer either to an ALB or a CET. Note: I wanted to re-test your latest dev version (10) today, but I didn't manage to unzip the archive (even with the password). Could you please check if you manage to unzip it? |
Rechecking, I think post ID should help.
Let me try to explain the problem simplyfied. Lets say you want to create a website and you want to design a button "Contact Me" that you can reuse on several pages. As a first step you start to design a page "My First".
As first step design the CET button:
Now you can translate the CET "Contact Button":
Translating the pages where the button is used:
After some time you want to change the button - e.g. label and icon position:
If you now visit a page in the base language with the button the changes will be visible without editing the page. Of course, you must translate the CET:
If this would work and you visit a page in the other languages with the button the changes will be visible without editing the pages. As you prefer to use Translation Management Dashboard I removed the "translate icon" from ALB shortcode button when editing custom element and added a theme option if user wants to have it. BTW: When "Do not allow access to the screens" is selected (= default) update button and some other stuff is hidden with CSS, when "Add links to open the CPT screens" is selected all is visible so developpers can update the CET for testing. |
Hi @InoPlugs, Thanks for the detailed steps, it helps! My tests are passing (following your steps). I think there's a misunderstanding with the translation jobs: Once an original post (or CET in our case) is modified, the translation job must be refreshed because it's not valid anymore (the original strings have changed). So after editing a CET that was already translated, you need to go to WPML > Translation Management (i.e. "translation dashboard") and re-send the CET to translation. Once you have a created a new translation job, you can go to WPML > Translations (i.e. "translations queue") and complete the new translation job. I managed to test your latest version because @amElnagdy shared another ZIP archive. Not sure why I can't properly extract yours, maybe because I use Linux. I also notices several notices and warnings when I switch the language in the backend:
Or:
Could this be related to the settings not properly defined in the secondary language? |
@InoPlugs, we managed to reproduce the issue when we don't save the current post (ALB screen) after updating the CET (I was wrong). I found the reason why: I can suggest a small change in your code to workaround that (in if( isset( $_REQUEST['action'] ) && in_array( $_REQUEST['action'], array( 'avia_alb_element_template_cpt_actions', 'avia_alb_element_template_update_content' ) ) )
{
$post = $unfiltered_post_content = get_post($post_id);
$post_content = $post ? $post->post_content : $post_content;
$update = true;
} Let me know if it works for you. |
Cool, thank you. A first check this seems to fix the problem. I will do some more testing tomorrow and will let you know. I also will add some more adjustments and send you a new release for checking. The notices sound like missing settings in the options array. In the next release I added a check that all settings keys from main language are also set in the other languages when switching langs in theme option page in backend. |
Translating CET requires Translation Management. It is currently not intended to be used with classic editor translations ( - Use WPML's Translation Editor checkbox off).
For normal users
Update button, other buttons and some other action links and info is hidden - user should edit CET only from ALB window.
Reason is, that option 'All subitems use the same custom element template' is only supported from ALB window and not from CPT screen editing.
Advanced users
add_theme_support( 'avia-custom-elements-cpt-screen' );
This adds a selectbox to theme options where you can decide to activate the CPT screen links.
This also enables all buttons and links you know from normal CPT screens and also allows to update CET's.
The text was updated successfully, but these errors were encountered: