Skip to content

Commit

Permalink
added auto pin menu tagging thing
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidCramer committed Oct 2, 2015
1 parent 10ed58d commit 6d02924
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
11 changes: 7 additions & 4 deletions classes/admin.php
Expand Up @@ -1200,18 +1200,21 @@ static function save_form(){
}else{

$form_id = sanitize_key( $_GET['form_id'] );

if( !empty( $_GET['pin_menu'] ) ){
$form['pinned'] = 1;
}
header("Content-Type: application/php");
header("Content-Disposition: attachment; filename=\"" . sanitize_file_name( strtolower( $form_id ) ) . "-include.php\";" );
echo '<?php' . "\r\n";
echo "/**\r\n * Caldera Forms - PHP Export \r\n * {$form['name']} \r\n * @version " . CFCORE_VER . "\r\n * @license GPL-2.0+\r\n * \r\n */\r\n";
echo "/**\r\n * Caldera Forms - PHP Export \r\n * {$form['name']} \r\n * @version " . CFCORE_VER . "\r\n * @license GPL-2.0+\r\n * \r\n */\r\n\r\n\r\n";

$structure = 'add_filter( "caldera_forms_get_forms", function( $forms ){' . "\r\n";
$structure = "/**\r\n * Filter admin forms to include custom form in admin\r\n *\r\n * @since 1.3.1\r\n *\r\n * @param array all registered forms\r\n */\r\n";
$structure .= 'add_filter( "caldera_forms_get_forms", function( $forms ){' . "\r\n";
$structure .= "\t" . '$forms["' . $form_id . '"] = apply_filters( "caldera_forms_get_form-' . $form_id . '", array() );' . "\r\n";
$structure .= "\t" . 'return $forms;' . "\r\n";
$structure .= "} );\r\n\r\n";


$structure .= "/**\r\n * Filter form request to include form structure to be rendered\r\n *\r\n * @since 1.3.1\r\n *\r\n * @param array form structure\r\n */\r\n";
$structure .= "add_filter( 'caldera_forms_get_form-{$form_id}', function(){\r\n return " . var_export( $form, true ) . ";\r\n" . '} );' . "\r\n";
// cleanups because I'm me
$structure = str_replace( 'array (', 'array(', $structure );
Expand Down
5 changes: 3 additions & 2 deletions ui/admin.php
Expand Up @@ -138,7 +138,7 @@
data-page="1"

><?php echo __('Entries', 'caldera-forms'); ?></a> | </span><?php } ?>
<input type="hidden" id="form-export-<?php echo $form_id; ?>" value='{ "formid" : "<?php echo $form_id; ?>", "nonce" : "<?php echo wp_create_nonce( 'cf_del_frm' ); ?>" }'>
<input type="hidden" id="form-export-<?php echo $form_id; ?>" value='{ "formslug" : "<?php echo sanitize_title( $form['name'] ); ?>", "formid" : "<?php echo $form_id; ?>", "nonce" : "<?php echo wp_create_nonce( 'cf_del_frm' ); ?>" }'>
<?php if( empty( $form['_external_form'] ) ){ ?><span class="export"><a class="form-control ajax-trigger"
<?php
// build exporter buttons
Expand All @@ -147,7 +147,8 @@
'data-modal-autoclose' => 'export',
);
?>
data-modal="export"
data-modal="export"
data-modal-height="400"
data-modal-title="<?php echo esc_attr( __('Export Form', 'caldera-forms') ); ?>"
data-request="#form-export-<?php echo $form_id; ?>"
data-type="json"
Expand Down
8 changes: 7 additions & 1 deletion ui/admin_templates.php
Expand Up @@ -22,7 +22,13 @@
<div class="caldera-config-group">
<label><?php echo __('Form ID', 'caldera-forms'); ?></label>
<div class="caldera-config-field">
<input type="text" class="block-input field-config" data-format="key" name="form_id" value="{{formid}}" required="required">
<input type="text" class="block-input field-config" data-format="key" name="form_id" value="{{formslug}}" required="required">
</div>
</div>
<div class="caldera-config-group">
<label><?php echo __('Pin to Admin', 'caldera-forms'); ?></label>
<div class="caldera-config-field">
<label><input type="checkbox" name="pin_menu" value="1"> <?php _e("Set form to be pinned to Admin Menu", "caldera-forms"); ?></label>
</div>
</div>
<div class="caldera-config-group">
Expand Down

0 comments on commit 6d02924

Please sign in to comment.