• Hi,

    WPForms cannot activate because of this error:

    Fatal error: Uncaught TypeError: Cannot access offset of type string on string in /../../public_html/wp-content/plugins/wpforms-lite/includes/class-install.php:188 Stack trace: #0 /../../public_html/wp-content/plugins/wpforms-lite/includes/class-install.php(82): WPForms_Install->run() #1 /../../public_html/wp-includes/class-wp-hook.php(287): WPForms_Install->install(”) #2 /../../public_html/wp-includes/class-wp-hook.php(311): WP_Hook->apply_filters(”, Array) #3 /../../public_html/wp-includes/plugin.php(484): WP_Hook->do_action(Array) #4 /../../public_html/wp-admin/plugins.php(193): do_action(‘activate_wpform…’) #5 {main} thrown in /../../public_html/wp-content/plugins/wpforms-lite/includes/class-install.php on line 188

    and i also tried to update to latest version ( old version 1.6.6 ), but the plugin also cannot activate and show the same error. How can i fix this?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Ralden Souza

    (@rsouzaam)

    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 1 day, 3 hours ago by ArrayIterator. Reason: change description
Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.