<?php
// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals

if ( ! defined( 'ABSPATH' ) ) {
	 exit;
}

$form_row          = is_object( $row ) ? $row : (object) array();
$current_form_id   = isset( $form_row->id ) ? absint( $form_row->id ) : 0;
$current_form_name = isset( $form_row->name ) ? $form_row->name : '';
$preview_page_id   = (int) get_option( 'wpefb_preview_page_id', 0 );
$preview_url       = $preview_page_id ? get_permalink( $preview_page_id ) : home_url( '/' );
if ( ! is_string( $preview_url ) || '' === $preview_url ) {
	$preview_url = home_url( '/' );
}
$preview_url = add_query_arg( 'id', $current_form_id, $preview_url );
?>
<div class="advrf-wrapper wrap wef-forms-modern wef-dashboard-modern wef-configure-modern">
    <div class="advrf-page-title">		 
        <h1 class="wpefb-page-heading">
            <?php echo esc_html( $current_form_name ); ?></h1>
        <ul class="advrf-nav">
            <li class="advrf-nav-item">
                <a href="<?php echo esc_url( admin_url( 'admin.php?page=wpefb_manage_forms' ) ); ?>">
                    <span class="dashicons dashicons-feedback"></span>
                    <?php esc_html_e( 'All Forms', 'vedrixa-forms-registration-builder' ); ?></a>
            </li>
            <li class="advrf-nav-item">
                <a href="<?php echo esc_url( admin_url( 'admin.php?page=wpefb_form_dashboard&id=' . $current_form_id ) ); ?>">
                    <span class="dashicons dashicons-admin-generic"></span>
                    	<?php esc_html_e( 'Dashboard', 'vedrixa-forms-registration-builder' ); ?>					</a>
            </li>
            <li class="advrf-nav-item">
                <a target="_blank" href="<?php echo esc_url( $preview_url ); ?>">
                    <span class="dashicons dashicons-visibility"></span>
                     <?php esc_html_e( 'Preview', 'vedrixa-forms-registration-builder' ); ?>	</a>
            </li>    
        </ul>

    </div>
    <div class="clearfix">
        <div class="advrf-form-conf-wrapper">
            <form action="" method="post" id="advrf_configuration_form">
                <fieldset class="advrf-config-wrap">
                    <div>
                        <div class="group-title">
                            <?php esc_html_e( 'General Settings', 'vedrixa-forms-registration-builder' ); ?>				</div>
                        <div class="group-wrap">
                            
                            <div class="advrf-row">
                                <div class="advrf-control-label">
                                    <label><?php esc_html_e( 'Name', 'vedrixa-forms-registration-builder' ); ?></label>
                                </div>
                                <div class="advrf-control">
                                    <input type="text" class="advrf-input-field" name="name" value="<?php echo esc_attr( isset( $row->name ) ? $row->name : '' ); ?>">
                                    <p class="description"><?php esc_html_e( 'Name of your form.', 'vedrixa-forms-registration-builder' ); ?></p>
                                </div>
                                 
                            </div>
                            
                            <div class="advrf-row">
						<div class="advrf-control-label">
							<label><?php esc_html_e( 'Description', 'vedrixa-forms-registration-builder' ); ?></label>
						</div>
						<div class="advrf-control">
							<textarea class="advrf-input-field" name="meta[wpefb_form_description]"><?php echo esc_textarea( isset( $meta['wpefb_form_description'] ) ? $meta['wpefb_form_description'] : '' ); ?></textarea>
							<p class="description"><?php esc_html_e( 'Not visible on front end by default. Can be displayed using MagicWidgets.', 'vedrixa-forms-registration-builder' ); ?></p>
						</div>  
					</div>
                            
                            <div class="advrf-row">
						<div class="advrf-control-label">
							<label><?php esc_html_e( 'Content Above The Form', 'vedrixa-forms-registration-builder' ); ?></label>
						</div>
						<div class="advrf-control">
							<?php
							$editor_id                               = 'before_form';
							$settings                                = array(
								'wpautop'           => false,
								'media_buttons'     => true,
								'textarea_name'     => 'meta[before_form]',
								'textarea_rows'     => 20,
								'tabindex'          => '',
								'tabfocus_elements' => ':prev,:next',
								'editor_css'        => '',
								'editor_class'      => 'advrf-editor',
								'teeny'             => false,
								'dfw'               => false,
								'tinymce'           => true, // <-----
								'quicktags'         => true,
							);
                                                        $before_form = isset( $meta['before_form'] )?$meta['before_form']:'';
							wp_editor( $before_form, $editor_id, $settings );
							?>
							<p class="description">
								<?php esc_html_e( 'This will be displayed above the form. Inbuilt shortcode:', 'vedrixa-forms-registration-builder' ); ?><br/>
			
							</p>
						</div>  
					</div>
                            
                        </div>
                    </div>


                  


                </fieldset>

                <p class="submit">
                    <input type="hidden" name="form_id" id="form_id" value="<?php echo esc_attr( $current_form_id ); ?>" />
                    <?php wp_nonce_field( 'save_wpefb_add_form' ); ?>
                    <input type="submit" value="<?php esc_attr_e( 'Save', 'vedrixa-forms-registration-builder' ); ?>" class="button button-primary" name="submit_form" id="submit_form" onClick="return add_form_validation()"/>
                    <a class="button button-secondary" href="<?php echo esc_url( admin_url( 'admin.php?page=wpefb_form_dashboard&id=' . $current_form_id ) ); ?>"><?php esc_html_e( 'Cancel', 'vedrixa-forms-registration-builder' ); ?></a>
                    <div class="all_error_text" style="display:none;"></div>
                </p>
            </form>  
        </div>    
    </div>    
</div>

