Пример #1
0
/**
 * Renders meta box content.
 * 
 * @param type $post
 * @param type $group 
 */
function wpcf_admin_post_meta_box($post, $group)
{
    if (!empty($group['args']['fields'])) {
        // Display description
        if (!empty($group['args']['description'])) {
            echo '<div class="wpcf-meta-box-description">' . wpautop(wpcf_translate('group ' . $group['args']['id'] . ' description', $group['args']['description'])) . '</div>';
        }
        foreach ($group['args']['fields'] as $field_slug => $field) {
            // Render form elements
            if (wpcf_compare_wp_version() && $field['#type'] == 'wysiwyg') {
                // Especially for WYSIWYG
                unset($field['#before'], $field['#after']);
                echo '<div class="wpcf-wysiwyg">';
                echo '<div id="wpcf-textarea-textarea-wrapper" class="form-item form-item-textarea wpcf-form-item wpcf-form-item-textarea">
<label class="wpcf-form-label wpcf-form-textarea-label">' . $field['#title'] . '</label>';
                echo '<div class="description wpcf-form-description wpcf-form-description-textarea description-textarea">
' . wpautop($field['#description']) . '</div>';
                wp_editor($field['#value'], $field['#id'], $field['#editor_settings']);
                $field['slug'] = str_replace(WPCF_META_PREFIX . 'wysiwyg-', '', $field_slug);
                $field['type'] = 'wysiwyg';
                echo '</div></div><br /><br />';
            } else {
                if ($field['#type'] == 'wysiwyg') {
                    $field['#type'] = 'textarea';
                }
                echo wpcf_form_simple(array($field['#id'] => $field));
            }
            do_action('wpcf_fields_' . $field_slug . '_meta_box_form', $field);
            if (isset($field['wpcf-type'])) {
                // May be ignored
                do_action('wpcf_fields_' . $field['wpcf-type'] . '_meta_box_form', $field);
            }
        }
    }
}
Пример #2
0
function wpcf_fields_colorpicker_render_js()
{
    //By Gen: changed minimal version from 3.4 to 3.5, because colorbox not works in 3.4.2
    if (wpcf_compare_wp_version('3.5', '<')) {
        wpcf_fields_colorpicker_js_farbtastic();
    } else {
        wpcf_fields_colorpicker_js();
    }
}
Пример #3
0
 /**
  * Returns array of available (registered) field types
  * and their config data.
  * 
  * @return type
  */
 public static function getFieldsTypesData()
 {
     if (!is_null(self::$fieldTypesData)) {
         return self::$fieldTypesData;
     }
     self::$fieldTypesData = self::getFieldsTypes();
     foreach (self::$fieldTypesData as $type => $path) {
         $data = self::getFieldTypeConfig($path);
         if (!empty($data)) {
             self::$fieldTypesData[$type] = $data;
         } else {
             unset(self::$fieldTypesData[$type]);
         }
         if (isset($data['wp_version']) && wpcf_compare_wp_version($data['wp_version'], '<')) {
             unset(self::$fieldTypesData[$type]);
         }
     }
     return self::$fieldTypesData;
 }
Пример #4
0
/**
 * Renders meta box content.
 *
 * Core function. Works and stable.
 * If required, add hooks only.
 *
 * @todo Revise this 1.1.5
 *
 * @param type $post
 * @param type $group
 * @param type $echo
 * @param type boolean $open_style_editor if true use code for open style editor when edit group
 */
