Last active
August 29, 2015 14:03
-
-
Save mikemanger/320e7ebcb3250c530da1 to your computer and use it in GitHub Desktop.
(WordPress) Reposition New Blog Templates
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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