Elementor CHOOSE控件前缀类%s字符串格式问题求助
Hey, let's get that prefix_class problem sorted out for your Elementor CHOOSE control. The issue here boils down to how Elementor handles the prefix_class parameter specifically for the CHOOSE control type.
Looking at your code, you added %s to the prefix_class value—but Elementor's CHOOSE control doesn't use that placeholder. Instead, it automatically appends the selected option's value directly to the prefix string you provide. That's why you're seeing etlms-author-layout-%sleft instead of the desired etlms-author-layout-left: the %s is being treated as literal text, then the option value gets tacked on at the end.
The Fix
Simply remove the %s from your prefix_class definition. Here's the corrected code:
$this->add_responsive_control( 'course_author_layout', [ 'label' => __('Layout', 'text-domain'), 'type' => Controls_Manager::CHOOSE, 'options' => [ 'left' => [ 'title' => __('Left', 'text-domain'), 'icon' => 'fa fa-long-arrow-left', ], 'up' => [ 'title' => __('Center', 'text-domain'), 'icon' => 'fa fa-long-arrow-up', ], ], 'prefix_class' => 'etlms-author-layout-', // No more %s here 'default' => 'left', ] );
Why This Works
For the CHOOSE control, Elementor takes the string you set in prefix_class and concatenates it with the selected option's key (in your case, left or up). So with etlms-author-layout- as the prefix, selecting left will generate the class etlms-author-layout-left, which matches your expected result.
Just a quick note: This behavior is specific to the CHOOSE control. Other control types like SELECT might require the %s placeholder, but CHOOSE handles the value appending automatically.
内容的提问来源于stack exchange,提问作者SK Shewa