function wpcf_admin_post_meta_box($post, $group, $echo = '', $open_style_editor = false)
{
    if (false === $open_style_editor && defined('WPTOOLSET_FORMS_VERSION')) {
        if (isset($group['args']['html'])) {
            /**
             * show group description
             */
            if (array_key_exists('description', $group['args']) && !empty($group['args']['description'])) {
                echo '<div class="wpcf-meta-box-description">';
                echo wpautop(wpcf_translate('group ' . $group['args']['id'] . ' description', $group['args']['description']));
                echo '</div>';
            }
            foreach ($group['args']['html'] as $field) {
                echo is_array($field) ? wptoolset_form_field('post', $field['config'], $field['meta']) : $field;
            }
        }
        return;
    }
    global $wpcf;
    /**
     * fake post object if need
     */
    $post = wpcf_admin_create_fake_post_if_need($post);
    static $nonce_added = false;
    $group_output = '';
    if (!isset($group['title'])) {
        $temp = $group;
        $group = '';
        $group['args'] = $temp;
        $group['id'] = $temp['slug'];
        $group['title'] = $temp['name'];
        $name = $temp['name'];
    }
    if (!empty($echo)) {
        $group_output = '<h3>This Preview generated for latest post "' . $post->post_title . '"</h3>' . "\n" . '<!-- Previous lines visible only in Admin Style Editor.-->' . "\n\n";
        $group_output .= '<div id="wpcf-group-' . $group['id'] . '" class="postbox " >
            <h3 class=\'hndle\'><span>' . $name . '</span></h3>
            <div class="inside">' . "\n";
    }
    /*
     * TODO Document where this is used
     */
    if (!$nonce_added && empty($echo)) {
        $nonce_action = 'update-' . $post->post_type . '_' . $post->ID;
        wp_nonce_field($nonce_action, '_wpcf_post_wpnonce');
        $nonce_added = true;
    }
    $group_output .= "\n\n" . '<div id="wpcf-group-metabox-id-' . $group['args']['slug'] . '">' . "\n";
    /*
     * TODO Move to Conditional code
     *
     * This is already checked. Use hook to add wrapper DIVS and apply CSS.
     */
    if (!empty($group['args']['_conditional_display'])) {
        if ($group['args']['_conditional_display'] == 'failed') {
            $group_output .= '<div class="wpcf-cd-group wpcf-cd-group-failed" style="display:none;">';
        } else {
            $group_output .= '<div class="wpcf-cd-group wpcf-cd-group-passed">';
        }
    }
    /*
     * TODO Move this into Field code
     * Process fields
     */
    if (!empty($group['args']['fields'])) {
        // Display description
        if (!empty($group['args']['description'])) {
            $group_output .= '<div class="wpcf-meta-box-description">' . wpautop(wpcf_translate('group ' . $group['args']['id'] . ' description', $group['args']['description'])) . '</div>';
        }
        foreach ($group['args']['fields'] as $field_slug => $field) {
            if (empty($field) || !is_array($field)) {
                continue;
            }
            $field = $wpcf->field->_parse_cf_form_element($field);
            if (isset($field['wpcf-type'])) {
                // May be ignored
                $field = apply_filters('wpcf_fields_' . $field['wpcf-type'] . '_meta_box_form_value_display', $field);
            }
            if (!isset($field['#id'])) {
                $field['#id'] = wpcf_unique_id(serialize($field));
            }
            // Render form elements
            if (wpcf_compare_wp_version() && array_key_exists('#type', $field) && 'wysiwyg' == $field['#type'] && !isset($field['#attributes']['disabled'])) {
                //                if ( isset( $field['#attributes']['disabled'] ) ) {
                //                    $field['#editor_settings']['tinymce'] = false;
                //                    $field['#editor_settings']['teeny'] = false;
                //                    $field['#editor_settings']['media_buttons'] = false;
                //                    $field['#editor_settings']['quicktags'] = false;
                //                    $field['#editor_settings']['dfw'] = false;
                //                }
                // Especially for WYSIWYG
                $group_output .= '<div class="wpcf-wysiwyg">';
                $group_output .= '<div id="wpcf-textarea-textarea-wrapper" class="form-item form-item-textarea wpcf-form-item wpcf-form-item-textarea">';
                $group_output .= isset($field['#before']) ? $field['#before'] : '';
                $group_output .= '<label class="wpcf-form-label wpcf-form-textarea-label">' . stripslashes($field['#title']) . '</label>';
                $group_output .= '<div class="description wpcf-form-description wpcf-form-description-textarea description-textarea">
                    ' . wpautop($field['#description']) . '</div>';
                ob_start();
                wp_editor($field['#value'], $field['#id'], $field['#editor_settings']);
                $group_output .= ob_get_clean() . "\n\n";
                $field['slug'] = str_replace(WPCF_META_PREFIX . 'wysiwyg-', '', $field_slug);
                $field['type'] = 'wysiwyg';
                $group_output .= '</div>';
                $group_output .= isset($field['#after']) ? $field['#after'] : '';
                $group_output .= '</div>';
            } else {
                if (array_key_exists('#type', $field) && 'wysiwyg' == $field['#type']) {
                    $field['#type'] = 'textarea';
                }
                if (!empty($echo)) {
                    $field['#validate'] = '';
                }
                $group_output .= wpcf_form_simple(array($field['#id'] => $field));
            }
            do_action('wpcf_fields_' . $field_slug . '_meta_box_form', $field);
            if (isset($field['wpcf-type'])) {
                // May be ignored
                do_action('wpcf_fields_' . $field['wpcf-type'] . '_meta_box_form', $field);
            }
        }
    }
    /*
     * TODO Move to Conditional code
     *
     * This is already checked. Use hook to add wrapper DIVS and apply CSS.
     */
    if (!empty($group['args']['_conditional_display'])) {
        $group_output .= '</div>';
    }
    $group_output .= '</div>';
    if (!empty($echo)) {
        $group_output .= "\n\n</div></div>";
        return $group_output;
    } else {
        echo $group_output;
    }
}
Пример #5
0
function wpcf_admin_render_fields($group, $user_id, $echo = '')
{
    global $wpcf;
    $output = '<div class="wpcf-group-area wpcf-group-area_' . $group['slug'] . '">' . "\n\n";
    $output .= '<h3>' . wpcf_translate('group ' . $group['id'] . ' name', $group['name']) . '</h3>' . "\n\n";
    if (!empty($group['fields'])) {
        // Display description
        if (!empty($group['description'])) {
            $output .= '<span>' . wpautop(wpcf_translate('group ' . $group['id'] . ' description', $group['description'])) . '</span>' . "\n\n";
        }
        $output .= '<div class="wpcf-profile-field-line">' . "\n\n";
        foreach ($group['fields'] as $field_slug => $field) {
            if (empty($field) || !is_array($field)) {
                continue;
            }
            $field = $wpcf->usermeta_field->_parse_cf_form_element($field);
            if (!isset($field['#id'])) {
                $field['#id'] = wpcf_unique_id(serialize($field));
            }
            if (isset($field['wpcf-type'])) {
                // May be ignored
                $field = apply_filters('wpcf_fields_' . $field['wpcf-type'] . '_meta_box_form_value_display', $field);
            }
            // Render form elements
            if (wpcf_compare_wp_version() && $field['#type'] == 'wysiwyg') {
                $field['#editor_settings']['media_buttons'] = '';
                if (!empty($echo)) {
                    $field['#editor_settings']['wpautop'] = true;
                }
                // Especially for WYSIWYG
                $output .= "\n" . '<div class="wpcf-profile-field-line">' . "\n\n";
                $output .= '<div class="wpcf-wysiwyg">' . "\n\n";
                $output .= '<div id="wpcf-textarea-textarea-wrapper" class="form-item form-item-textarea wpcf-form-item wpcf-form-item-textarea">' . "\n\n";
                $output .= isset($field['#before']) ? $field['#before'] : '';
                $output .= '<label class="wpcf-form-label wpcf-form-textarea-label">' . $field['#title'] . '</label>' . "\n\n";
                $output .= '<div class="description wpcf-form-description wpcf-form-description-textarea description-textarea">' . "\n\n" . wpautop($field['#description']) . '</div>' . "\n\n";
                ob_start();
                wp_editor($field['#value'], $field['#id'], $field['#editor_settings']);
                $output .= ob_get_clean() . "\n\n";
                $field['slug'] = str_replace(WPCF_META_PREFIX . 'wysiwyg-', '', $field_slug);
                $field['type'] = 'wysiwyg';
                $output .= '</div>' . "\n\n";
                $output .= isset($field['#after']) ? $field['#after'] : '';
                $output .= '</div>' . "\n\n";
                $output .= '</div>' . "\n\n";
            } else {
                if ($field['#type'] == 'wysiwyg') {
                    $field['#type'] = 'textarea';
                }
                $field['#pattern'] = "\n" . '<div class="wpcf-profile-field-line">
	<div class="wpcf-profile-line-left">
		<LABEL><DESCRIPTION>
	</div>
	<div class="wpcf-profile-line-right"><BEFORE><ERROR><PREFIX><ELEMENT><SUFFIX><AFTER></div>
</div>' . "\n\n";
                if (isset($field['#name']) && (strpos($field['#name'], '[hour]') !== false || strpos($field['#name'], '[minute]') !== false)) {
                    if (isset($field['#attributes']) && $field['#attributes']['class'] == 'wpcf-repetitive') {
                        $field['#pattern'] = strpos($field['#name'], '[hour]') !== false ? __('Hour', 'wpcf') : __('Minute', 'wpcf');
                        $field['#pattern'] .= '<LABEL><DESCRIPTION><ERROR><PREFIX><ELEMENT><SUFFIX><AFTER>' . "\n\n";
                    } else {
                        if (strpos($field['#name'], '[hour]') !== false) {
                            $field['#pattern'] = "\n" . '<div class="wpcf-profile-field-line">
	<div class="wpcf-profile-line-left">&nbsp;&nbsp;&nbsp;&nbsp;' . __('Time', 'wpcf') . '</div>
	<div class="wpcf-profile-line-right">
	<LABEL><DESCRIPTION><ERROR><PREFIX><ELEMENT><SUFFIX><AFTER>' . "\n";
                        } else {
                            $field['#pattern'] = "\n" . '
	<LABEL><DESCRIPTION><ERROR><PREFIX><ELEMENT><SUFFIX><AFTER></div>
</div>' . "\n\n";
                        }
                    }
                }
                if (!empty($echo)) {
                    $field['#validate'] = '';
                }
                $output .= wpcf_form_simple(array($field['#id'] => $field));
            }
        }
        $output .= '</div>';
    }
    /*
     * TODO Move to Conditional code
     *
     * This is already checked. Use hook to add wrapper DIVS and apply CSS.
     */
    if (!empty($group['_conditional_display'])) {
        $output .= '</div>';
    }
    $output .= "\n\n" . '</div>';
    if (!empty($echo)) {
        return $output;
    } else {
        echo $output;
    }
}
Пример #6
0
/**
 * Renders page head.
 * 
 * @global type $pagenow
 * @param type $title
 */
