public function AddNewFields($edit_field = false) { $input_values = array(); if ($edit_field) { $existing_values = SerializeStringToArray(get_option($this->prefix)); if ($existing_values && is_array($existing_values) && array_key_exists($edit_field, $existing_values)) { $input_values = $existing_values[$edit_field]; } else { echo '<div class="error"><p><strong>We did not find any recrod with given data.</strong></p></div>'; return; } echo '<input type="hidden" name="update_field" value="' . $edit_field . '">'; } else { echo '<input type="hidden" name="update_field" value="new">'; } ?> <input type="hidden" name="bb_field_types_save" value="<?php echo $this->prefix("bb_field_types_save"); ?> "> <div style="float:left;" class="form-wrap" id="col-left"> <div class="form-field"> <label for="field_title">Field Title <span class="require_star">*</span></label> <?php $selected_value = ""; if (isset($input_values['field_title'])) { $selected_value = $input_values['field_title']; } ?> <input type="text" name="field_title" id="field_title" class="regular-text" value="<?php echo $selected_value; ?> " required="required"> </div> <div class="form-field"> <label for="meta_key">Meta Key <span class="require_star">*</span></label> <?php $selected_value = ""; if (isset($input_values['meta_key'])) { $selected_value = $input_values['meta_key']; } ?> <input type="text" name="meta_key" id="meta_key" class="regular-text" value="<?php echo $selected_value; ?> " required="required"> </div> <div class="form-field"> <label for="field_type">Field Type <span class="require_star">*</span></label> <select name="field_type" id="field_type" class="<?php echo $this->prefix("field_type"); ?> " required="required"> <?php $selected_value = ""; if (isset($input_values['field_type'])) { $selected_value = $input_values['field_type']; } $types = array('text' => 'Text', 'editor' => 'Editor', 'image' => 'Image', 'file' => 'Files', 'textarea' => 'Text Area', 'color' => 'Color Picker', 'date' => 'Date Picker', 'checkbox_list' => 'Check Box List', 'checkbox' => 'Check Box', 'select' => 'Select List', 'password' => 'Password', 'radio' => 'Radio Buttons'); echo ArraytoSelectList($types, $selected_value); ?> </select> </div> <div class="form-field"> <label for="field_description">Help Text</label> <?php $selected_value = ""; if (isset($input_values['field_description'])) { $selected_value = $input_values['field_description']; } ?> <textarea name="field_description" id="field_description" cols="30" rows="5" class="regular-text"><?php echo $selected_value; ?> </textarea> <p class="description">Tell to the user about what is the field</p> </div> <p class="submit"><input type="submit" name="submit" id="submit" class="button button-primary" value="Save Changes"></p> </div> <!-- style="width:50%; float:left;" --> <div class="form-wrap" id="col-right" style="float:right;"> <div class="options_of_fields" style="padding:20px; background-color:#fff;"> <h3 style="margin:0 0 20px 0px;">Options of field</h3><p>By default on this box will be displayed a information about custom fields, after the custom field be selected, this box will be displayed some extra options of the field (if required) or a information about the selected field</p> <div class="hidden_fields checkbox_list select radio form-field" style="display:none;"> <label for="field_type_values">Choices: </label> <?php $selected_value = ""; if (isset($input_values['field_type_values'])) { $selected_value = implode("\n", $input_values['field_type_values']); } ?> <textarea name="field_type_values" id="field_type_values" cols="30" rows="5" class="regular-text"><?php echo $selected_value; ?> </textarea> <p class="description">Enter each choice on a new line.</p> </div> <div class="hidden_fields text color select radio form-field"> <label for="default_value">Default Value: </label> <?php $selected_value = ""; if (isset($input_values['default_value'])) { $selected_value = $input_values['default_value']; } ?> <input type="text" name="default_value" id="default_value" class="regular-text" value="<?php echo $selected_value; ?> " /> </div> <div class="hidden_fields text image form-field"> <label for="field_duplicate" style="display:inline-block;">Can be duplicated: </label> <?php $selected_value = ""; if (isset($input_values['field_duplicate'])) { $selected_value = $input_values['field_duplicate']; } ?> <input type="checkbox" name="field_duplicate" id="field_duplicate" <?php if ($selected_value === 'on') { echo 'checked="checked"'; } ?> /> </div> </div> </div> <div class="clearboth"></div> <script> jQuery(document).ready(function($) { $(".options_of_fields .hidden_fields").hide(); var bb_field_type_value = $("select.<?php echo $this->prefix('field_type'); ?> ").val(); $(".options_of_fields ."+bb_field_type_value).show(); $("select.<?php echo $this->prefix('field_type'); ?> ").change(function(){ bb_field_type_value = $(this).val(); $(".options_of_fields .hidden_fields").hide(); $(".options_of_fields ."+bb_field_type_value).show(); }); }); </script> <?php }
private function CreatePageForm($user_created_pages = array(), $edit_page = false) { $edit_page_values = array(); echo '<form method="post" action="">'; if ($edit_page && is_array($user_created_pages) && count($user_created_pages) >= 1 && array_key_exists($edit_page, $user_created_pages)) { $edit_page_values = $user_created_pages[$edit_page]; echo '<input type="hidden" name="update_created_option_page" value="' . $edit_page . '" />'; } ?> <input type="hidden" name="create_new_option_page" value="<?php echo $this->prefix('create_new_option_page'); ?> " /> <table class="form-table"> <tr> <th scope="row"><label for="user_created_pages">Page Name: <span class="require_star">*</span></label></th> <td> <?php $selected_value = ''; if (isset($edit_page_values['page_title'])) { $selected_value = $edit_page_values['page_title']; } ?> <input type="text" name="user_created_pages" id="user_created_pages" class="regular-text" required="required" value="<?php echo $selected_value; ?> " /> </td> </tr> <tr> <th scope="row"><label for="parent_menu">Select Parent Menu: <span class="require_star">*</span></label></th> <td> <select id="parent_menu" name="parent_menu"> <?php $pages_list = array("new_menu" => "Create New Parent Menu ", "dashboard" => "Dashboard", "posts" => 'Posts', "media" => "Media", "pages" => "Pages", "comments" => 'Comments', "theme" => "Appearance", "plugins" => "Plugins", "users" => 'Users', "management" => "Tools", "options" => "Settings"); if (isset($user_created_pages) && is_array($user_created_pages) && count($user_created_pages) >= 1) { foreach ($user_created_pages as $key => $value) { if (isset($value['parent_menu']) && $value['parent_menu'] == "new_menu") { $pages_list[$value['page_slug']] = $value['page_title']; } } } //global $submenu, $menu, $pagenow; $selected_value = ''; if (isset($edit_page_values['parent_menu'])) { $selected_value = $edit_page_values['parent_menu']; } echo ArraytoSelectList($pages_list, $selected_value); ?> </select> </td> </tr> </table> <?php submit_button('Create Page'); echo '</form>'; }