Skip to content

Plugin Compatibility issue: GravityForms #4

@jimboobrien

Description

@jimboobrien

Having an issue with GravityForms plugin. Cannot edit any form in the admin due to Javascript error. They recently updated their plugin to use AJAX in the backend for the form builder and it is clashing with a body class possibly.

I have narrowed the issue down to the themes.php feature in the _bootstrap_filter_body_html() function. When I comment out the following code it works completely fine in the admin:

function _bootstrap_filter_body_html($buffer) {
  $theme_json = _bootstrap_get_theme_json();
  $resolve_preset = _bootstrap_get_preset_resolver($theme_json);
  $background_color = query_object($theme_json, 'styles.color.background') ?: (
    get_background_color()
      ? '#' . get_background_color()
      : ''
  );

  $bs_theme = '';

  if ($background_color) {
    $brightness = brightness($background_color);

    if ($brightness < 100) {
      $bs_theme = 'dark';
    }
  }

  $bs_theme = apply_filters('bootstrap_theme', $bs_theme);

  if ($bs_theme) {
    $buffer = preg_replace('/<body([^>]+)/', sprintf('<body$1 data-bs-theme="%s"', $bs_theme), $buffer);
  }

  return $buffer;
}


ob_start();

add_action('shutdown', function() {
    $final = '';
    $levels = ob_get_level();

    for ($i = 0; $i < $levels; $i++) {
      $final .= ob_get_clean();
    }

    echo _bootstrap_filter_body_html($final);
}, 0);

Thanks for your contributions, and I hope this helps!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions