Beispiel #1
0
function ninja_forms_admin()
{
    global $wpdb, $ninja_forms_tabs, $ninja_forms_sidebars, $current_tab, $ninja_forms_tabs_metaboxes, $ninja_forms_admin_update_message;
    $current_tab = ninja_forms_get_current_tab();
    $current_page = esc_html($_REQUEST['page']);
    if (isset($_REQUEST['form_id'])) {
        $form_id = absint($_REQUEST['form_id']);
        $data = Ninja_Forms()->form($form_id)->get_all_settings();
        $form_title = isset($data['form_title']) ? $data['form_title'] : '';
    } else {
        $form_id = '';
        $data = '';
        $form_title = '';
    }
    if (!isset($ninja_forms_admin_update_message) and isset($_REQUEST['update_message'])) {
        $ninja_forms_admin_update_message = esc_html($_REQUEST['update_message']);
    }
    $output_form = isset($ninja_forms_tabs[$current_page][$current_tab]['output_form']) ? $ninja_forms_tabs[$current_page][$current_tab]['output_form'] : true;
    $form_method = isset($ninja_forms_tabs[$current_page][$current_tab]['form_method']) ? $ninja_forms_tabs[$current_page][$current_tab]['form_method'] : 'post';
    $hidden_fields = isset($ninja_forms_tabs[$current_page][$current_tab]['hidden_fields']) ? $ninja_forms_tabs[$current_page][$current_tab]['hidden_fields'] : true;
    if ($output_form) {
        ?>
		<form id="ninja_forms_admin" enctype="multipart/form-data" method="<?php 
        echo $form_method;
        ?>
">
			<input type="hidden" name="_page" id="_page" value="<?php 
        echo $current_page;
        ?>
">
			<input type="hidden" name="_tab" id="_tab" value="<?php 
        echo $current_tab;
        ?>
">
			<input type="hidden" name="_form_id"  id="_form_id" value="<?php 
        echo $form_id;
        ?>
">
			<input type="hidden" name="_fields_order" id="_fields_order" value="same">
			<?php 
        wp_nonce_field('_ninja_forms_save', '_ninja_forms_admin_submit');
    }
    ?>
		<div class="wrap">
			<?php 
    screen_icon('ninja-custom-forms');
    if (isset($ninja_forms_tabs[$current_page][$current_tab]['title'])) {
        echo $ninja_forms_tabs[$current_page][$current_tab]['title'];
    }
    if ('form_list' == $current_tab) {
        $builder_url = esc_url(add_query_arg(array('form_id' => 'new', 'tab' => 'builder')));
        ?>
					<h2><?php 
        _e('Forms', 'ninja-forms');
        ?>
 <a href="<?php 
        echo $builder_url;
        ?>
" class="add-new-h2"><?php 
        _e('Add New', 'ninja-forms');
        ?>
</a></h2>
					<?php 
    } else {
        ?>
					<h2 id="nf-display-form-title"><?php 
        echo $form_title;
        ?>
</h2>
					<?php 
    }
    if ($ninja_forms_tabs[$current_page][$current_tab]['show_tab_links']) {
        ?>
					<h2 class="nav-tab-wrapper">
						<?php 
        ninja_forms_display_tabs();
        if (!empty($form_id)) {
            $preview_link = ninja_forms_preview_link($form_id, false);
            $subs_link = admin_url('edit.php?post_status=all&post_type=nf_sub&action=-1&m=0&form_id=' . $form_id . '&begin_date&end_date&paged=1&mode=list&action2=-1');
            ?>
							<a href="<?php 
            echo $preview_link;
            ?>
" target="_blank" class="nf-preview button-secondary"><span class="dashicons dashicons-welcome-view-site"></span><?php 
            _e('Preview', 'ninja-forms');
            ?>
</a>
							<a href="<?php 
            echo $subs_link;
            ?>
" target="_blank" class="nf-subs button-secondary"><span class="dashicons dashicons-email-alt"></span><?php 
            _e('Submissions', 'ninja-forms');
            ?>
</a>
						<?php 
        }
        ?>
					</h2>
					<?php 
    }
    if (isset($ninja_forms_admin_update_message) and $ninja_forms_admin_update_message != '') {
        ?>
					<div id="message" class="updated below-h2">
						<p>
							<?php 
        echo $ninja_forms_admin_update_message;
        ?>
						</p>
					</div>
					<?php 
    }
    if (isset($ninja_forms_sidebars[$current_page][$current_tab]) and is_array($ninja_forms_sidebars[$current_page][$current_tab])) {
        ?>
					<div id="nav-menus-frame">
						<?php 
        ninja_forms_display_sidebars($data);
        ?>

					</div><!-- /#menu-settings-column -->
					<?php 
    }
    ?>

			<div id="poststuff">
				<div id="post-body">
					<div id="post-body-content">
						<?php 
    //Check to see if the registered tab has an metaboxes registered to it.
    if (isset($ninja_forms_tabs_metaboxes[$current_page][$current_tab]) and !empty($ninja_forms_tabs_metaboxes[$current_page][$current_tab])) {
        ?>
							<div id="ninja_forms_admin_metaboxes">
							<?php 
        foreach ($ninja_forms_tabs_metaboxes[$current_page][$current_tab] as $slug => $metabox) {
            ninja_forms_output_tab_metabox($form_id, $slug, $metabox);
        }
        ?>
							</div>
							<?php 
    }
    //Check to see if the registered tab has a display function registered.
    if (isset($ninja_forms_tabs[$current_page][$current_tab]['display_function']) and $ninja_forms_tabs[$current_page][$current_tab]['display_function'] != '') {
        $tab_callback = $ninja_forms_tabs[$current_page][$current_tab]['display_function'];
        $arguments = func_get_args();
        array_shift($arguments);
        // We need to remove the first arg ($function_name)
        $arguments['form_id'] = $form_id;
        $arguments['data'] = $data;
        call_user_func_array($tab_callback, $arguments);
    }
    if (isset($ninja_forms_tabs[$current_page][$current_tab]['show_save']) and $ninja_forms_tabs[$current_page][$current_tab]['show_save'] === true) {
        ?>
							<br />
							<input class="button-primary menu-save ninja-forms-save-data" id="ninja_forms_save_data_top" type="submit" value="<?php 
        _e('Save', 'ninja-forms');
        ?>
" />
						<?php 
    }
    ?>

					</div><!-- /#post-body-content -->
				</div><!-- /#post-body -->
			</div>
		</div>
	<!-- </div>/.wrap-->
	<?php 
    if ($output_form) {
        ?>
		</form>
		<?php 
    }
    ?>
	<div id="nf-admin-modal-backdrop" style="display: none;"></div>
	<div id="nf-admin-modal-wrap" class="wp-core-ui" style="display: none;">
		<div id="nf-admin-modal" tabindex="-1">
			<div id="admin-modal-title">
				<span id="nf-modal-title"></span>
				<button type="button" id="nf-admin-modal-close" class="modal-close"><span class="screen-reader-text modal-close">Close</span></button>
		 	</div>
		 	<div id="modal-contents-wrapper" style="padding:20px;">
				<div id="nf-admin-modal-content" class="admin-modal-inside">
					
				</div>
				<div class="submitbox" style="display:block;">
					
				</div>
			</div>
		</div>
	</div>

	<?php 
}
Beispiel #2
0
function ninja_forms_admin()
{
    global $wpdb, $ninja_forms_tabs, $ninja_forms_sidebars, $current_tab, $ninja_forms_tabs_metaboxes, $ninja_forms_admin_update_message;
    $current_tab = ninja_forms_get_current_tab();
    $current_page = esc_html($_REQUEST['page']);
    if (isset($_REQUEST['form_id'])) {
        $form_id = absint($_REQUEST['form_id']);
        $form_row = ninja_forms_get_form_by_id($form_id);
        $data = $form_row['data'];
    } else {
        $form_id = '';
        $data = '';
    }
    if (!isset($ninja_forms_admin_update_message) and isset($_REQUEST['update_message'])) {
        $ninja_forms_admin_update_message = $_REQUEST['update_message'];
    }
    ?>
	<form id="ninja_forms_admin" enctype="multipart/form-data" method="post" name="" action="">
		<input type="hidden" name="_page" id="_page" value="<?php 
    echo $current_page;
    ?>
">
		<input type="hidden" name="_tab" id="_tab" value="<?php 
    echo $current_tab;
    ?>
">
		<input type="hidden" name="_form_id"  id="_form_id" value="<?php 
    echo $form_id;
    ?>
">
		<input type="hidden" name="_fields_order" id="_fields_order" value="same">
		<?php 
    wp_nonce_field('_ninja_forms_save', '_ninja_forms_admin_submit');
    ?>
		<div class="wrap">
			<?php 
    screen_icon('ninja-custom-forms');
    if (isset($ninja_forms_tabs[$current_page][$current_tab]['title'])) {
        echo $ninja_forms_tabs[$current_page][$current_tab]['title'];
    }
    if ($ninja_forms_tabs[$current_page][$current_tab]['show_tab_links']) {
        ?>
					<h2 class="nav-tab-wrapper">
						<?php 
        ninja_forms_display_tabs();
        ?>
					</h2>
					<?php 
    }
    if (isset($ninja_forms_admin_update_message) and $ninja_forms_admin_update_message != '') {
        ?>
					<div id="message" class="updated below-h2">
						<p>
							<?php 
        echo $ninja_forms_admin_update_message;
        ?>
						</p>
					</div>
					<?php 
    }
    if (isset($ninja_forms_sidebars[$current_page][$current_tab]) and is_array($ninja_forms_sidebars[$current_page][$current_tab])) {
        ?>
					<div id="nav-menus-frame">
						<?php 
        ninja_forms_display_sidebars($data);
        ?>

					</div><!-- /#menu-settings-column -->
					<?php 
    }
    ?>

			<div id="poststuff">
				<div id="post-body">
					<div id="post-body-content">
						<?php 
    //Check to see if the registered tab has a display function registered.
    if (isset($ninja_forms_tabs[$current_page][$current_tab]['display_function']) and $ninja_forms_tabs[$current_page][$current_tab]['display_function'] != '') {
        $tab_callback = $ninja_forms_tabs[$current_page][$current_tab]['display_function'];
        $arguments = func_get_args();
        array_shift($arguments);
        // We need to remove the first arg ($function_name)
        $arguments['form_id'] = $form_id;
        $arguments['data'] = $data;
        call_user_func_array($tab_callback, $arguments);
    }
    //Check to see if the registered tab has an metaboxes registered to it.
    if (isset($ninja_forms_tabs_metaboxes[$current_page][$current_tab]) and !empty($ninja_forms_tabs_metaboxes[$current_page][$current_tab])) {
        ?>
							<div id="ninja_forms_admin_metaboxes">
							<?php 
        foreach ($ninja_forms_tabs_metaboxes[$current_page][$current_tab] as $slug => $metabox) {
            ninja_forms_output_tab_metabox($form_id, $slug, $metabox);
        }
        ?>
							</div>
							<?php 
    }
    ?>
						<?php 
    if (isset($ninja_forms_tabs[$current_page][$current_tab]['show_save']) and $ninja_forms_tabs[$current_page][$current_tab]['show_save'] === true) {
        ?>
							<br />
							<input class="button-primary menu-save ninja-forms-save-data" id="ninja_forms_save_data_top" type="submit" value="<?php 
        _e('Save Form Settings', 'ninja-forms');
        ?>
" />
						<?php 
    }
    ?>

					</div><!-- /#post-body-content -->
				</div><!-- /#post-body -->
			</div>
		</div>
	<!-- </div>/.wrap-->
</form>
<?php 
}