Skip to content

Instantly share code, notes, and snippets.

@wpsunshine
wpsunshine / wordpress-show-block-in-theme.php
Created May 13, 2021
Display block in theme template files
View wordpress-show-block-in-theme.php
$block = get_post( 123 ); // Change 123 to the unique post ID for your block
echo apply_filters( 'the_content', $block->post_content );
@wpsunshine
wpsunshine / gf-enhanced-ui-list-select.js
Last active Apr 23, 2021
Gravity Forms use enhanced UI on select drop down for lists
View gf-enhanced-ui-list-select.js
<script>
// For standard forms
jQuery( document ).on( 'gform_post_render', function( event, form_id, current_page ){
gformInitChosenFields( '#field_12_10 select', 'No results matched' ); // Change selector to #field_FORMID_FIELDID
});
// Forms that use multiple pages and ajax
jQuery( document ).on( 'gform_page_loaded', function( event, form_id, current_page ){
gformInitChosenFields( '#field_12_10 select', 'No results matched' ); // Change selector to #field_FORMID_FIELDID
});
</script>
@wpsunshine
wpsunshine / gf-body-class-after-submission.php
Created Apr 1, 2021
Gravity Forms add body class after submission
View gf-body-class-after-submission.php
add_action( 'gform_after_submission', 'wpsunshine_gf_after_submission', 10, 2 );
function wpsunshine_gf_after_submission( $entry, $form ) {
add_filter( 'body_class', function( $classes ) {
return array_merge( $classes, array( 'gf-submitted' ) );
} );
}