Skip to content

Commit

Permalink
Better Gravity Forms compatibility with bootstrap-datepicker
Browse files Browse the repository at this point in the history
  • Loading branch information
nicomollet committed Jun 14, 2021
1 parent c36967d commit d137405
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
* Better Gravity Forms compatibility with bootstrap-datepicker

### 0.7.7: May 25th, 2021
* Bootstrap select rules for Gravity Forms are conflicting on mobile

Expand Down
7 changes: 7 additions & 0 deletions inc/front/scripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,13 @@ function stormbringer_js_libraries_footer() {

if ( @$libraries['bootstrap-datepicker'] && get_theme_mod( 'libraries_bootstrap-datepicker', true ) ) {

wp_dequeue_script( 'gform_datepicker_init' );
wp_dequeue_script( 'gform-datepicker-init' );
wp_dequeue_script( 'jquery-ui-datepicker' );
wp_deregister_script( 'gform_datepicker_init' );
wp_deregister_script( 'gform-datepicker-init' );
wp_deregister_script( 'jquery-ui-datepicker' );

$lang_datepicker = ($lang == 'zh' ? 'zh-CN' : $lang);

wp_enqueue_script( 'bootstrap-datepicker',
Expand Down
12 changes: 7 additions & 5 deletions inc/plugins/gravityforms.php
Original file line number Diff line number Diff line change
Expand Up @@ -347,11 +347,13 @@ function stormbringer_gform_get_form_filter($content)
//$content = preg_replace('/<ul class=\'gfield_checkbox\'(.*?)>(.*?)<\/ul>/', '\\2', $content);
//$content = preg_replace('/<ul class=\'gfield_radio\'(.*?)>(.*?)<\/ul>/', '\\2', $content);

$content = str_replace('<li ', '<div ', $content);
$content = str_replace('<ul ', '<div ', $content);
$content = str_replace('</li>', '</div>', $content);
$content = str_replace('</ul>', '</div>', $content);

$content = str_replace( '<li ', '<div ', $content );
$content = str_replace( '<ul ', '<div ', $content );
$content = str_replace( '</li>', '</div>', $content );
$content = str_replace( '</ul>', '</div>', $content );
$content = str_replace( 'hasDatepicker', '', $content );
$content = str_replace( 'datepicker_no_icon', '', $content );
$content = str_replace( 'datepicker', '', $content );

return $content;
}
Expand Down

0 comments on commit d137405

Please sign in to comment.