function wpcf_admin_ajax_head($title)
{
    global $pagenow;
    $hook_suffix = $pagenow;
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" <?php 
    do_action('admin_xml_ns');
    ?>
 <?php 
    language_attributes();
    ?>
>
        <head>
            <meta http-equiv="Content-Type" content="<?php 
    bloginfo('html_type');
    ?>
; charset=<?php 
    echo get_option('blog_charset');
    ?>
" />
            <title><?php 
    echo $title;
    ?>
</title>
            <?php 
    if (wpcf_compare_wp_version('3.2.1', '<=')) {
        wp_admin_css('global');
    }
    wp_admin_css();
    wp_admin_css('colors');
    wp_admin_css('ie');
    do_action('admin_enqueue_scripts', $hook_suffix);
    do_action("admin_print_styles-{$hook_suffix}");
    do_action('admin_print_styles');
    do_action("admin_print_scripts-{$hook_suffix}");
    do_action('admin_print_scripts');
    // TODO Check if needed
    //            do_action("admin_head-$hook_suffix");
    //            do_action('admin_head');
    do_action('admin_head_wpcf_ajax');
    ?>
            <style type="text/css">
                html { height: auto; }
            </style>
        </head>
        <body style="padding: 20px;">
            <?php 
}
 /**
  * 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_options()
 {
     $form = array();
     $form['rewrite-enabled'] = array('#type' => 'checkbox', '#force_boolean' => true, '#title' => __('Rewrite', 'wpcf'), '#name' => 'ct[rewrite][enabled]', '#description' => __('Rewrite permalinks with this format. Default will use $taxonomy as query var.', 'wpcf'), '#default_value' => !empty($this->ct['rewrite']['enabled']), '#inline' => true);
     $hidden = empty($this->ct['rewrite']['enabled']) ? ' class="hidden"' : '';
     $form['rewrite-slug'] = array('#type' => 'textfield', '#name' => 'ct[rewrite][slug]', '#title' => __('Prepend posts with this slug', 'wpcf'), '#description' => __('Optional', 'wpcf') . '. ' . __("Prepend posts with this slug - defaults to taxonomy's name.", 'wpcf'), '#value' => isset($this->ct['rewrite']['slug']) ? $this->ct['rewrite']['slug'] : '', '#inline' => true, '#before' => '<div id="wpcf-types-form-rewrite-toggle"' . $hidden . '>', '#after' => '</div>', '#validate' => array('rewriteslug' => array('value' => 'true')), '#attributes' => array('class' => 'regular-text'));
     $form['rewrite-with_front'] = array('#type' => 'checkbox', '#force_boolean' => true, '#title' => __('Allow permalinks to be prepended with front base', 'wpcf'), '#name' => 'ct[rewrite][with_front]', '#description' => __('Defaults to true.', 'wpcf'), '#default_value' => !empty($this->ct['rewrite']['with_front']), '#inline' => true);
     $form['rewrite-hierarchical'] = array('#type' => 'checkbox', '#name' => 'ct[rewrite][hierarchical]', '#title' => __('Hierarchical URLs', 'wpcf'), '#description' => sprintf(__('True or false allow hierarchical urls (implemented in %sVersion 3.1%s).', 'wpcf'), '<a href="http://codex.wordpress.org/Version_3.1" title="Version 3.1" target="_blank">', '</a>'), '#default_value' => !empty($this->ct['rewrite']['hierarchical']), '#inline' => true);
     $form['vars'] = array('#type' => 'checkboxes', '#name' => 'ct[advanced]', '#inline' => true, '#options' => array('show_ui' => array('#name' => 'ct[show_ui]', '#default_value' => !empty($this->ct['show_ui']), '#title' => __('show_ui', 'wpcf'), '#description' => __('Whether to generate a default UI for managing this taxonomy.', 'wpcf') . '<br />' . __('Default: if not set, defaults to value of public argument.', 'wpcf'), '#inline' => true), 'show_in_nav_menus' => array('#name' => 'ct[show_in_nav_menus]', '#default_value' => !empty($this->ct['show_in_nav_menus']), '#title' => __('show_in_nav_menus', 'wpcf'), '#description' => __('True makes this taxonomy available for selection in navigation menus.', 'wpcf') . '<br />' . __('Default: if not set, defaults to value of public argument.', 'wpcf'), '#inline' => true), 'show_tagcloud' => array('#name' => 'ct[show_tagcloud]', '#default_value' => !empty($this->ct['show_tagcloud']), '#title' => __('show_tagcloud', 'wpcf'), '#description' => __('Whether to allow the Tag Cloud widget to use this taxonomy.', 'wpcf') . '<br />' . __('Default: if not set, defaults to value of show_ui argument.', 'wpcf'), '#inline' => true)));
     if (wpcf_compare_wp_version('3.5', '>=')) {
         $form['vars']['#options']['show_admin_column'] = array('#name' => 'ct[show_admin_column]', '#default_value' => !empty($this->ct['show_admin_column']), '#title' => __('show_admin_column', 'wpcf'), '#description' => __('Whether to allow automatic creation of taxonomy columns on associated post-types.', 'wpcf') . '<br />' . __('Default: false.', 'wpcf'), '#inline' => true);
     }
     $query_var = isset($this->ct['query_var']) ? $this->ct['query_var'] : '';
     $hidden = !empty($this->ct['query_var_enabled']) ? '' : ' class="hidden"';
     $form['query_var'] = array('#type' => 'checkbox', '#name' => 'ct[query_var_enabled]', '#title' => 'query_var', '#description' => __('Disable to prevent queries like "mysite.com/?taxonomy=example". Enable to use queries like "mysite.com/?taxonomy=example". Enable and set a value to use queries like "mysite.com/?query_var_value=example"', 'wpcf') . '<br />' . __('Default: true - set to $taxonomy.', 'wpcf'), '#default_value' => !empty($this->ct['query_var_enabled']), '#after' => '<div id="wpcf-types-form-queryvar-toggle"' . $hidden . '><input type="text" name="ct[query_var]" value="' . $query_var . '" class="regular-text wpcf-form-textfield form-textfield textfield" /><div class="description wpcf-form-description wpcf-form-description-checkbox description-checkbox">' . __('Optional', 'wpcf') . '. ' . __('String to customize query var', 'wpcf') . '</div></div>', '#inline' => true);
     $form['update_count_callback'] = array('#type' => 'textfield', '#name' => 'ct[update_count_callback]', '#title' => 'update_count_callback', 'wpcf', '#description' => __('Function name that will be called to update the count of an associated $object_type, such as post, is updated.', 'wpcf') . '<br />' . __('Default: None.', 'wpcf'), '#value' => !empty($this->ct['update_count_callback']) ? $this->ct['update_count_callback'] : '', '#inline' => true, '#attributes' => array('class' => 'regular-text'));
     $form['meta_box_cb-header'] = array('#type' => 'markup', '#markup' => sprintf('<h3>%s</h3>', __('Meta box callback function', 'wpcf')));
     $form['meta_box_cb-disabled'] = array('#type' => 'checkbox', '#force_boolean' => true, '#title' => __('Hide taxonomy meta box.', 'wpcf'), '#name' => 'ct[meta_box_cb][disabled]', '#default_value' => !empty($this->ct['meta_box_cb']['disabled']), '#inline' => true, '#description' => __('If you disable this, there will be no metabox on entry edit screen.', 'wpcf'));
     $hidden = empty($this->ct['meta_box_cb']['disabled']) ? '' : ' class="hidden"';
     $form['meta_box_cb'] = array('#type' => 'textfield', '#name' => 'ct[meta_box_cb][callback]', '#title' => __('meta_box_cb', 'wpcf'), '#description' => __('Provide a callback function name for the meta box display.', 'wpcf') . '<br />' . __('Default: None.', 'wpcf'), '#value' => !empty($this->ct['meta_box_cb']['callback']) ? $this->ct['meta_box_cb']['callback'] : '', '#inline' => true, '#before' => '<div id="wpcf-types-form-meta_box_cb-toggle"' . $hidden . '>', '#after' => '</div>', '#attributes' => array('class' => 'regular-text'));
     $form = wpcf_form(__FUNCTION__, $form);
     echo $form->renderForm();
 }
Пример #8
0
/**
 * Renders page head.
 * 
 * @see WPCF_Template::ajax_header()
 * @global type $pagenow
 * @param type $title
 */
