/** * Render the form on the user profile page * @return void */ public function render_user_form($user) { $this->fm->data_id = $user->ID; $this->fm->data_type = 'user'; if (!empty($this->title)) { echo '<h3>' . esc_html($this->title) . '</h3>'; } echo '<div class="fm-user-form-wrapper">'; $this->render_field(); echo '</div>'; // Check if any validation is required $fm_validation = Fieldmanager_Util_Validation('your-profile', 'user'); $fm_validation->add_field($this->fm); }
/** * Output HTML for the form * @return void */ public function render_page_form() { $current = apply_filters('fm_' . $this->uniqid . '_load', array(), $this->fm); echo '<form method="POST" id="' . esc_attr($this->uniqid) . '">'; echo '<div class="fm-page-form-wrapper">'; printf('<input type="hidden" name="fm-page-action" value="%s" />', sanitize_title($this->uniqid)); wp_nonce_field('fieldmanager-save-' . $this->fm->name, 'fieldmanager-' . $this->fm->name . '-nonce'); echo $this->fm->element_markup($current); echo '</div>'; printf('<input type="submit" name="fm-submit" class="button-primary" value="%s" />', esc_attr($this->fm->submit_button_label) ?: esc_attr__('Save Options', 'fieldmanager')); echo '</form>'; echo '</div>'; // Check if any validation is required $fm_validation = Fieldmanager_Util_Validation($this->uniqid, 'page'); $fm_validation->add_field($this->fm); }
/** * Creates the HTML template for wrapping fields on the edit term form and prints the field * @access public * @param WP_Term $tag * @param string $taxonomy * @return void */ public function edit_term_fields($term, $taxonomy) { // Check if this term's parent matches the specified term if it is set if (!empty($this->parent) && $this->parent != $term->parent) { return; } // Create the HTML template for output $html_template = '<tr class="form-field"><th scope="row" valign="top">%s</th><td>%s</td></tr>'; // Check if any validation is required $fm_validation = Fieldmanager_Util_Validation('edittag', 'term'); $fm_validation->add_field($this->fm); // Display the field echo $this->term_fields($html_template, $taxonomy, $term); }
/** * Helper to attach element_markup() to add_meta_box(). Prints markup for options page. * @return void. */ public function render_submenu_page() { $values = get_option($this->fm->name, null); ?> <div class="wrap"> <?php if (!empty($_GET['msg']) && 'success' == $_GET['msg']) { ?> <div class="updated success"><p><?php esc_html_e('Options updated', 'fieldmanager'); ?> </p></div> <?php } ?> <h2><?php echo esc_html($this->page_title); ?> </h2> <form method="POST" id="<?php echo esc_attr($this->uniqid); ?> "> <div class="fm-submenu-form-wrapper"> <input type="hidden" name="fm-options-action" value="<?php echo sanitize_title($this->fm->name); ?> " /> <?php $this->render_field(array('data' => $values)); ?> </div> <?php submit_button($this->submit_button_label, 'primary', 'fm-submit'); ?> </form> </div> <?php // Check if any validation is required $fm_validation = Fieldmanager_Util_Validation($this->uniqid, 'submenu'); $fm_validation->add_field($this->fm); }
/** * Helper to attach element_markup() to add_meta_box(). Prints markup for post editor. * @see http://codex.wordpress.org/Function_Reference/add_meta_box * @param $post the post object. * @param $form_struct the structure of the form itself. Unused. * @return void. */ public function render_meta_box($post, $form_struct = null) { $this->fm->data_type = 'post'; $this->fm->data_id = $post->ID; $this->render_field(); // Check if any validation is required $fm_validation = Fieldmanager_Util_Validation('post', 'post'); $fm_validation->add_field($this->fm); }