/**
 * Add/Edit usermeta fields group
 *
 * @author Gen gen.i@icanlocalize.com
 * @since Types 1.3
 */
function wpcf_admin_menu_edit_user_fields()
{
    $add_new = false;
    $post_type = current_filter();
    $title = __('View User Field Group', 'wpcf');
    if (isset($_GET['group_id'])) {
        $item = wpcf_admin_get_user_field_group_by_id((int) $_GET['group_id']);
        if (WPCF_Roles::user_can_edit('user-meta-field', $item)) {
            $title = __('Edit User Field Group', 'wpcf');
            $add_new = array('page' => 'wpcf-edit-usermeta');
        }
    } else {
        if (WPCF_Roles::user_can_create('user-meta-field')) {
            $title = __('Add New User Field Group', 'wpcf');
        }
    }
    wpcf_add_admin_header($title, $add_new);
    $form = wpcf_form('wpcf_form_fields');
    echo '<form method="post" action="" class="wpcf-fields-form wpcf-form-validate js-types-show-modal">';
    wpcf_admin_screen($post_type, $form->renderForm());
    echo '</form>';
    wpcf_add_admin_footer();
    return;
    $form = wpcf_form('wpcf_form_fields');
    echo '<br /><form method="post" action="" class="wpcf-fields-form ' . 'wpcf-form-validate" onsubmit="';
    echo 'if (jQuery(\'#wpcf-group-name\').val() == \'' . __('Enter group title', 'wpcf') . '\') { jQuery(\'#wpcf-group-name\').val(\'\'); }';
    echo 'if (jQuery(\'#wpcf-group-description\').val() == \'' . __('Enter a description for this group', 'wpcf') . '\') { jQuery(\'#wpcf-group-description\').val(\'\'); }';
    echo 'jQuery(\'.wpcf-forms-set-legend\').each(function(){
        if (jQuery(this).val() == \'' . __('Enter field name', 'wpcf') . '\') {
            jQuery(this).val(\'\');
        }
        if (jQuery(this).next().val() == \'' . __('Enter field slug', 'wpcf') . '\') {
            jQuery(this).next().val(\'\');
        }
        if (jQuery(this).next().next().val() == \'' . __('Describe this field', 'wpcf') . '\') {
            jQuery(this).next().next().val(\'\');
        }
	});';
    echo '">';
    echo $form->renderForm();
    echo '</form>';
    wpcf_add_admin_footer();
}
示例#2
0
 public function page_handler()
 {
     // Following code taken from the legacy parts. Needs refactoring.
     // By now we expect that prepare_form_maybe_redirect() was already called. If not, something went terribly wrong.
     if (null == $this->wpcf_admin) {
         return;
     }
     // Well this doesn't look right.
     $post_type = current_filter();
     // Start rendering the page.
     // Header and title
     $page_purpose = $this->wpcf_admin->get_page_purpose();
     $add_new_button = 'edit' == $page_purpose ? array('page' => self::PAGE_NAME) : false;
     wpcf_add_admin_header($this->get_page_title($page_purpose), $add_new_button);
     // Display WPML admin notices if there are any.
     wpcf_wpml_warning();
     // Transform the form data into an Enlimbo form
     $form = wpcf_form(self::FORM_NAME, $this->form);
     // Dark magic happens here.
     echo '<form method="post" action="" class="wpcf-fields-form wpcf-form-validate js-types-show-modal">';
     wpcf_admin_screen($post_type, $form->renderForm());
     echo '</form>';
     wpcf_add_admin_footer();
 }
/**
 * Menu page display.
 */
function wpcf_admin_menu_edit_tax()
{
    $post_type = current_filter();
    $title = __('View Taxonomy', 'wpcf');
    $add_new = false;
    if (WPCF_Roles::user_can_create('custom-taxonomy')) {
        $title = __('Add New Taxonomy', 'wpcf');
        if (isset($_GET['wpcf-tax'])) {
            $title = __('Edit Taxonomy', 'wpcf');
            $add_new = array('page' => 'wpcf-edit-tax');
        }
    }
    wpcf_add_admin_header($title, $add_new);
    wpcf_wpml_warning();
    $form = wpcf_form('wpcf_form_tax');
    echo '<form method="post" action="" class="wpcf-tax-form wpcf-form-validate js-types-show-modal">';
    wpcf_admin_screen($post_type, $form->renderForm());
    echo '</form>';
    wpcf_add_admin_footer();
}