Sensei: Change init priority for Course CPT so course slugs can be translated.

Created on 29 Jan 2019  路  2Comments  路  Source: Automattic/sensei

A user referenced this thread regarding problems with translating course slugs, and discovered a solution.

They changed priority from 100 to 10 for initialization of the "course" CPT, and they were able to translate the slug:

add_action( 'init', array( $this, 'setup_course_post_type' ), 10 );

Internal reference: 1744700-zen

[Type] Bug

All 2 comments

I was kindly asked to add something about this issue, so here I am :-)

I just installed Sensei on a private staging site (and will remove it as soon as the test is finished), to do the tests. I disabled the other plugins and only left WC, Sensei and WPML (with its addon WPML String Translation).
I have only English (default) and Italian languages active in WPML.

How to reproduce the issue:

  • Head to WPML settings to enable translation of Course's slug
  • Select the option to set a different slugs for each installed language and input your translation of the slug
  • Press "Save"
  • A red error message appears, stating that "Course slugs are set to be translated, but they are missing their translation"
  • The translation you just entered is not visible if you select the option to set a different translation for each language

How to "fix" the issue:

  • Find file /wp-content/plugins/woothemes-sensei/includes/class-sensei-posttypes.php
  • Search for the string add_action( 'init', array( $this, 'setup_course_post_type' ), 100 );
  • Change hook's priority from 100 to 10

Done. Now, back into WPML settings, I'm able to change course's slug without any warning or error. This should be done for Lessons, too, of course.

I really hope this helps :-)

Erenor.

We should probably have people use the provided filter for now:

add_filter( 'sensei_course_slug', function() {
  return 'curso';
} );
Was this page helpful?
0 / 5 - 0 ratings