function wpcf_admin_ajax_head($title = '')
{
    /*
     * Since Types 1.2 and WP 3.5
     * AJAX head is rendered differently
     */
    global $wp_version;
    if (version_compare($wp_version, '3.4', '>')) {
        // WP Header
        include WPCF_EMBEDDED_ABSPATH . '/includes/ajax/admin-header.php';
        return true;
    }
    global $pagenow;
    $hook_suffix = $pagenow;
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" <?php 
    do_action('admin_xml_ns');
    ?>
 <?php 
    language_attributes();
    ?>
>
        <head>
            <meta http-equiv="Content-Type" content="<?php 
    bloginfo('html_type');
    ?>
; charset=<?php 
    echo get_option('blog_charset');
    ?>
" />
            <title><?php 
    echo $title;
    ?>
</title>
            <?php 
    if (wpcf_compare_wp_version('3.2.1', '<=')) {
        wp_admin_css('global');
    }
    wp_admin_css();
    wp_admin_css('colors');
    wp_admin_css('ie');
    //            do_action('admin_enqueue_scripts', $hook_suffix);
    do_action("admin_print_styles-{$hook_suffix}");
    do_action('admin_print_styles');
    //            do_action("admin_print_scripts-$hook_suffix");
    do_action('admin_print_scripts');
    //            do_action("admin_head-$hook_suffix");
    //            do_action('admin_head');
    do_action('admin_head_wpcf_ajax');
    ?>
            <style type="text/css">
                html { height: auto; }
            </style>

            <script type="text/javascript">
                // <![CDATA[
                jQuery(document).ready(function(){
                    // Position the help link in the title bar.
                    var title = jQuery('#TB_closeAjaxWindow', window.parent.document);
                    if (title.length != 0) {
                        title.after(jQuery('.wpcf-help-link'));
                    }
                });
                // ]]>
            </script>

            <link rel="stylesheet" href="<?php 
    echo WPCF_EMBEDDED_RES_RELPATH . '/css/basic.css';
    ?>
" type="text/css" media="all" />

        </head>
        <body style="padding: 20px;">
            <?php 
}
Пример #9
0
/**
 * Gets all fields.
 *
 * @todo Move to WPCF_Fields
 * @param bool $only_active
 * @param bool $disabled_by_type
 * @param bool $strictly_active
 * @param string $option_name
 * @param bool $use_cache
 * @param bool $clear_cache
 * @return type
 *
 * added param $use_cache by Gen (used when adding new fields to group)
 * added param $use_cache by Gen (used when adding new fields to group)
 */
function wpcf_admin_fields_get_fields($only_active = false, $disabled_by_type = false, $strictly_active = false, $option_name = 'wpcf-fields', $use_cache = true, $clear_cache = false)
{
    static $cache = array();
    if ($clear_cache) {
        $cache = array();
    }
    $cache_key = md5($only_active . $disabled_by_type . $strictly_active . $option_name . $use_cache);
    if (isset($cache[$cache_key]) && $use_cache == true) {
        return $cache[$cache_key];
    }
    $required_data = array('id', 'name', 'type', 'slug');
    $fields = (array) get_option($option_name, array());
    foreach ($fields as $k => $v) {
        $failed = false;
        foreach ($required_data as $required) {
            if (!isset($v[$required])) {
                $failed = true;
                continue;
            }
            if (is_numeric($v[$required]) === true) {
                $failed = true;
                continue;
            }
        }
        if (is_numeric($k) === true || $failed) {
            unset($fields[$k]);
            continue;
        }
        // This call loads config file
        $data = wpcf_fields_type_action($v['type']);
        if (empty($data)) {
            unset($fields[$k]);
            continue;
        }
        if (isset($data['wp_version']) && wpcf_compare_wp_version($data['wp_version'], '<')) {
            unset($fields[$k]);
            continue;
        }
        if ($strictly_active) {
            if (!empty($v['data']['disabled']) || !empty($v['data']['disabled_by_type'])) {
                unset($fields[$k]);
                continue;
            }
        } else {
            if ($only_active && !empty($v['data']['disabled'])) {
                unset($fields[$k]);
                continue;
            }
            if (!$disabled_by_type && !empty($v['data']['disabled_by_type'])) {
                unset($fields[$k]);
                continue;
            }
        }
        $v['id'] = $k;
        $v['meta_key'] = wpcf_types_get_meta_prefix($v) . $k;
        $v['meta_type'] = $option_name == 'wpcf-fields' ? 'postmeta' : 'usermeta';
        $fields[$k] = wpcf_sanitize_field($v);
    }
    $cache[$cache_key] = apply_filters('types_fields', $fields);
    return $cache[$cache_key];
}
function wpv_ajax_wpv_view_form_popup()
{
    global $wpdb;
    if (wp_verify_nonce($_GET['_wpnonce'], 'wpv_editor_callback')) {
        $view_id = $_GET['view_id'];
        $title = $wpdb->get_var("SELECT post_title FROM {$wpdb->posts} WHERE ID={$view_id}");
        // Find the posts that use this view
        $posts = $wpdb->get_results("SELECT ID, post_title, post_content FROM {$wpdb->posts} WHERE post_content LIKE '%name=\"{$title}\"%' AND post_type NOT IN ('revision')");
        wp_enqueue_script('jquery');
        ?>
        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
        <html xmlns="http://www.w3.org/1999/xhtml" <?php 
        do_action('admin_xml_ns');
        ?>
 <?php 
        language_attributes();
        ?>
>
            <head>
                <meta http-equiv="Content-Type" content="<?php 
        bloginfo('html_type');
        ?>
; charset=<?php 
        echo get_option('blog_charset');
        ?>
" />
                <title></title>
                <?php 
        if (wpcf_compare_wp_version('3.2.1', '<=')) {
            wp_admin_css('global');
        }
        wp_admin_css();
        wp_admin_css('colors');
        wp_admin_css('ie');
        do_action('admin_print_styles');
        do_action('admin_print_scripts');
        ?>
                <style type="text/css">
                    html { height: auto; }
                </style>
            </head>
            <body style="padding: 20px;">
                <?php 
        echo sprintf(__('Insert the filter section from View - %s', 'wpv-views'), '<strong>' . $title . '</strong>');
        ?>
                <input type="hidden" value="<?php 
        echo $view_id;
        ?>
" id="wpv_view_id">
                <br />
                
                <br />
                
                <?php 
        echo __('When the form is submitted, go to this post:', 'wpv-views');
        ?>
                <select id="wpv_filter_form_target" />
                    
                    <option value="0">None</option>
                    <?php 
        $first = true;
        foreach ($posts as $post) {
            $post_title = $post->post_title;
            if ($post_title == '') {
                $post_title = $post->ID;
            }
            if ($first) {
                echo '<option value="' . $post->ID . '" selected="selected" >' . $post->post_title . '</option>';
            } else {
                echo '<option value="' . $post->ID . '">' . $post->post_title . '</option>';
            }
            $first = false;
        }
        ?>
                
                </select>
                
                <br />
                <br />
                
                <?php 
        if (count($post) == 0) {
            echo '<strong>' . __('No target posts were found that use this View', 'wpv-views') . '</strong>';
            echo '<br /><br />';
        }
        ?>
        
                <input type="button" class="button-secondary" value="<?php 
        echo __('Insert shortcode', 'wpv-views');
        ?>
" onclick="wpv_insert_form_shortcode()" />
                
                <script type="text/javascript">
                    //<![CDATA[
                    function wpv_insert_form_shortcode() {
                        
                        var data = '&action=wpv_insert_form_shortcode'
                        data += '&_wpnonce=<?php 
        echo wp_create_nonce('wpv_editor_callback');
        ?>
';
                        data += '&view_id=' + jQuery('#wpv_view_id').val();
                        data += '&target=' + jQuery('#wpv_filter_form_target').val();
                        
                        jQuery.ajaxSetup({async:false});
                        jQuery.post('<?php 
        echo admin_url('admin-ajax.php');
        ?>
', data, function(response) {
                            jQuery('body').append(response);
                            
                        });
                        
                    }
                    
                    //]]>
                </script>
                    
                
            </body>
        </html>
        
        <?php 
    }
    die;
}
Пример #11
0
/**
 * Gets all fields.
 *
 * @todo Move to WPCF_Fields
 * @param bool $only_active
 * @param bool $disabled_by_type
 * @param bool $strictly_active
 * @param string $option_name
 * @param bool $use_cache
 * @param bool $clear_cache
 * @return array
 *
 * added param $use_cache by Gen (used when adding new fields to group)
 * added param $use_cache by Gen (used when adding new fields to group)
 */
function wpcf_admin_fields_get_fields($only_active = false, $disabled_by_type = false, $strictly_active = false, $option_name = 'wpcf-fields', $use_cache = true, $clear_cache = false)
{
    static $cache = array();
    if ($clear_cache) {
        $cache = array();
    }
    /**
     * Sanitize option name
     */
    switch ($option_name) {
        case 'wpcf-usermeta':
        case 'wpcf-fields':
        case WPCF_Field_Term_Definition_Factory::FIELD_DEFINITIONS_OPTION:
            break;
        default:
            $option_name = 'wpcf-fields';
            break;
    }
    $cache_key = md5($only_active . $disabled_by_type . $strictly_active . $option_name . $use_cache);
    if (isset($cache[$cache_key]) && $use_cache == true) {
        return $cache[$cache_key];
    }
    $required_data = array('id', 'name', 'type', 'slug');
    $fields = (array) get_option($option_name, array());
    foreach ($fields as $k => $v) {
        $failed = false;
        foreach ($required_data as $required) {
            if (!isset($v[$required])) {
                $failed = true;
                continue;
            }
            if (is_numeric($v[$required]) === true) {
                $failed = true;
                continue;
            }
        }
        if (is_numeric($k) === true || $failed) {
            unset($fields[$k]);
            continue;
        }
        // This call loads config file
        $data = wpcf_fields_type_action($v['type']);
        if (empty($data)) {
            unset($fields[$k]);
            continue;
        }
        if (isset($data['wp_version']) && wpcf_compare_wp_version($data['wp_version'], '<')) {
            unset($fields[$k]);
            continue;
        }
        if ($strictly_active) {
            if (!empty($v['data']['disabled']) || !empty($v['data']['disabled_by_type'])) {
                unset($fields[$k]);
                continue;
            }
        } else {
            if ($only_active && !empty($v['data']['disabled'])) {
                unset($fields[$k]);
                continue;
            }
            if (!$disabled_by_type && !empty($v['data']['disabled_by_type'])) {
                unset($fields[$k]);
                continue;
            }
        }
        $v['id'] = $k;
        $v['meta_key'] = wpcf_types_get_meta_prefix($v) . $k;
        $option_name_to_meta_type = array('wpcf-fields' => 'postmeta', 'wpcf-usermeta' => 'usermeta', WPCF_Field_Term_Definition_Factory::FIELD_DEFINITIONS_OPTION => 'termmeta');
        $v['meta_type'] = $option_name_to_meta_type[$option_name];
        $fields[$k] = wpcf_sanitize_field($v);
    }
    $cache[$cache_key] = apply_filters('types_fields', $fields);
    return $cache[$cache_key];
}
/**
 * Options
 */
function wpcf_admin_metabox_options($data)
{
    $form = array();
    $form['table-' . __FUNCTION__ . '-open'] = wpcf_admin_metabox_begin(__('Options', 'wpcf'), 'options', 'wpcf-types-form-options-table');
    $form['make-hierarchical'] = array('#type' => 'radios', '#name' => 'ct[hierarchical]', '#default_value' => empty($data['hierarchical']) || $data['hierarchical'] == 'flat' ? 'flat' : 'hierarchical', '#inline' => true, '#options' => array(__('Hierarchical - like post categories, with parent / children relationship and checkboxes to select taxonomy', 'wpcf') => 'hierarchical', __('Flat - like post tags, with a text input to enter terms', 'wpcf') => 'flat'), '#after' => '<br /><br />');
    $form['rewrite-enabled'] = array('#type' => 'checkbox', '#force_boolean' => true, '#title' => __('Rewrite', 'wpcf'), '#name' => 'ct[rewrite][enabled]', '#description' => __('Rewrite permalinks with this format. Default will use $taxonomy as query var.', 'wpcf'), '#default_value' => !empty($data['rewrite']['enabled']), '#inline' => true);
    $hidden = empty($data['rewrite']['enabled']) ? ' class="hidden"' : '';
    $form['rewrite-slug'] = array('#type' => 'textfield', '#name' => 'ct[rewrite][slug]', '#title' => __('Prepend posts with this slug', 'wpcf'), '#description' => __('Optional', 'wpcf') . '. ' . __("Prepend posts with this slug - defaults to taxonomy's name.", 'wpcf'), '#value' => isset($data['rewrite']['slug']) ? $data['rewrite']['slug'] : '', '#inline' => true, '#before' => '<div id="wpcf-types-form-rewrite-toggle"' . $hidden . '>', '#after' => '</div>', '#validate' => array('rewriteslug' => array('value' => 'true')));
    $form['rewrite-with_front'] = array('#type' => 'checkbox', '#force_boolean' => true, '#title' => __('Allow permalinks to be prepended with front base', 'wpcf'), '#name' => 'ct[rewrite][with_front]', '#description' => __('Defaults to true.', 'wpcf'), '#default_value' => !empty($data['rewrite']['with_front']), '#inline' => true);
    $form['rewrite-hierarchical'] = array('#type' => 'checkbox', '#name' => 'ct[rewrite][hierarchical]', '#title' => __('Hierarchical URLs', 'wpcf'), '#description' => sprintf(__('True or false allow hierarchical urls (implemented in %sVersion 3.1%s).', 'wpcf'), '<a href="http://codex.wordpress.org/Version_3.1" title="Version 3.1" target="_blank">', '</a>'), '#default_value' => !empty($data['rewrite']['hierarchical']), '#inline' => true);
    $form['vars'] = array('#type' => 'checkboxes', '#name' => 'ct[advanced]', '#inline' => true, '#options' => array('show_ui' => array('#name' => 'ct[show_ui]', '#default_value' => !empty($data['show_ui']), '#title' => __('show_ui', 'wpcf'), '#description' => __('Whether to generate a default UI for managing this taxonomy.', 'wpcf') . '<br />' . __('Default: if not set, defaults to value of public argument.', 'wpcf'), '#inline' => true), 'show_in_nav_menus' => array('#name' => 'ct[show_in_nav_menus]', '#default_value' => !empty($data['show_in_nav_menus']), '#title' => __('show_in_nav_menus', 'wpcf'), '#description' => __('True makes this taxonomy available for selection in navigation menus.', 'wpcf') . '<br />' . __('Default: if not set, defaults to value of public argument.', 'wpcf'), '#inline' => true), 'show_tagcloud' => array('#name' => 'ct[show_tagcloud]', '#default_value' => !empty($data['show_tagcloud']), '#title' => __('show_tagcloud', 'wpcf'), '#description' => __('Whether to allow the Tag Cloud widget to use this taxonomy.', 'wpcf') . '<br />' . __('Default: if not set, defaults to value of show_ui argument.', 'wpcf'), '#inline' => true)));
    if (wpcf_compare_wp_version('3.5', '>=')) {
        $form['vars']['#options']['show_admin_column'] = array('#name' => 'ct[show_admin_column]', '#default_value' => !empty($data['show_admin_column']), '#title' => __('show_admin_column', 'wpcf'), '#description' => __('Whether to allow automatic creation of taxonomy columns on associated post-types.', 'wpcf') . '<br />' . __('Default: false.', 'wpcf'), '#inline' => true);
    }
    $query_var = isset($data['query_var']) ? $data['query_var'] : '';
    $hidden = !empty($data['query_var_enabled']) ? '' : ' class="hidden"';
    $form['query_var'] = array('#type' => 'checkbox', '#name' => 'ct[query_var_enabled]', '#title' => 'query_var', '#description' => __('False to prevent queries, or string to customize query var. Default will use $taxonomy as query var.', 'wpcf') . '<br />' . __('Default: $taxonomy.', 'wpcf'), '#default_value' => !empty($data['query_var_enabled']), '#after' => '<div id="wpcf-types-form-queryvar-toggle"' . $hidden . '><input type="text" name="ct[query_var]" value="' . $query_var . '" class="wpcf-form-textfield form-textfield textfield" /><div class="description wpcf-form-description wpcf-form-description-checkbox description-checkbox">' . __('Optional', 'wpcf') . '. ' . __('String to customize query var', 'wpcf') . '</div></div>', '#inline' => true);
    $form['update_count_callback'] = array('#type' => 'textfield', '#name' => 'ct[update_count_callback]', '#title' => 'update_count_callback', 'wpcf', '#description' => __('Function name that will be called to update the count of an associated $object_type, such as post, is updated.', 'wpcf') . '<br />' . __('Default: None.', 'wpcf'), '#value' => !empty($data['update_count_callback']) ? $data['update_count_callback'] : '', '#inline' => true);
    /**
     * close
     */
    $form['table-' . __FUNCTION__ . '-close'] = wpcf_admin_metabox_end();
    return $form;
}
/**
 * Add/edit form structure
 */
function wpcf_admin_custom_taxonomies_form()
{
    global $wpcf;
    $ct = array();
    $id = false;
    $update = false;
    if (isset($_GET['wpcf-tax'])) {
        $id = $_GET['wpcf-tax'];
    } else {
        if (isset($_POST['wpcf-tax'])) {
            $id = $_POST['wpcf-tax'];
        }
    }
    if ($id) {
        $custom_taxonomies = get_option('wpcf-custom-taxonomies', array());
        if (isset($custom_taxonomies[$id])) {
            $ct = $custom_taxonomies[$id];
            $update = true;
            // Set rewrite if needed
            if (isset($_GET['wpcf-rewrite'])) {
                flush_rewrite_rules();
            }
        } else {
            wpcf_admin_message(__('Wrong custom taxonomy specified', 'wpcf'), 'error');
            return false;
        }
    } else {
        $ct = wpcf_custom_taxonomies_default();
    }
    $form = array();
    $form['#form']['callback'] = 'wpcf_admin_custom_taxonomies_form_submit';
    $form['#form']['redirection'] = false;
    if ($update) {
        $form['id'] = array('#type' => 'hidden', '#value' => $id, '#name' => 'ct[wpcf-tax]');
    }
    $form['table-1-open'] = array('#type' => 'markup', '#markup' => '<table id="wpcf-types-form-name-table" class="wpcf-types-form-table widefat"><thead><tr><th colspan="2">' . __('Name and description', 'wpcf') . '</th></tr></thead><tbody>');
    $table_row = '<tr><td><LABEL></td><td><ERROR><ELEMENT></td></tr>';
    $form['name'] = array('#type' => 'textfield', '#name' => 'ct[labels][name]', '#title' => __('Custom taxonomy name plural', 'wpcf') . ' (<strong>' . __('required', 'wpcf') . '</strong>)', '#description' => '<strong>' . __('Enter in plural!', 'wpcf') . '.', '#value' => isset($ct['labels']['name']) ? $ct['labels']['name'] : '', '#validate' => array('required' => array('value' => true), 'maxlength' => array('value' => 30)), '#pattern' => $table_row, '#inline' => true);
    $form['name-singular'] = array('#type' => 'textfield', '#name' => 'ct[labels][singular_name]', '#title' => __('Custom taxonomy name singular', 'wpcf') . ' (<strong>' . __('required', 'wpcf') . '</strong>)', '#description' => '<strong>' . __('Enter in singular!', 'wpcf') . '</strong><br />' . '.', '#value' => isset($ct['labels']['singular_name']) ? $ct['labels']['singular_name'] : '', '#validate' => array('required' => array('value' => true), 'maxlength' => array('value' => 30)), '#pattern' => $table_row, '#inline' => true);
    /*
     * 
     * IF isset $_POST['slug'] it means form is not submitted
     */
    $attributes = array();
    if (!empty($_POST['ct']['slug'])) {
        $reserved = wpcf_is_reserved_name($_POST['ct']['slug'], 'taxonomy');
        if (is_wp_error($reserved)) {
            $attributes = array('class' => 'wpcf-form-error', 'onclick' => 'jQuery(this).removeClass(\'wpcf-form-error\');');
        }
    }
    $form['slug'] = array('#type' => 'textfield', '#name' => 'ct[slug]', '#title' => __('Slug', 'wpcf') . ' (<strong>' . __('required', 'wpcf') . '</strong>)', '#description' => '<strong>' . __('Enter in singular!', 'wpcf') . '</strong><br />' . __('Machine readable name.', 'wpcf') . '<br />' . __('If not provided - will be created from singular name.', 'wpcf') . '<br />', '#value' => isset($ct['slug']) ? $ct['slug'] : '', '#pattern' => $table_row, '#inline' => true, '#validate' => array('required' => array('value' => true), 'nospecialchars' => array('value' => true), 'maxlength' => array('value' => 30)), '#attributes' => $attributes + array('maxlength' => '30'));
    $form['description'] = array('#type' => 'textarea', '#name' => 'ct[description]', '#title' => __('Description', 'wpcf'), '#value' => isset($ct['description']) ? $ct['description'] : '', '#attributes' => array('rows' => 4, 'cols' => 60), '#pattern' => $table_row, '#inline' => true);
    $form['table-1-close'] = array('#type' => 'markup', '#markup' => '</tbody></table>');
    $form['table-2-open'] = array('#type' => 'markup', '#markup' => '<table id="wpcf-types-form-visibility-table" class="wpcf-types-form-table widefat"><thead><tr><th>' . __('Visibility', 'wpcf') . '</th></tr></thead><tbody><tr><td>');
    $form['public'] = array('#type' => 'radios', '#name' => 'ct[public]', '#options' => array(__('Make this taxonomy public (will appear in the WordPress Admin menu)', 'wpcf') => 'public', __('Hidden - users cannot directly edit data in this taxonomy', 'wpcf') => 'hidden'), '#default_value' => isset($ct['public']) && strval($ct['public']) == 'hidden' ? 'hidden' : 'public', '#inline' => true);
    $form['table-2-close'] = array('#type' => 'markup', '#markup' => '</td></tr></tbody></table>');
    $post_types = get_post_types('', 'objects');
    $options = array();
    foreach ($post_types as $post_type_slug => $post_type) {
        if (in_array($post_type_slug, $wpcf->excluded_post_types) || !$post_type->show_ui) {
            continue;
        }
        $options[$post_type_slug]['#name'] = 'ct[supports][' . $post_type_slug . ']';
        $options[$post_type_slug]['#title'] = $post_type->labels->singular_name;
        $options[$post_type_slug]['#default_value'] = !empty($ct['supports'][$post_type_slug]);
        $options[$post_type_slug]['#inline'] = true;
        $options[$post_type_slug]['#after'] = '&nbsp;&nbsp;';
        if (is_rtl()) {
            $options[$post_type_slug]['#before'] = '<div style="float:right;margin-left:10px;">';
            $options[$post_type_slug]['#after'] .= '</div>';
        }
    }
    $form['table-3-open'] = array('#type' => 'markup', '#markup' => '<table id="wpcf-types-form-taxonomies-table" class="wpcf-types-form-table widefat"><thead><tr><th>' . __('Select Post Types', 'wpcf') . '</th></tr></thead><tbody><tr><td>');
    $form['types'] = array('#type' => 'checkboxes', '#options' => $options, '#description' => __('Registered post types that will be used with this taxonomy.', 'wpcf'), '#name' => 'ct[supports]', '#inline' => true);
    $form['table-3-close'] = array('#type' => 'markup', '#markup' => '</td></tr></tbody></table>');
    $form['table-4-open'] = array('#type' => 'markup', '#markup' => '<table id="wpcf-types-form-labels-table" class="wpcf-types-form-table widefat"><thead><tr><th colspan="3">' . __('Labels', 'wpcf') . '</th></tr></thead><tbody>');
    $labels = array('search_items' => array('title' => __('Search %s', 'wpcf'), 'description' => __("The search items text. Default is __( 'Search Tags' ) or __( 'Search Categories' ).", 'wpcf')), 'popular_items' => array('title' => __('Popular %s', 'wpcf'), 'description' => __("The popular items text. Default is __( 'Popular Tags' ) or null.", 'wpcf')), 'all_items' => array('title' => __('All %s', 'wpcf'), 'description' => __("The all items text. Default is __( 'All Tags' ) or __( 'All Categories' ).", 'wpcf')), 'parent_item' => array('title' => __('Parent %s', 'wpcf'), 'description' => __("The parent item text. This string is not used on non-hierarchical taxonomies such as post tags. Default is null or __( 'Parent Category' ).", 'wpcf')), 'parent_item_colon' => array('title' => __('Parent %s:', 'wpcf'), 'description' => __("The same as parent_item, but with colon : in the end null, __( 'Parent Category:' ).", 'wpcf')), 'edit_item' => array('title' => __('Edit %s', 'wpcf'), 'description' => __("The edit item text. Default is __( 'Edit Tag' ) or __( 'Edit Category' ).", 'wpcf')), 'update_item' => array('title' => __('Update %s', 'wpcf'), 'description' => __("The update item text. Default is __( 'Update Tag' ) or __( 'Update Category' ).", 'wpcf')), 'add_new_item' => array('title' => __('Add New %s', 'wpcf'), 'description' => __("The add new item text. Default is __( 'Add New Tag' ) or __( 'Add New Category' ).", 'wpcf')), 'new_item_name' => array('title' => __('New %s Name', 'wpcf'), 'description' => __("The new item name text. Default is __( 'New Tag Name' ) or __( 'New Category Name' ).", 'wpcf')), 'separate_items_with_commas' => array('title' => __('Separate %s with commas', 'wpcf'), 'description' => __("The separate item with commas text used in the taxonomy meta box. This string isn't used on hierarchical taxonomies. Default is __( 'Separate tags with commas' ), or null.", 'wpcf')), 'add_or_remove_items' => array('title' => __('Add or remove %s', 'wpcf'), 'description' => __("the add or remove items text used in the meta box when JavaScript is disabled. This string isn't used on hierarchical taxonomies. Default is __( 'Add or remove tags' ) or null.", 'wpcf')), 'choose_from_most_used' => array('title' => __('Choose from the most used %s', 'wpcf'), 'description' => __("The choose from most used text used in the taxonomy meta box. This string isn't used on hierarchical taxonomies. Default is __( 'Choose from the most used tags' ) or null.", 'wpcf')), 'menu_name' => array('title' => __('Menu Name', 'wpcf'), 'description' => __("The menu name text. This string is the name to give menu items. Defaults to value of name.", 'wpcf')));
    foreach ($labels as $name => $data) {
        $form['labels-' . $name] = array('#type' => 'textfield', '#name' => 'ct[labels][' . $name . ']', '#title' => ucwords(str_replace('_', ' ', $name)), '#description' => $data['description'], '#value' => isset($ct['labels'][$name]) ? $ct['labels'][$name] : '', '#inline' => true, '#pattern' => '<tr><td><LABEL></td><td><ELEMENT></td><td><DESCRIPTION></td>');
    }
    $form['table-4-close'] = array('#type' => 'markup', '#markup' => '</tbody></table>');
    $form['table-6-open'] = array('#type' => 'markup', '#markup' => '<table id="wpcf-types-form-supports-table" class="wpcf-types-form-table widefat"><thead><tr><th>' . __('Options', 'wpcf') . '</th></tr></thead><tbody><tr><td>');
    $form['make-hierarchical'] = array('#type' => 'radios', '#name' => 'ct[hierarchical]', '#default_value' => empty($ct['hierarchical']) || $ct['hierarchical'] == 'flat' ? 'flat' : 'hierarchical', '#inline' => true, '#options' => array(__('Hierarchical - like post categories, with parent / children relationship and checkboxes to select taxonomy', 'wpcf') => 'hierarchical', __('Flat - like post tags, with a text input to enter terms', 'wpcf') => 'flat'), '#after' => '<br /><br />');
    $form['rewrite-enabled'] = array('#type' => 'checkbox', '#force_boolean' => true, '#title' => __('Rewrite', 'wpcf'), '#name' => 'ct[rewrite][enabled]', '#description' => __('Rewrite permalinks with this format. Default will use $taxonomy as query var.', 'wpcf'), '#default_value' => !empty($ct['rewrite']['enabled']), '#inline' => true);
    $hidden = empty($ct['rewrite']['enabled']) ? ' class="hidden"' : '';
    $form['rewrite-slug'] = array('#type' => 'textfield', '#name' => 'ct[rewrite][slug]', '#title' => __('Prepend posts with this slug', 'wpcf'), '#description' => __('Optional', 'wpcf') . '. ' . __("Prepend posts with this slug - defaults to taxonomy's name.", 'wpcf'), '#value' => isset($ct['rewrite']['slug']) ? $ct['rewrite']['slug'] : '', '#inline' => true, '#before' => '<div id="wpcf-types-form-rewrite-toggle"' . $hidden . '>', '#after' => '</div>', '#validate' => array('rewriteslug' => array('value' => 'true')));
    $form['rewrite-with_front'] = array('#type' => 'checkbox', '#force_boolean' => true, '#title' => __('Allow permalinks to be prepended with front base', 'wpcf'), '#name' => 'ct[rewrite][with_front]', '#description' => __('Defaults to true.', 'wpcf'), '#default_value' => !empty($ct['rewrite']['with_front']), '#inline' => true);
    $form['rewrite-hierarchical'] = array('#type' => 'checkbox', '#name' => 'ct[rewrite][hierarchical]', '#title' => __('Hierarchical URLs', 'wpcf'), '#description' => sprintf(__('True or false allow hierarchical urls (implemented in %sVersion 3.1%s).', 'wpcf'), '<a href="http://codex.wordpress.org/Version_3.1" title="Version 3.1" target="_blank">', '</a>'), '#default_value' => !empty($ct['rewrite']['hierarchical']), '#inline' => true);
    $form['vars'] = array('#type' => 'checkboxes', '#name' => 'ct[advanced]', '#inline' => true, '#options' => array('show_ui' => array('#name' => 'ct[show_ui]', '#default_value' => !empty($ct['show_ui']), '#title' => __('show_ui', 'wpcf'), '#description' => __('Whether to generate a default UI for managing this taxonomy.', 'wpcf') . '<br />' . __('Default: if not set, defaults to value of public argument.', 'wpcf'), '#inline' => true), 'show_in_nav_menus' => array('#name' => 'ct[show_in_nav_menus]', '#default_value' => !empty($ct['show_in_nav_menus']), '#title' => __('show_in_nav_menus', 'wpcf'), '#description' => __('True makes this taxonomy available for selection in navigation menus.', 'wpcf') . '<br />' . __('Default: if not set, defaults to value of public argument.', 'wpcf'), '#inline' => true), 'show_tagcloud' => array('#name' => 'ct[show_tagcloud]', '#default_value' => !empty($ct['show_tagcloud']), '#title' => __('show_tagcloud', 'wpcf'), '#description' => __('Whether to allow the Tag Cloud widget to use this taxonomy.', 'wpcf') . '<br />' . __('Default: if not set, defaults to value of show_ui argument.', 'wpcf'), '#inline' => true)));
    if (wpcf_compare_wp_version('3.5', '>=')) {
        $form['vars']['#options']['show_admin_column'] = array('#name' => 'ct[show_admin_column]', '#default_value' => !empty($ct['show_admin_column']), '#title' => __('show_admin_column', 'wpcf'), '#description' => __('Whether to allow automatic creation of taxonomy columns on associated post-types.', 'wpcf') . '<br />' . __('Default: false.', 'wpcf'), '#inline' => true);
    }
    $query_var = isset($ct['query_var']) ? $ct['query_var'] : '';
    $hidden = !empty($ct['query_var_enabled']) ? '' : ' class="hidden"';
    $form['query_var'] = array('#type' => 'checkbox', '#name' => 'ct[query_var_enabled]', '#title' => 'query_var', '#description' => __('False to prevent queries, or string to customize query var. Default will use $taxonomy as query var.', 'wpcf') . '<br />' . __('Default: $taxonomy.', 'wpcf'), '#default_value' => !empty($ct['query_var_enabled']), '#after' => '<div id="wpcf-types-form-queryvar-toggle"' . $hidden . '><input type="text" name="ct[query_var]" value="' . $query_var . '" class="wpcf-form-textfield form-textfield textfield" /><div class="description wpcf-form-description wpcf-form-description-checkbox description-checkbox">' . __('Optional', 'wpcf') . '. ' . __('String to customize query var', 'wpcf') . '</div></div>', '#inline' => true);
    $form['update_count_callback'] = array('#type' => 'textfield', '#name' => 'ct[update_count_callback]', '#title' => 'update_count_callback', 'wpcf', '#description' => __('Function name that will be called to update the count of an associated $object_type, such as post, is updated.', 'wpcf') . '<br />' . __('Default: None.', 'wpcf'), '#value' => !empty($ct['update_count_callback']) ? $ct['update_count_callback'] : '', '#inline' => true);
    $form['table-6-close'] = array('#type' => 'markup', '#markup' => '</td></tr></tbody></table>');
    $form['submit'] = array('#type' => 'submit', '#name' => 'submit', '#value' => __('Save Taxonomy', 'wpcf'), '#attributes' => array('class' => 'button-primary wpcf-disabled-on-submit'));
    return $form;
}
Пример #14
0
/**
 * Get main post ID.
 * 
 * @param type $context
 * @return type
 */
function wpcf_get_post_id($context = 'group')
{
    if (!is_admin()) {
        /*
         * 
         * TODO Check if frontend is fine (rendering children).
         * get_post() previously WP 3.5 requires $post_id
         */
        $post_id = null;
        if (wpcf_compare_wp_version('3.5', '<')) {
            global $post;
            $post_id = !empty($post->ID) ? $post->ID : -1;
        }
        $_post = get_post($post_id);
        return !empty($_post->ID) ? $_post->ID : -1;
    }
    /*
     * TODO Explore possible usage for $context
     */
    $post = wpcf_admin_get_edited_post();
    return empty($post->ID) ? -1 : $post->ID;
}
Пример #15
0
/**
 * Renders meta box content.
 * 
 * Core function. Works and stable.
 * If required, add hooks only.
 * 
 * @todo Revise this 1.1.5
 * 
 * @param type $post
 * @param type $group 
 */
function wpcf_admin_post_meta_box($post, $group)
{
    global $wpcf;
    static $nonce_added = false;
    /*
     * TODO Document where this is used
     */
    if (!$nonce_added) {
        $nonce_action = 'update-' . $post->post_type . '_' . $post->ID;
        wp_nonce_field($nonce_action, '_wpcf_post_wpnonce');
        $nonce_added = true;
    }
    /*
     * TODO Move to Conditional code
     * 
     * This is already checked. Use hook to add wrapper DIVS and apply CSS.
     */
    if (!empty($group['args']['_conditional_display'])) {
        if ($group['args']['_conditional_display'] == 'failed') {
            echo '<div class="wpcf-cd-group wpcf-cd-group-failed" style="display:none;">';
        } else {
            echo '<div class="wpcf-cd-group wpcf-cd-group-passed">';
        }
    }
    /*
     * TODO Move this into Field code
     * Process fields
     */
    if (!empty($group['args']['fields'])) {
        // Display description
        if (!empty($group['args']['description'])) {
            echo '<div class="wpcf-meta-box-description">' . wpautop(wpcf_translate('group ' . $group['args']['id'] . ' description', $group['args']['description'])) . '</div>';
        }
        foreach ($group['args']['fields'] as $field_slug => $field) {
            if (empty($field) || !is_array($field)) {
                continue;
            }
            $field = $wpcf->field->_parse_cf_form_element($field);
            if (!isset($field['#id'])) {
                $field['#id'] = wpcf_unique_id(serialize($field));
            }
            // Render form elements
            if (wpcf_compare_wp_version() && $field['#type'] == 'wysiwyg') {
                // Especially for WYSIWYG
                echo '<div class="wpcf-wysiwyg">';
                echo '<div id="wpcf-textarea-textarea-wrapper" class="form-item form-item-textarea wpcf-form-item wpcf-form-item-textarea">';
                echo isset($field['#before']) ? $field['#before'] : '';
                echo '
<label class="wpcf-form-label wpcf-form-textarea-label">' . $field['#title'] . '</label>';
                echo '<div class="description wpcf-form-description wpcf-form-description-textarea description-textarea">
' . wpautop($field['#description']) . '</div>';
                wp_editor($field['#value'], $field['#id'], $field['#editor_settings']);
                $field['slug'] = str_replace(WPCF_META_PREFIX . 'wysiwyg-', '', $field_slug);
                $field['type'] = 'wysiwyg';
                echo '</div>';
                echo isset($field['#after']) ? $field['#after'] : '';
                echo '</div><br /><br />';
            } else {
                if ($field['#type'] == 'wysiwyg') {
                    $field['#type'] = 'textarea';
                }
                echo wpcf_form_simple(array($field['#id'] => $field));
            }
            do_action('wpcf_fields_' . $field_slug . '_meta_box_form', $field);
            if (isset($field['wpcf-type'])) {
                // May be ignored
                do_action('wpcf_fields_' . $field['wpcf-type'] . '_meta_box_form', $field);
            }
        }
    }
    /*
     * TODO Move to Conditional code
     * 
     * This is already checked. Use hook to add wrapper DIVS and apply CSS.
     */
    if (!empty($group['args']['_conditional_display'])) {
        echo '</div>';
    }
}
Пример #16
0
/**
 * Gets all available types.
 */
function wpcf_admin_fields_get_available_types()
{
    static $data = array();
    if (!empty($data)) {
        return $data;
    }
    foreach (glob(WPCF_EMBEDDED_INC_ABSPATH . '/fields/*.php') as $filename) {
        require_once $filename;
        if (function_exists('wpcf_fields_' . basename($filename, '.php'))) {
            $data_field = call_user_func('wpcf_fields_' . basename($filename, '.php'));
            if (!empty($data_field['wp_version'])) {
                if (wpcf_compare_wp_version($data_field['wp_version'], '>=')) {
                    $data[basename($filename, '.php')] = $data_field;
                }
            } else {
                $data[basename($filename, '.php')] = $data_field;
            }
        }
    }
    $data = apply_filters('types_register_fields', $data);
    return $data;
}
Пример #17
0
<?php

if (wpcf_compare_wp_version('3.3', '<')) {
    return false;
}
/**
 * Register data (called automatically).
 * 
 * @return type 
 */
function wpcf_fields_wysiwyg()
{
    $settings = array('id' => 'wpcf-wysiwyg', 'title' => __('WYSIWYG', 'wpcf'), 'description' => __('WYSIWYG editor', 'wpcf'), 'meta_box_css' => array('wpcf-fields-wysiwyg' => array('inline' => 'wpcf_fields_wysiwyg_css')));
    $settings['wp_version'] = '3.3';
    return $settings;
}
/**
 * Meta box form.
 * 
 * @param type $field
 * @return array 
 */
function wpcf_fields_wysiwyg_meta_box_form($field)
{
    $set = array('wpautop' => true, 'media_buttons' => true, 'textarea_name' => 'wpcf[' . $field['id'] . ']', 'textarea_rows' => get_option('default_post_edit_rows', 10), 'tabindex' => '', 'editor_css' => '', 'editor_class' => 'wpcf-wysiwyg', 'teeny' => false, 'dfw' => false, 'tinymce' => true, 'quicktags' => true);
    $form = array('#type' => 'wysiwyg', '#attributes' => array('class' => 'wpcf-wysiwyg'), '#editor_settings' => $set);
    return $form;
}
/**
 * CSS for styling TinyMCE Editor.
 */