Hi @nursyfqh,
Thanks for reaching out, and I’m sorry to hear about the issue you’re experiencing.
When you get a chance, please share the details from WPForms > Tools > System Info (screenshot). This information may help us better understand the issue and provide further information.
Thanks!
Hello @rsouzaam this looks like your code direct load the integration before after_setup_theme
Looks like your code is invalid on integration, eg: (divi or default themes)
/**
* This is array<string>
* @var array<string>
*/
$allow_themes = [ 'Divi', 'Extra' ]; // string[]
$theme = wp_get_theme();
$theme_name = $theme->get_template(); // string (OK)
$theme_parent = $theme->parent(); // but this is \WP_Theme
// invalid comparation cause using __tostring() / stringable theme object
return (bool) array_intersect( [ $theme_name, $theme_parent ], $allow_themes );
When you use it for comparation it will call __tostring()
method, the stringable also call the display()
method on WP_Theme
.
Please follow the github source of WP_Theme
, that mean the display method will call the method of load_textdomain()
even the init/setup theme not yet called.
// ref: https://github.com/WordPress/wordpress-develop/blob/d088e31c73456179502c9bd5354fc43c6267bd7a/src/wp-includes/class-wp-theme.php#L811
public function display( $header, $markup = true, $translate = true ) {
$value = $this->get( $header );
if ( false === $value ) {
return false;
}
// this is the problem
if ( $translate && ( empty( $value ) || ! $this->load_textdomain() ) ) {
$translate = false;
}
if ( $translate ) {
$value = $this->translate_header( $header, $value );
}
if ( $markup ) {
$value = $this->markup_header( $header, $value, $translate );
}
return $value;
}
I prefer to change array_intersect
with this code: (divi)
/**
* This is array<string>
* @var array<string>
*/
$allow_themes = [ 'Divi', 'Extra' ];
$theme = wp_get_theme();
$theme_name = $theme->get_template();
$theme_parent = $theme->parent(); // \WP_Theme
$theme_list = [
$theme_name
];
if ($theme_parent instanceof \WP_Theme) {
$theme_list[] = $theme_parent->get_template();
}
// using comparison with real string[]
return (bool) array_intersect( $theme_list, $allow_themes );
-
This reply was modified 7 months ago by
ArrayIterator. Reason: change description
Hey @arrayiterator,
Thank you for chiming in and sharing your detailed findings on this topic and your suggested fix.
We have created a report for this issue internally, and our team is currently investigating. I’ll make sure to follow up with you as soon as we have an update or a resolution to share.
Thank you so much for your patience.
Hey @arrayiterator and @nursyfqh,
I wanted to share an update and let you know that our team has fixed the issue internally and the fix will be going out in the next update. We don’t have a release date but I can say that it will be sometime soon. I’ll share another update as soon as the fix goes out!
Thank you again for reporting this.
Thank you?
Truly is also my fault 😅
cause I’ve been in wrong topic & replies. I was writing about textdomain.
Hi @arrayiterator
No worries at all! We’ll be addressing the Fatal error: Uncaught TypeError: Cannot access offset of type string on string error in this update.
Thank you!
Hey @nursyfqh and @arrayiterator,
I wanted to let you know that we have release version 1.9.2.3 of WPForms that contains a fix for this issue. Would you mind updating to this version is you have not done so already?
Thank you!