Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
(WordPress) Reposition New Blog Templates
<?php
/*
Plugin Name: Reposition New Blog Templates
Description: Move New Blog Template selection to a different Gravity Form page.
Author: Mike Manger
Author URI:
*/
function mm_rnbt_get_form_filter( $form_html, $form ) {
// Let's check if the option for New Blog Templates is activated in this form
$config = GFUserData::get_feed_by_form( $form['id'] );
if ( empty( $config ) ) {
return $form_html;
}
$config = current( $config );
$multisite_options = rgar( $config['meta'], 'multisite_options' );
if ( isset( $multisite_options['blog_templates'] ) && absint( $multisite_options['blog_templates'] ) ) {
$form_id = $form['id'];
ob_start();
// Adding some Javascript to move template selection to the first page
?>
<script type="text/javascript">
jQuery( document ).ready(function( $ ) {
var first_page = $( '#gform_page_<?php echo $form_id; ?>_1' );
$( '#blog_template-selection' ).prependTo( first_page );
});
</script>
<?php
$form_html .= ob_get_clean();
}
return $form_html;
}
add_filter( 'gform_get_form_filter', 'mm_rnbt_get_form_filter', 15, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment