Пример #1
0
/**
 * Editor callback form.
 */
function wpcf_fields_checkbox_editor_callback()
{
    $form = array();
    $value_not_selected = '';
    $value_selected = '';
    if (isset($_GET['field_id'])) {
        $field = wpcf_admin_fields_get_field($_GET['field_id']);
        if (!empty($field)) {
            if (isset($field['data']['display_value_not_selected'])) {
                $value_not_selected = $field['data']['display_value_not_selected'];
            }
            if (isset($field['data']['display_value_selected'])) {
                $value_selected = $field['data']['display_value_selected'];
            }
        }
    }
    $form['#form']['callback'] = 'wpcf_fields_checkbox_editor_submit';
    $form['display'] = array('#type' => 'radios', '#default_value' => 'db', '#name' => 'display', '#options' => array('display_from_db' => array('#title' => __('Display the value of this field from the database', 'wpcf'), '#name' => 'display', '#value' => 'db', '#inline' => true, '#after' => '<br />'), 'display_values' => array('#title' => __('Show one of these two values:', 'wpcf'), '#name' => 'display', '#value' => 'value')), '#inline' => true);
    $form['display-value-1'] = array('#type' => 'textfield', '#title' => '<td style="text-align:right;">' . __('Not selected:', 'wpcf') . '</td><td>', '#name' => 'display_value_not_selected', '#value' => $value_not_selected, '#inline' => true, '#before' => '<table><tr>', '#after' => '</td></tr>');
    $form['display-value-2'] = array('#type' => 'textfield', '#title' => '<td style="text-align:right;">' . __('Selected:', 'wpcf') . '</td><td>', '#name' => 'display_value_selected', '#value' => $value_selected, '#after' => '</tr></table>');
    $form['submit'] = array('#type' => 'submit', '#name' => 'submit', '#value' => __('Save Changes'), '#attributes' => array('class' => 'button-primary'));
    $f = wpcf_form('wpcf-form', $form);
    wpcf_admin_ajax_head('Insert checkbox', 'wpcf');
    echo '<form method="post" action="">';
    echo $f->renderForm();
    echo '</form>';
    wpcf_admin_ajax_footer();
}
Пример #2
0
/**
 * Editor callback form.
 */
function wpcf_fields_radio_editor_callback()
{
    wpcf_admin_ajax_head('Insert checkbox', 'wpcf');
    $field = wpcf_admin_fields_get_field($_GET['field_id']);
    if (empty($field)) {
        echo '<div class="message error"><p>' . __('Wrong field specified', 'wpcf') . '</p></div>';
        wpcf_admin_ajax_footer();
        return '';
    }
    $form = array();
    $form['#form']['callback'] = 'wpcf_fields_radio_editor_submit';
    $form['display'] = array('#type' => 'radios', '#default_value' => 'db', '#name' => 'display', '#options' => array('display_from_db' => array('#title' => __('Display the value of this field from the database', 'wpcf'), '#name' => 'display', '#value' => 'db', '#inline' => true, '#after' => '<br />'), 'display_values' => array('#title' => __('Show one of these values:', 'wpcf'), '#name' => 'display', '#value' => 'value')), '#inline' => true);
    if (!empty($field['data']['options'])) {
        $form['table-open'] = array('#type' => 'markup', '#markup' => '<table style="margin-top:20px;" cellpadding="0" cellspacing="8">');
        foreach ($field['data']['options'] as $option_id => $option) {
            if ($option_id == 'default') {
                continue;
            }
            $value = isset($option['display_value']) ? $option['display_value'] : $option['value'];
            $form['display-value-' . $option_id] = array('#type' => 'textfield', '#title' => $option['title'], '#name' => 'options[' . $option_id . ']', '#value' => $value, '#inline' => true, '#pattern' => '<tr><td style="text-align:right;"><LABEL></td><td><ELEMENT></td></tr>', '#attributes' => array('style' => 'width:200px;'));
        }
        $form['table-close'] = array('#type' => 'markup', '#markup' => '</table>');
    }
    $form['submit'] = array('#type' => 'markup', '#markup' => get_submit_button());
    $f = wpcf_form('wpcf-form', $form);
    echo '<form method="post" action="">';
    echo $f->renderForm();
    echo '</form>';
    wpcf_admin_ajax_footer();
}
Пример #3
0
/**
 * Add/Edit usermeta fields group
 *
 * @author Gen gen.i@icanlocalize.com
 * @since Types 1.3
 */
function wpcf_admin_menu_edit_user_fields()
{
    if (isset($_GET['group_id'])) {
        $title = __('Edit Usermeta Group', 'wpcf');
    } else {
        $title = __('Add New Usermeta Group', 'wpcf');
    }
    wpcf_add_admin_header($title);
    $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();
}
Пример #4
0
/**
 * Editor callback form.
 */
function wpcf_fields_checkbox_editor_callback()
{
    wp_enqueue_script('jquery');
    $form = array();
    $value_not_selected = '';
    $value_selected = '';
    if (isset($_GET['field_id'])) {
        $field = wpcf_admin_fields_get_field($_GET['field_id']);
        if (!empty($field)) {
            if (isset($field['data']['display_value_not_selected'])) {
                $value_not_selected = $field['data']['display_value_not_selected'];
            }
            if (isset($field['data']['display_value_selected'])) {
                $value_selected = $field['data']['display_value_selected'];
            }
        }
    }
    $form['#form']['callback'] = 'wpcf_fields_checkbox_editor_submit';
    $form['display'] = array('#type' => 'radios', '#default_value' => 'db', '#name' => 'display', '#options' => array('display_from_db' => array('#title' => __('Display the value of this field from the database', 'wpcf'), '#name' => 'display', '#value' => 'db', '#inline' => true, '#after' => '<br />'), 'display_values' => array('#title' => __('Enter values for \'selected\' and \'not selected\' states', 'wpcf'), '#name' => 'display', '#value' => 'value')), '#inline' => true);
    $form['states-start'] = array('#type' => 'markup', '#markup' => '<div id="wpcf-checkbox-states" style="display:none;margin-left:20px">');
    $form['display-value-1'] = array('#type' => 'textfield', '#title' => '<td style="text-align:right;">' . __('Not selected:', 'wpcf') . '</td><td>', '#name' => 'display_value_not_selected', '#value' => $value_not_selected, '#inline' => true, '#before' => '<table><tr>', '#after' => '</td></tr>');
    $form['display-value-2'] = array('#type' => 'textfield', '#title' => '<td style="text-align:right;">' . __('Selected:', 'wpcf') . '</td><td>', '#name' => 'display_value_selected', '#value' => $value_selected, '#before' => '<tr>', '#after' => '</tr></table>');
    $form['states-end'] = array('#type' => 'markup', '#markup' => '</div>');
    $form = wpcf_form_popup_add_optional($form);
    $help = array('url' => "http://wp-types.com/documentation/functions/checkbox/", 'text' => __('Checkbox help', 'wpcf'));
    $form = wpcf_form_popup_helper($form, __('Insert', 'wpcf'), __('Cancel', 'wpcf'), $help);
    $f = wpcf_form('wpcf-form', $form);
    add_action('admin_head_wpcf_ajax', 'wpcf_fields_checkbox_form_script');
    wpcf_admin_ajax_head('Insert checkbox', 'wpcf');
    echo '<form method="post" action="">';
    echo $f->renderForm();
    echo '</form>';
    wpcf_admin_ajax_footer();
}
Пример #5
0
/**
 * Show link to Control Custom Field
 *
 * @since 1.8.0
 *
 */
function wpcf_admin_fields_list_metabox_to_custom_fields_control()
{
    $form['table-1-open'] = array('#type' => 'markup', '#markup' => '<table class="wpcf-types-form-table widefat js-wpcf-slugize-container"><thead><tr><th>' . __('Post Field Control', 'wpcf') . '</th></tr></thead><tbody>', '_builtin' => true);
    $form['table-row-1-open'] = array('#type' => 'markup', '#markup' => '<tr><td>', '_builtin' => true);
    $form['table-row-1-content-1'] = array('#type' => 'markup', '#markup' => '<p>' . __('You can control Post Fields by removing them from the groups, changing type or just deleting.', 'wpcf'), '_builtin' => true);
    $form['table-row-1-content-2'] = array('#type' => 'markup', '#markup' => sprintf(' <a class="button" href="%s">%s</a></p>', Types_Page_Field_Control::get_page_url(Types_Field_Utils::DOMAIN_POSTS), __('Post Field Control', 'wpcf')), '_builtin' => true);
    $form['table-row-1-close'] = array('#type' => 'markup', '#markup' => '</td></tr>', '_builtin' => true);
    $form['table-1-close'] = array('#type' => 'markup', '#markup' => '</tbody></table>', '_builtin' => true);
    $form = wpcf_form(__FUNCTION__, $form);
    echo $form->renderForm();
}
Пример #6
0
 /**
  * Show box with a link to Term Field Control page.
  */
 function show_term_field_control_box()
 {
     $form = array();
     $form['table-1-open'] = array('#type' => 'markup', '#markup' => '<table class="wpcf-types-form-table widefat js-wpcf-slugize-container"><thead><tr><th>' . __('Term Field Control', 'wpcf') . '</th></tr></thead><tbody>', '_builtin' => true);
     $form['table-row-1-open'] = array('#type' => 'markup', '#markup' => '<tr><td>', '_builtin' => true);
     $form['table-row-1-content-1'] = array('#type' => 'markup', '#markup' => '<p>' . __('You can control Term Fields by removing them from the groups, changing type or just deleting.', 'wpcf'), '_builtin' => true);
     $form['table-row-1-content-2'] = array('#type' => 'markup', '#markup' => sprintf(' <a class="button" href="%s">%s</a></p>', Types_Page_Field_Control::get_page_url(Types_Field_Utils::DOMAIN_TERMS), __('Term Field Control', 'wpcf')), '_builtin' => true);
     $form['table-row-1-close'] = array('#type' => 'markup', '#markup' => '</td></tr>', '_builtin' => true);
     $form['table-1-close'] = array('#type' => 'markup', '#markup' => '</tbody></table>', '_builtin' => true);
     $form = wpcf_form(self::PAGE_NAME . '-field-control-box', $form);
     echo $form->renderForm();
 }
Пример #7
0
/**
 * Editor callback form.
 */
function wpcf_fields_url_editor_callback()
{
    $form = array();
    $form['#form']['callback'] = 'wpcf_fields_url_editor_submit';
    $form['title'] = array('#type' => 'textfield', '#title' => __('Title', 'wpcf'), '#description' => __('If set, this text will be displayed instead of raw data'), '#name' => 'title');
    $form['submit'] = array('#type' => 'submit', '#name' => 'submit', '#value' => __('Save Changes'), '#attributes' => array('class' => 'button-primary'));
    $f = wpcf_form('wpcf-form', $form);
    wpcf_admin_ajax_head('Insert URL', 'wpcf');
    echo '<form method="post" action="">';
    echo $f->renderForm();
    echo '</form>';
    wpcf_admin_ajax_footer();
}
Пример #8
0
/**
 * Editor callback form.
 */
function wpcf_fields_email_editor_callback()
{
    $last_settings = wpcf_admin_fields_get_field_last_settings($_GET['field_id']);
    $form = array();
    $form['#form']['callback'] = 'wpcf_fields_email_editor_submit';
    $form['title'] = array('#type' => 'textfield', '#title' => __('Title', 'wpcf'), '#description' => __('If set, this text will be displayed instead of raw data'), '#name' => 'title', '#value' => isset($last_settings['title']) ? $last_settings['title'] : '');
    $form['submit'] = array('#type' => 'markup', '#markup' => get_submit_button());
    $f = wpcf_form('wpcf-form', $form);
    wpcf_admin_ajax_head('Insert email', 'wpcf');
    echo '<form method="post" action="">';
    echo $f->renderForm();
    echo '</form>';
    wpcf_admin_ajax_footer();
}
Пример #9
0
/**
 * Editor callback form.
 */
function wpcf_fields_numeric_editor_callback()
{
    wp_enqueue_style('wpcf-fields', WPCF_EMBEDDED_RES_RELPATH . '/css/basic.css', array(), WPCF_VERSION);
    wp_enqueue_script('jquery');
    // Get field
    $field = wpcf_admin_fields_get_field($_GET['field_id']);
    if (empty($field)) {
        _e('Wrong field specified', 'wpcf');
        die;
    }
    $last_settings = wpcf_admin_fields_get_field_last_settings($_GET['field_id']);
    $form = array();
    $form['#form']['callback'] = 'wpcf_fields_numeric_editor_submit';
    $form['format'] = array('#type' => 'textfield', '#title' => __('Output format', 'wpcf'), '#description' => __("Similar to sprintf function. Default: 'FIELD_NAME: FIELD_VALUE'.", 'wpcf'), '#name' => 'format', '#value' => isset($last_settings['format']) ? $last_settings['format'] : 'FIELD_NAME: FIELD_VALUE');
    $form['submit'] = array('#type' => 'submit', '#name' => 'submit', '#value' => __('Insert shortcode', 'wpcf'), '#attributes' => array('class' => 'button-primary'));
    $f = wpcf_form('wpcf-form', $form);
    wpcf_admin_ajax_head('Insert numeric', 'wpcf');
    echo '<form method="post" action="">';
    echo $f->renderForm();
    echo '</form>';
}
Пример #10
0
/**
 * Editor callback form.
 */
function wpcf_fields_checkboxes_editor_callback()
{
    $form = array();
    $form['#form']['callback'] = 'wpcf_fields_checkboxes_editor_submit';
    $form['display'] = array('#type' => 'radios', '#default_value' => 'display_all', '#name' => 'display', '#options' => array('display_from_db' => array('#title' => __('Display the value of this field from the database', 'wpcf'), '#name' => 'display', '#value' => 'db', '#inline' => true, '#after' => '<br />'), 'display_all' => array('#title' => __('Display all values with separator', 'wpcf'), '#name' => 'display', '#value' => 'display_all', '#inline' => true, '#after' => '&nbsp;' . wpcf_form_simple(array('separator' => array('#type' => 'textfield', '#name' => 'separator', '#value' => ', ', '#inline' => true))) . '<br />'), 'display_values' => array('#title' => __('Show one of these two values:', 'wpcf'), '#name' => 'display', '#value' => 'value')), '#inline' => true);
    if (isset($_GET['field_id'])) {
        $field = wpcf_admin_fields_get_field($_GET['field_id']);
        if (!empty($field['data']['options'])) {
            foreach ($field['data']['options'] as $option_key => $option) {
                $form[$option_key . '-markup'] = array('#type' => 'markup', '#markup' => '<h3>' . $option['title'] . '</h3>');
                $form[$option_key . '-display-value-1'] = array('#type' => 'textfield', '#title' => '<td style="text-align:right;">' . __('Not selected:', 'wpcf') . '</td><td>', '#name' => 'options[' . $option_key . '][display_value_not_selected]', '#value' => $option['display_value_not_selected'], '#inline' => true, '#before' => '<table><tr>', '#after' => '</td></tr>');
                $form[$option_key . '-display-value-2'] = array('#type' => 'textfield', '#title' => '<td style="text-align:right;">' . __('Selected:', 'wpcf') . '</td><td>', '#name' => 'options[' . $option_key . '][display_value_selected]', '#value' => $option['display_value_selected'], '#after' => '</tr></table>');
            }
        }
    }
    $form['submit'] = array('#type' => 'submit', '#name' => 'submit', '#value' => __('Save Changes'), '#attributes' => array('class' => 'button-primary'));
    $f = wpcf_form('wpcf-form', $form);
    wpcf_admin_ajax_head('Insert checkbox', 'wpcf');
    echo '<form method="post" action="">';
    echo $f->renderForm();
    echo '</form>';
    wpcf_admin_ajax_footer();
}
Пример #11
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();
 }
Пример #12
0
/**
 * Menu page display.
 */
function wpcf_admin_menu_migration()
{
    echo wpcf_add_admin_header(__('Migration', 'wpcf'));
    echo '<br /><form method="post" action="" id="wpcf-migration-form" class="wpcf-migration-form ' . 'wpcf-form-validate" enctype="multipart/form-data">';
    $form = wpcf_form('wpcf_form_migration');
    echo $form->renderForm();
    echo '</form>';
    echo wpcf_add_admin_footer();
}
 /**
  * Summary.
  *
  * Description.
  *
  * @since x.x.x
  * @access (for functions: only use if private)
  *
  * @see Function/method/class relied on
  * @link URL
  * @global type $varname Description.
  * @global type $varname Description.
  *
  * @param type $var Description.
  * @param type $var Optional. Description.
  * @return type Description.
  */
 public function add_usermeta_to_groups()
 {
     /**
      * check nonce
      */
     if (0 || !isset($_REQUEST['_wpnonce']) || !wp_verify_nonce($_REQUEST['_wpnonce'], 'custom_fields_control')) {
         $this->verification_failed_and_die();
     }
     $form = $this->get_group_list(array(), 'wpcf-usermeta');
     $form = wpcf_form(__FUNCTION__, $form);
     echo $form->renderForm();
     die;
 }
/**
 * Menu page display.
 */
function wpcf_admin_menu_settings()
{
    ob_start();
    wpcf_add_admin_header(__('Settings', 'wpcf'));
    ?>
<form method="post" action="" id="wpcf-general-settings-form" class="wpcf-settings-form wpcf-form-validate">
<?php 
    $form = wpcf_form('wpcf_form_general_settings');
    echo $form->renderForm();
    ?>
    </form>
<?php 
    wpcf_add_admin_footer();
    echo ob_get_clean();
}
 /**
  * Summary.
  *
  * Description.
  *
  * @since x.x.x
  * @access (for functions: only use if private)
  *
  * @see Function/method/class relied on
  * @link URL
  * @global type $varname Description.
  * @global type $varname Description.
  *
  * @param type $var Description.
  * @param type $var Optional. Description.
  * @return type Description.
  */
 public function box_taxonomy_type()
 {
     $form = array();
     $form['make-hierarchical'] = array('#type' => 'radios', '#name' => 'ct[hierarchical]', '#default_value' => empty($this->ct['hierarchical']) || $this->ct['hierarchical'] == 'hierarchical' ? 'hierarchical' : 'flat', '#inline' => true, '#options' => array(sprintf('<b>%s</b> - %s', __('Hierarchical', 'wpcf'), __('like post categories, with parent / children relationship and checkboxes to select taxonomy', 'wpcf')) => 'hierarchical', sprintf('<b>%s</b> - %s', __('Flat', 'wpcf'), __('like post tags, with a text input to enter terms', 'wpcf')) => 'flat'));
     $form = wpcf_form(__FUNCTION__, $form);
     echo $form->renderForm();
 }
 /**
  * Summary.
  *
  * Description.
  *
  * @since x.x.x
  * @access (for functions: only use if private)
  *
  * @see Function/method/class relied on
  * @link URL
  * @global type $varname Description.
  * @global type $varname Description.
  *
  * @param type $var Description.
  * @param type $var Optional. Description.
  * @return type Description.
  */
 protected function print_notice($notice, $add_wrap = 'no-wrap', $print = true)
 {
     $form = array();
     if ('add-wpcf-inside' == $add_wrap) {
         $form['wrap-begin'] = array('#type' => 'markup', '#markup' => '<div class="wpcf-inside">');
     }
     $form['alert'] = array('#type' => 'notice', '#markup' => $notice);
     if ('add-wpcf-inside' == $add_wrap) {
         $form['wrap-end'] = array('#type' => 'markup', '#markup' => '</div>');
     }
     $form = wpcf_form(__FUNCTION__, $form);
     if ($print) {
         echo $form->renderForm();
     } else {
         return $form->renderForm();
     }
 }
/**
 * 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();
}
 public function ajax_filter_dialog()
 {
     /**
      * check nonce
      */
     if (!isset($_REQUEST['id']) || !isset($_REQUEST['_wpnonce']) || !isset($_REQUEST['type']) || !wp_verify_nonce($_REQUEST['_wpnonce'], $_REQUEST['type'])) {
         _e('Verification failed.', 'wpcf');
         die;
     }
     if (isset($_REQUEST['all_fields']) && !is_array($_POST['all_fields'])) {
         parse_str($_REQUEST['all_fields'], $_REQUEST['all_fields']);
     }
     $form = array();
     $tabs = $this->get_tabs_for_filter_dialog();
     // html: open tabs menu
     $html_tabs_menu = '<ul class="wpcf-tabs-menu">';
     // css: class for first menu
     $first_menu_active = ' class="wpcf-tabs-menu-current"';
     // build tabs menu
     foreach ($tabs as $id => $tab) {
         // html: tabs menu list item
         $html_tabs_menu .= '<li' . $first_menu_active . '>';
         $html_tabs_menu .= '<span data-open-tab="#' . $id . '">';
         $html_tabs_menu .= $tab['title'] . '</span></li>';
         // next menu won't be active
         $first_menu_active = '';
     }
     // html: close tabs menu
     $html_tabs_menu .= '</ul>';
     // form: add tabs menu
     $form['tabs-menu'] = array('#type' => 'markup', '#markup' => $html_tabs_menu);
     // form: open tabs
     $form['tabs-open'] = array('#type' => 'markup', '#markup' => '<div class="wpcf-tabs">');
     // build tabs
     foreach ($tabs as $id => $tab) {
         // form: tab open
         $form['tabs-tab-open-' . $id] = array('#type' => 'markup', '#markup' => '<div id="' . $id . '">');
         // form: tab content
         $this->form_add_filter_dialog($id, $form);
         // form: tab close
         $form['tabs-tab-close-' . $id] = array('#type' => 'markup', '#markup' => '</div>');
     }
     // form: open tabs
     $form['tabs-close'] = array('#type' => 'markup', '#markup' => '</div>');
     $form = wpcf_form(__FUNCTION__, $form);
     echo $form->renderForm();
     die;
 }
Пример #19
0
/**
 * Editor callback form.
 */
function wpcf_fields_image_editor_callback()
{
    wp_enqueue_style('wpcf-fields-image', WPCF_EMBEDDED_RES_RELPATH . '/css/basic.css', array(), WPCF_VERSION);
    wp_enqueue_script('jquery');
    // Get field
    $field = wpcf_admin_fields_get_field($_GET['field_id']);
    if (empty($field)) {
        _e('Wrong field specified', 'wpcf');
        die;
    }
    // Get post_ID
    $post_ID = false;
    if (isset($_POST['post_id'])) {
        $post_ID = intval($_POST['post_id']);
    } else {
        $http_referer = explode('?', $_SERVER['HTTP_REFERER']);
        if (isset($http_referer[1])) {
            parse_str($http_referer[1], $http_referer);
            if (isset($http_referer['post'])) {
                $post_ID = $http_referer['post'];
            }
        }
    }
    // Get attachment
    $image = false;
    $attachment_id = false;
    if ($post_ID) {
        $image = get_post_meta($post_ID, wpcf_types_get_meta_prefix($field) . $field['slug'], true);
        if (!empty($image)) {
            // Get attachment by guid
            global $wpdb;
            $attachment_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM {$wpdb->posts}\r\r\n    WHERE post_type = 'attachment' AND guid=%s", $image));
        }
    }
    // Get post type
    $post_type = '';
    if ($post_ID) {
        $post_type = get_post_type($post_ID);
    } else {
        $http_referer = explode('?', $_SERVER['HTTP_REFERER']);
        parse_str($http_referer[1], $http_referer);
        if (isset($http_referer['post_type'])) {
            $post_type = $http_referer['post_type'];
        }
    }
    $image_data = wpcf_fields_image_get_data($image);
    if (!in_array($post_type, array('view', 'view-template'))) {
        // We must ignore errors here and treat image as outsider
        if (!empty($image_data['error'])) {
            $image_data['is_outsider'] = 1;
            $image_data['is_attachment'] = 0;
        }
    } else {
        if (!empty($image_data['error'])) {
            $image_data['is_outsider'] = 0;
            $image_data['is_attachment'] = 0;
        }
    }
    $last_settings = wpcf_admin_fields_get_field_last_settings($_GET['field_id']);
    $form = array();
    $form['#form']['callback'] = 'wpcf_fields_image_editor_submit';
    if ($attachment_id) {
        $form['preview'] = array('#type' => 'markup', '#markup' => '<div style="position:absolute; margin-left:300px;">' . wp_get_attachment_image($attachment_id, 'thumbnail') . '</div>');
    }
    $alt = '';
    $title = '';
    if ($attachment_id) {
        $alt = trim(strip_tags(get_post_meta($attachment_id, '_wp_attachment_image_alt', true)));
        $attachment_post = get_post($attachment_id);
        if (!empty($attachment_post)) {
            $title = trim(strip_tags($attachment_post->post_title));
        } else {
            if (!empty($alt)) {
                $title = $alt;
            }
        }
        if (empty($alt)) {
            $alt = $title;
        }
    }
    $form['title'] = array('#type' => 'textfield', '#title' => __('Image title', 'wpcf'), '#description' => __('Title text for the image, e.g. &#8220;The Mona Lisa&#8221;', 'wpcf'), '#name' => 'title', '#value' => isset($last_settings['title']) ? $last_settings['title'] : $title);
    $form['alt'] = array('#type' => 'textfield', '#title' => __('Alternate Text', 'wpcf'), '#description' => __('Alt text for the image, e.g. &#8220;The Mona Lisa&#8221;', 'wpcf'), '#name' => 'alt', '#value' => isset($last_settings['alt']) ? $last_settings['alt'] : $alt);
    $form['alignment'] = array('#type' => 'radios', '#title' => __('Alignment', 'wpcf'), '#name' => 'alignment', '#default_value' => isset($last_settings['alignment']) ? $last_settings['alignment'] : 'none', '#options' => array(__('None', 'wpcf') => 'none', __('Left', 'wpcf') => 'left', __('Center', 'wpcf') => 'center', __('Right', 'wpcf') => 'right'));
    if (!in_array($post_type, array('view', 'view-template'))) {
        $attributes_outsider = $image_data['is_outsider'] ? array('disabled' => 'disabled') : array();
        $attributes_attachment = !$image_data['is_attachment'] ? array('disabled' => 'disabled') : array();
    } else {
        $attributes_outsider = array();
        $attributes_attachment = array();
    }
    if (!in_array($post_type, array('view', 'view-template')) && $image_data['is_outsider']) {
        $form['notice'] = array('#type' => 'markup', '#markup' => '<div class="message error" style="margin:0 0 20px 0;"><p>' . __('Types can only resize images that you upload to this site and not images from other domains.', 'wpcf') . '</p></div>');
    } else {
        if ($image_data['is_outsider']) {
            $form['notice'] = array('#type' => 'markup', '#markup' => '<div class="message error" style="margin:0 0 20px 0;"><p>' . __('Types will be able to resize images that are uploaded to the post. If you specify URLs of images on other sites, Types will not resize them.', 'wpcf') . '</p></div>');
        }
    }
    if ($image_data['is_attachment']) {
        $default_value = isset($last_settings['image-size']) ? $last_settings['image-size'] : 'thumbnail';
    } else {
        if (!$image_data['is_outsider']) {
            $default_value = 'wpcf-custom';
        } else {
            $default_value = 'thumbnail';
        }
    }
    $form['size'] = array('#type' => 'radios', '#title' => __('Pre-defined sizes', 'wpcf'), '#name' => 'image-size', '#default_value' => $default_value, '#options' => array('thumbnail' => array('#title' => __('Thumbnail', 'wpcf'), '#value' => 'thumbnail', '#attributes' => $attributes_attachment), 'medium' => array('#title' => __('Medium', 'wpcf'), '#value' => 'medium', '#attributes' => $attributes_attachment), 'large' => array('#title' => __('Large', 'wpcf'), '#value' => 'large', '#attributes' => $attributes_attachment), 'full' => array('#title' => __('Full Size', 'wpcf'), '#value' => 'full', '#attributes' => $attributes_attachment), 'wpcf-custom' => array('#title' => __('Custom size', 'wpcf'), '#value' => 'wpcf-custom', '#attributes' => $attributes_outsider)));
    $form['toggle-open'] = array('#type' => 'markup', '#markup' => '<div id="wpcf-toggle" style="display:none;">');
    $form['width'] = array('#type' => 'textfield', '#title' => __('Width', 'wpcf'), '#description' => __('Specify custom width', 'wpcf'), '#name' => 'width', '#value' => isset($last_settings['width']) ? $last_settings['width'] : '', '#suffix' => '&nbsp;px', '#attributes' => $attributes_outsider);
    $form['height'] = array('#type' => 'textfield', '#title' => __('Height', 'wpcf'), '#description' => __('Specify custom height', 'wpcf'), '#name' => 'height', '#value' => isset($last_settings['height']) ? $last_settings['height'] : '', '#suffix' => '&nbsp;px', '#attributes' => $attributes_outsider);
    $form['proportional'] = array('#type' => 'checkbox', '#title' => __('Keep proportional', 'wpcf'), '#name' => 'proportional', '#default_value' => 1, '#attributes' => $attributes_outsider);
    $form['toggle-close'] = array('#type' => 'markup', '#markup' => '</div>', '#attributes' => $attributes_outsider);
    if ($post_ID) {
        $form['post_id'] = array('#type' => 'hidden', '#name' => 'post_id', '#value' => $post_ID);
    }
    $form['submit'] = array('#type' => 'submit', '#name' => 'submit', '#value' => __('Insert shortcode', 'wpcf'), '#attributes' => array('class' => 'button-primary'));
    $f = wpcf_form('wpcf-form', $form);
    wpcf_admin_ajax_head('Insert email', 'wpcf');
    echo '<form method="post" action="">';
    echo $f->renderForm();
    echo '</form>';
    ?>

    <script type="text/javascript">
        //<![CDATA[
        jQuery(document).ready(function(){
            jQuery('input:radio[name="image-size"]').change(function(){
                if (jQuery(this).val() == 'wpcf-custom') {
                    jQuery('#wpcf-toggle').slideDown();
                } else {
                    jQuery('#wpcf-toggle').slideUp();
                }
            });
            if (jQuery('input:radio[name="image-size"]:checked').val() == 'wpcf-custom') {
                jQuery('#wpcf-toggle').show();
            }
        });
        //]]>
    </script>
    <?php 
    wpcf_admin_ajax_footer();
}
Пример #20
0
/**
 * Editor callback form.
 */
function wpcf_fields_file_editor_callback()
{
    wp_enqueue_style('wpcf-fields-file', WPCF_EMBEDDED_RES_RELPATH . '/css/basic.css', array(), WPCF_VERSION);
    // Get field
    $field = wpcf_admin_fields_get_field($_GET['field_id']);
    if (empty($field)) {
        _e('Wrong field specified', 'wpcf');
        die;
    }
    // Get post_ID
    $post_ID = false;
    if (isset($_POST['post_id'])) {
        $post_ID = intval($_POST['post_id']);
    } else {
        $http_referer = explode('?', $_SERVER['HTTP_REFERER']);
        parse_str($http_referer[1], $http_referer);
        if (isset($http_referer['post'])) {
            $post_ID = $http_referer['post'];
        }
    }
    // Get attachment
    $attachment_id = false;
    if ($post_ID) {
        $file = get_post_meta($post_ID, wpcf_types_get_meta_prefix($field) . $field['slug'], true);
        if (!empty($file)) {
            // Get attachment by guid
            global $wpdb;
            $attachment_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM {$wpdb->posts}\r\n    WHERE post_type = 'attachment' AND guid=%s", $file));
        }
    }
    $last_settings = wpcf_admin_fields_get_field_last_settings($_GET['field_id']);
    $form = array();
    $form['#form']['callback'] = 'wpcf_fields_file_editor_submit';
    if ($attachment_id) {
        $form['preview'] = array('#type' => 'markup', '#markup' => '<div class="message updated" style="margin: 0 0 20px 0"><p>' . $file . '</p></div>');
    }
    $form['link'] = array('#type' => 'checkbox', '#title' => __('Display as link', 'wpcf'), '#name' => 'link', '#default_value' => isset($last_settings['link']) ? $last_settings['link'] : 1);
    $form['title'] = array('#type' => 'textfield', '#title' => __('Link title', 'wpcf'), '#name' => 'title', '#value' => isset($last_settings['title']) ? $last_settings['title'] : '');
    $form['class'] = array('#type' => 'textfield', '#title' => __('Class', 'wpcf'), '#name' => 'class', '#value' => isset($last_settings['class']) ? $last_settings['class'] : '');
    $form['style'] = array('#type' => 'textfield', '#title' => __('Style', 'wpcf'), '#name' => 'style', '#value' => isset($last_settings['style']) ? $last_settings['style'] : '');
    $form['submit'] = array('#type' => 'submit', '#name' => 'submit', '#value' => __('Insert shortcode', 'wpcf'), '#attributes' => array('class' => 'button-primary'));
    $f = wpcf_form('wpcf-form', $form);
    wpcf_admin_ajax_head('Insert email', 'wpcf');
    echo '<form method="post" action="">';
    echo $f->renderForm();
    echo '</form>';
    wpcf_admin_ajax_footer();
}
function wpcf_admin_metabox_relationship($post_type)
{
    $form = array();
    $form['description'] = array('#type' => 'markup', '#markup' => sprintf('<p class="description">%s</p>', sprintf('%s <a href="%s" target="_blank">%s</a>.', __('Parent/child relationship lets you connect between posts of different types. When you edit a parent, you will see its children listed in a table and you can edit the fields of the children. When you edit a child, you can choose the parents. On the front-end, you can display a list of children or information about the parents.', 'wpcf'), Types_Helper_Url::get_url('post-relationship', true, 'parent_child_relationship', Types_Helper_Url::UTM_MEDIUM_POSTEDIT), __('Parent/child documentation', 'wpcf'))));
    $custom_types = get_option(WPCF_OPTION_NAME_CUSTOM_TYPES, array());
    $is_error = false;
    $error_message = '';
    // Detect situations when we cannot configure post relationships yet. Render a message and finish.
    $is_unsaved_post_type = !isset($_REQUEST['wpcf-post-type']) || !isset($custom_types[$_REQUEST['wpcf-post-type']]);
    if ($is_unsaved_post_type) {
        $is_error = true;
        $error_message = __('Please save first, before you can edit the relationship.', 'wpcf');
    }
    $is_attachment = isset($_REQUEST['wpcf-post-type']) && 'attachment' == $_REQUEST['wpcf-post-type'];
    if ($is_attachment) {
        $is_error = true;
        $error_message = __('Post relationships are not allowed for the Media post type.', 'wpcf');
    }
    if ($is_error) {
        $form['alert'] = array('#type' => 'notice', '#markup' => $error_message);
        $form = wpcf_form(__FUNCTION__, $form);
        echo $form->renderForm();
        return;
    }
    $post_type = $custom_types[$_REQUEST['wpcf-post-type']];
    unset($custom_types);
    // No problems detected, go ahead and render the options.
    // belongs/children section
    $has = wpcf_pr_admin_get_has($post_type['slug']);
    $belongs = wpcf_pr_admin_get_belongs($post_type['slug']);
    $post_types = get_post_types('', 'objects');
    // parents
    $form['parent-h3'] = array('#type' => 'markup', '#markup' => sprintf('<h3>%s</h3>', __('Parent Post Types:', 'wpcf')));
    $form['parent-description'] = array('#type' => 'markup', '#markup' => sprintf('<p class="description">%s</p>', __('Select which post types will be parents of this type.', 'wpcf')));
    $options = array();
    // Build excluded post types
    global $wpcf;
    $excluded_post_types = $wpcf->excluded_post_types;
    $excluded_post_types[] = $post_type['slug'];
    // Explicitly exclude attachments for post relationships because there is no GUI for it
    // (but we're not excluding them from all Types functionality)
    $excluded_post_types[] = 'attachment';
    foreach ($post_types as $post_type_option_slug => $post_type_option) {
        $is_excluded = in_array($post_type_option_slug, $excluded_post_types);
        $has_no_ui = !$post_type_option->show_ui && !apply_filters('wpcf_show_ui_hide_in_relationships', true);
        if ($is_excluded || $has_no_ui) {
            continue;
        }
        $options[$post_type_option_slug] = array('#name' => 'ct[post_relationship][belongs][' . $post_type_option_slug . ']', '#title' => $post_type_option->labels->singular_name, '#default_value' => isset($belongs[$post_type_option_slug]), '#inline' => true, '#before' => '<li>', '#after' => '</li>', '#attributes' => array('class' => 'js-wpcf-relationship-checkbox', 'data-wpcf-type' => 'belongs', 'data-wpcf-value' => esc_attr($post_type_option_slug), 'data-wpcf-message-disabled' => esc_attr__('This post type is disabled, becouse is used as child post.', 'wpcf')));
        if (isset($has[$post_type_option_slug])) {
            $options[$post_type_option_slug]['#before'] = '<li class="disabled">';
            $options[$post_type_option_slug]['#attributes']['disabled'] = 'disabled';
        }
    }
    $form['table-pr-belongs-form'] = array('#type' => 'checkboxes', '#options' => $options, '#name' => 'ct[post_relationship]', '#inline' => true, '#before' => '<ul>', '#after' => '</ul>');
    // child posts
    $form['child-h3'] = array('#type' => 'markup', '#markup' => sprintf('<hr /><h3>%s</h3>', __('Children Post Types:', 'wpcf')));
    $form['child-description'] = array('#type' => 'markup', '#markup' => sprintf('<p class="description">%s</p>', __('Select which post types will be children of this type.', 'wpcf')));
    $options = array();
    foreach ($post_types as $post_type_option_slug => $post_type_option) {
        if (in_array($post_type_option_slug, $excluded_post_types) || !$post_type_option->show_ui && !apply_filters('wpcf_show_ui_hide_in_relationships', true)) {
            continue;
        }
        $nonce = sprintf('child-post-fields-%s-%s', $post_type['slug'], $post_type_option_slug);
        $a = sprintf(' <span>(<a class="js-wpcf-edit-child-post-fields" href="#" data-wpcf-nonce="%s" data-wpcf-child="%s" data-wpcf-parent="%s" data-wpcf-title="%s" data-wpcf-buttons-apply="%s" data-wpcf-buttons-cancel="%s" data-wpcf-message-loading="%s" data-wpcf-save-status="%s">%s</a>)</span>', esc_attr(wp_create_nonce($nonce)), esc_attr($post_type_option_slug), esc_attr($post_type['slug']), esc_attr(sprintf(__('Select child fields from %s to be displayed in Post Relationship table', 'wpcf'), $post_type_option->labels->singular_name)), esc_attr__('Apply', 'wpcf'), esc_attr__('Cancel', 'wpcf'), esc_attr__('Please Wait, Loading…', 'wpcf'), esc_attr(isset($has[$post_type_option_slug]) ? 'saved' : 'new'), esc_attr__('Select fields', 'wpcf'));
        $options[$post_type_option_slug] = array('#name' => 'ct[post_relationship][has][' . $post_type_option_slug . ']', '#title' => $post_type_option->labels->singular_name, '#inline' => true, '#before' => '<li>', '#after' => $a . '</li>', '#attributes' => array('class' => 'js-wpcf-relationship-checkbox', 'data-wpcf-type' => 'has', 'data-wpcf-value' => esc_attr($post_type_option_slug), 'data-wpcf-message-disabled' => esc_attr__('This post type is disabled, becouse is used as parent post.', 'wpcf')));
        // Check if it already belongs
        if (isset($belongs[$post_type_option_slug])) {
            $options[$post_type_option_slug]['#before'] = '<li class="disabled">';
            $options[$post_type_option_slug]['#attributes']['disabled'] = 'disabled';
        } else {
            if (isset($has[$post_type_option_slug])) {
                $options[$post_type_option_slug]['#default_value'] = true;
                $options[$post_type_option_slug]['#before'] = '<li class="active">';
            }
        }
    }
    $form['table-pr-has-form'] = array('#type' => 'checkboxes', '#options' => $options, '#name' => 'ct[post_relationship]', '#inline' => true, '#before' => '<ul>', '#after' => '</ul>');
    $form = wpcf_form(__FUNCTION__, $form);
    echo $form->renderForm();
}
Пример #22
0
/**
 * Menu page display.
 */
function wpcf_admin_menu_settings()
{
    $show_toolset_messages = !WPCF_Types_Marketing_Messages::check_register();
    ob_start();
    wpcf_add_admin_header(__('Settings', 'wpcf'));
    ?>
    <p style="font-weight: bold;"><?php 
    _e('This screen contains the Types settings for your site.', 'wpcf');
    ?>
</p>
    <ul class="horlist">
        <li><a href="#types-image-settings"><?php 
    _e('Image Settings', 'wpcf');
    ?>
</a></li>
        <li><a href="#types-general-settings"><?php 
    _e('General Setings', 'wpcf');
    ?>
</a></li>
        <?php 
    if ($show_toolset_messages) {
        ?>
<li><a href="#toolset-messages"><?php 
        _e('Toolset Messages', 'wpcf');
        ?>
</a></li><?php 
    }
    ?>
        <li><a href="#debug"><?php 
    _e('Debug Information', 'wpcf');
    ?>
</a></li>
    </ul>
    <br style='clear:both'/><br /><br />
    <a id="types-image-settings"></a>
    <table class="widefat" id="types_image_settings_table">
        <thead>
            <tr>
                <th><?php 
    _e('Image Settings', 'wpcf');
    ?>
</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>
                    <?php 
    echo '<br /><form method="post" action="" id="wpcf-image-settings-form" class="wpcf-settings-form ' . 'wpcf-form-validate">';
    $form = wpcf_form('wpcf_form_image_settings');
    echo $form->renderForm();
    echo '</form>';
    ?>
                </td>
            </tr>
        </tbody>
    </table>
    <br /><br />
    <a id="types-general-settings"></a>
    <table class="widefat" id="types_general_settings_table">
        <thead>
            <tr>
                <th><?php 
    _e('General Settings', 'wpcf');
    ?>
</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>
                    <?php 
    echo '<br /><form method="post" action="" id="wpcf-general-settings-form" class="wpcf-settings-form ' . 'wpcf-form-validate">';
    $form = wpcf_form('wpcf_form_general_settings');
    echo $form->renderForm();
    echo '</form>';
    ?>
                </td>
            </tr>
        </tbody>
    </table>
    <br /><br />
<?php 
    /**
     * Toolset Messages
     */
    if ($show_toolset_messages) {
        ?>
    <a id="toolset-messages"></a>
    <table class="widefat" id="toolset_messages">
        <thead>
            <tr>
                <th><?php 
        _e('Toolset Messages', 'wpcf');
        ?>
</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>
                    <?php 
        echo '<br /><form method="post" action="" id="wpcf-toolset-messages-form" class="wpcf-settings-form ' . 'wpcf-form-validate">';
        $form = wpcf_form('wpcf_form_toolset_messages');
        echo $form->renderForm();
        echo '</form>';
        ?>
                </td>
            </tr>
        </tbody>
    </table>
    <br /><br />
<?php 
    }
    /**
     * Debug Information
     */
    ?>
    <a id="debug"></a>
    <table class="widefat" id="debug_table">
        <thead>
            <tr>
                <th><?php 
    _e('Debug Information', 'wpcf');
    ?>
</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>
<?php 
    printf(__('For retrieving debug information if asked by a support person, use the <a href="%s">debug information</a> page.', 'wpcf'), admin_url('admin.php?page=wpcf-debug-information'));
    ?>
                </td>
            </tr>
        </tbody>
    </table>
    <?php 
    wpcf_add_admin_footer();
    echo ob_get_clean();
}
Пример #23
0
 /**
  * Render content of a metabox for associating the field group with taxonomies.
  */
 public function box_where()
 {
     // Filter taxonomies
     $taxonomy_slugs = $this->get_relevant_taxonomy_slugs();
     $currently_supported_taxonomy_slugs = $this->get_field_group_id() != 0 ? $this->field_group->get_associated_taxonomies() : array();
     $fields_to_clear_class = 'js-wpcf-filter-support-taxonomy';
     $form_tax = array();
     foreach ($taxonomy_slugs as $taxonomy_slug) {
         $form_tax[$taxonomy_slug] = array('#type' => 'hidden', '#name' => sprintf('wpcf[group][taxonomies][%s]', esc_attr($taxonomy_slug)), '#id' => 'wpcf-form-groups-support-taxonomy-' . $taxonomy_slug, '#attributes' => array('class' => $fields_to_clear_class, 'data-wpcf-label' => WPCF_Utils::taxonomy_slug_to_label($taxonomy_slug)), '#value' => in_array($taxonomy_slug, $currently_supported_taxonomy_slugs) ? $taxonomy_slug : '', '#inline' => true);
     }
     // generate wrapper and button
     $form_tax += $this->filter_wrap('wpcf-filter-dialog-edit', array('data-wpcf-buttons-apply' => esc_attr__('Apply', 'wpcf'), 'data-wpcf-buttons-cancel' => esc_attr__('Cancel', 'wpcf'), 'data-wpcf-dialog-title' => esc_attr__('Where to use this Field Group', 'wpcf'), 'data-wpcf-field-prefix' => esc_attr('wpcf-form-groups-support-taxonomy-'), 'data-wpcf-field-to-clear-class' => esc_attr('.' . $fields_to_clear_class), 'data-wpcf-id' => esc_attr($this->update['id']), 'data-wpcf-message-any' => esc_attr__('None', 'wpcf'), 'data-wpcf-message-loading' => esc_attr__('Please wait, Loading…', 'wpcf')), true, false);
     $form = array();
     // Now starting form
     $form['supports-table-open'] = array('#type' => 'markup', '#markup' => sprintf('<p class="wpcf-fields-group-conditions-description js-wpcf-fields-group-conditions-none">%s</p>', __('By default this group of fields will appear when editing all terms from all taxonomies. Select specific Taxonomies to use these fields with.', 'wpcf')));
     // Description: Terms set
     $form['supports-msg-conditions-taxonomies'] = array('#type' => 'markup', '#markup' => sprintf('<p class="wpcf-fields-group-conditions-description js-wpcf-fields-group-conditions-condition js-wpcf-fields-group-conditions-taxonomies">%s <span></span></p>', __('This Fields Group is used with the following Taxonomies:', 'wpcf')));
     // Terms
     $form = $form + $form_tax;
     // setup common setting for forms
     $form = $this->common_form_setup($form);
     // render form
     $form = wpcf_form(__FUNCTION__, $form);
     echo $form->renderForm();
 }
 public function types_styling_editor()
 {
     $form = $this->add_admin_style(array());
     $form = wpcf_form(__FUNCTION__, $form);
     echo $form->renderForm();
 }
Пример #25
0
 /**
  * Legacy (hacky) AJAX call to get a list of term field groups on the Term Fields Control page.
  *
  * Should not be used anywhere else.
  */
 public function termmeta_control_get_groups()
 {
     // nonce from wpcf_fields_contol_common_resources().
     if (!wp_verify_nonce(wpcf_getpost('_wpnonce'), 'custom_fields_control')) {
         die('Verification failed.');
         // todo wpv_ajax_...
     }
     require_once WPCF_INC_ABSPATH . '/classes/class.types.admin.control.fields.php';
     $tacf = new Types_Admin_Control_Fields();
     $form = $tacf->get_group_list(array(), WPCF_Field_Term_Definition_Factory::FIELD_DEFINITIONS_OPTION);
     $form = wpcf_form(__FUNCTION__, $form);
     echo $form->renderForm();
     die;
 }
Пример #26
0
/**
 * TinyMCE editor form.
 */
function wpcf_fields_date_editor_callback()
{
    $last_settings = wpcf_admin_fields_get_field_last_settings($_GET['field_id']);
    wp_enqueue_script('jquery');
    $form = array();
    $form['#form']['callback'] = 'wpcf_fields_date_editor_form_submit';
    $form['style'] = array('#type' => 'radios', '#name' => 'wpcf[style]', '#options' => array(__('Show as calendar', 'wpcf') => 'calendar', __('Show as text', 'wpcf') => 'text'), '#default_value' => isset($last_settings['style']) ? $last_settings['style'] : 'text', '#after' => '<br />');
    $date_formats = apply_filters('date_formats', array(__('F j, Y'), 'Y/m/d', 'm/d/Y', 'd/m/Y'));
    $options = array();
    foreach ($date_formats as $format) {
        $title = date($format, time());
        $field['#title'] = $title;
        $field['#value'] = $format;
        $options[] = $field;
    }
    $custom_format = isset($last_settings['format-custom']) ? $last_settings['format-custom'] : get_option('date_format');
    $options[] = array('#title' => __('Custom', 'wpcf'), '#value' => 'custom', '#suffix' => wpcf_form_simple(array('custom' => array('#name' => 'wpcf[format-custom]', '#type' => 'textfield', '#value' => $custom_format, '#suffix' => '&nbsp;' . date($custom_format, time()), '#inline' => true))));
    $form['toggle-open'] = array('#type' => 'markup', '#markup' => '<div id="wpcf-toggle" style="display:none;">');
    $form['format'] = array('#type' => 'radios', '#name' => 'wpcf[format]', '#options' => $options, '#default_value' => isset($last_settings['format']) ? $last_settings['format'] : get_option('date_format'), '#after' => '<a href="http://codex.wordpress.org/Formatting_Date_and_Time" target="_blank">' . __('Documentation on date and time formatting', 'wpcf') . '</a>');
    $form['toggle-close'] = array('#type' => 'markup', '#markup' => '</div>');
    $form['field_id'] = array('#type' => 'hidden', '#name' => 'wpcf[field_id]', '#value' => $_GET['field_id']);
    $form['submit'] = array('#type' => 'submit', '#name' => 'submit', '#value' => __('Insert date', 'wpcf'), '#attributes' => array('class' => 'button-primary'));
    $f = wpcf_form('wpcf-fields-date-editor', $form);
    add_action('admin_head_wpcf_ajax', 'wpcf_fields_date_editor_form_script');
    wpcf_admin_ajax_head(__('Insert date', 'wpcf'));
    echo '<form id="wpcf-form" method="post" action="">';
    echo $f->renderForm();
    echo '</form>';
    wpcf_admin_ajax_footer();
}
 /**
  * Taxonomies
  */
 public function box_taxonomies()
 {
     $form = array();
     $taxonomies = get_taxonomies('', 'objects');
     $options = array();
     foreach ($taxonomies as $category_slug => $category) {
         if (false || $category_slug == 'nav_menu' || $category_slug == 'link_category' || $category_slug == 'post_format') {
             continue;
         }
         $options[$category_slug] = array('#name' => 'ct[taxonomies][' . $category_slug . ']', '#title' => $category->labels->name, '#default_value' => !empty($this->ct['taxonomies'][$category_slug]), '#inline' => true, '#before' => '<li>', '#after' => '</li>');
         $options[$category_slug]['_builtin'] = $category->_builtin;
         /* if ( $this->ct['_builtin'] && $category->_builtin ) {
                $options[$category_slug]['#attributes'] = array(
                    'disabled' => 'disabled',
                );
            } */
     }
     $form['taxonomies'] = array('#type' => 'checkboxes', '#options' => $options, '#name' => 'ct[taxonomies]', '#inline' => true, '#before' => '<ul class="wpcf-list">', '#after' => '</ul>', '_builtin' => true);
     $form = wpcf_form(__FUNCTION__, $form);
     echo $form->renderForm();
 }
Пример #28
0
/**
 * Menu page display.
 */
function wpcf_admin_menu_settings()
{
    ob_start();
    echo wpcf_add_admin_header(__('Settings', 'wpcf'));
    ?>
    <p style="font-weight: bold;"><?php 
    _e('This screen contains the Types settings for your site.', 'wpcf');
    ?>
</p>
    <ul class="horlist">
        <li><a href="#types-image-settings"><?php 
    _e('Image Settings', 'wpcf');
    ?>
</a></li>
        <li><a href="#types-general-settings"><?php 
    _e('General Setings', 'wpcf');
    ?>
</a></li>
    </ul>
    <br style='clear:both'/><br /><br />
    <a id="types-image-settings"></a>
    <table class="widefat" id="types_image_settings_table">
        <thead>
            <tr>
                <th><?php 
    _e('Image Settings', 'wpcf');
    ?>
</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>
                    <?php 
    echo '<br /><form method="post" action="" id="wpcf-image-settings-form" class="wpcf-settings-form ' . 'wpcf-form-validate">';
    $form = wpcf_form('wpcf_form_image_settings');
    echo $form->renderForm();
    echo '</form>';
    ?>
                </td>
            </tr>
        </tbody>
    </table>
    <br /><br />
    <a id="types-general-settings"></a>
    <table class="widefat" id="types_general_settings_table">
        <thead>
            <tr>
                <th><?php 
    _e('General Settings', 'wpcf');
    ?>
</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>
                    <?php 
    echo '<br /><form method="post" action="" id="wpcf-general-settings-form" class="wpcf-settings-form ' . 'wpcf-form-validate">';
    $form = wpcf_form('wpcf_form_general_settings');
    echo $form->renderForm();
    echo '</form>';
    ?>
                </td>
            </tr>
        </tbody>
    </table>
    <?php 
    echo wpcf_add_admin_footer();
    echo ob_get_clean();
}
Пример #29
0
/**
 * Menu page display.
 */
function wpcf_admin_menu_settings()
{
    echo wpcf_add_admin_header(__('Settings', 'wpcf'));
    echo '<br /><form method="post" action="" id="wpcf-settings-form" class="wpcf-settings-form ' . 'wpcf-form-validate">';
    $form = wpcf_form('wpcf_form_settings');
    echo $form->renderForm();
    echo '</form>';
    echo wpcf_add_admin_footer();
}
Пример #30
0
function wpcf_admin_metabox_module_manager($type)
{
    $form = array();
    /**
     * box content
     */
    ob_start();
    switch ($type) {
        case 'post':
            wpcf_module_inline_table_post_types();
            break;
        case 'taxonomy':
            wpcf_module_inline_table_post_taxonomies();
            break;
        default:
            _e('Wrong type!', 'wpcf');
            break;
    }
    $markup = ob_get_contents();
    ob_end_clean();
    $form['table-mm'] = array('#type' => 'markup', '#markup' => $markup);
    /**
     * render form
     */
    $form = wpcf_form(__FUNCTION__, $form);
    echo $form->renderForm();
}