当前位置: 首页>>代码示例>>PHP>>正文


PHP wpcf_admin_post_add_to_editor函数代码示例

本文整理汇总了PHP中wpcf_admin_post_add_to_editor函数的典型用法代码示例。如果您正苦于以下问题:PHP wpcf_admin_post_add_to_editor函数的具体用法?PHP wpcf_admin_post_add_to_editor怎么用?PHP wpcf_admin_post_add_to_editor使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了wpcf_admin_post_add_to_editor函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: wpcf_admin_post_add_postmeta_to_editor_on_demand

 public static function wpcf_admin_post_add_postmeta_to_editor_on_demand($editor)
 {
     add_action('admin_footer', 'wpcf_admin_post_js_validation');
     wpcf_enqueue_scripts();
     wp_enqueue_script('toolset-colorbox');
     wp_enqueue_style('toolset-colorbox');
     $current_post = wpcf_admin_get_edited_post();
     if (empty($current_post)) {
         $current_post = (object) array('ID' => -1);
     }
     $fields = wpcf_admin_post_add_to_editor('get');
     $groups = wpcf_admin_post_get_post_groups_fields($current_post);
     if (!empty($fields) && !empty($groups)) {
         foreach ($groups as $group) {
             if (empty($group['fields'])) {
                 continue;
             }
             foreach ($group['fields'] as $group_field_id => $group_field) {
                 if (isset($fields[$group_field_id])) {
                     $field = $fields[$group_field_id];
                     $callback = 'wpcfFieldsEditorCallback(\'' . $field['id'] . '\', \'postmeta\', ' . $current_post->ID . ')';
                     $editor->add_insert_shortcode_menu(stripslashes($field['name']), trim(wpcf_fields_get_shortcode($field), '[]'), $group['name'], $callback);
                 }
             }
         }
     }
 }
开发者ID:SpencerNeitzke,项目名称:types,代码行数:27,代码来源:wpviews.php

示例2: wpcf_admin_post_add_to_editor_js

/**
 * Renders JS for editor menu.
 *
 * Core function. Works and stable. Do not move or change.
 * If required, add hooks only.
 *
 * @return type
 */
function wpcf_admin_post_add_to_editor_js()
{
    // since 1.3 we do not use global $post
    $post = wpcf_admin_get_edited_post();
    if (empty($post)) {
        $post = (object) array('ID' => -1);
    }
    $fields = wpcf_admin_post_add_to_editor('get');
    $groups = wpcf_admin_post_get_post_groups_fields($post);
    if (empty($fields) || empty($groups)) {
        return false;
    }
    $editor_addon = new Editor_addon('types', __('Insert Types Shortcode', 'wpcf'), WPCF_EMBEDDED_RES_RELPATH . '/js/types_editor_plugin.js', '', true, 'icon-types-logo ont-icon-18 ont-color-gray');
    foreach ($groups as $group) {
        if (empty($group['fields'])) {
            continue;
        }
        foreach ($group['fields'] as $group_field_id => $group_field) {
            if (!isset($fields[$group_field_id])) {
                continue;
            }
            $field = $fields[$group_field_id];
            $callback = 'wpcfFieldsEditorCallback(\'' . $field['id'] . '\', \'postmeta\', ' . $post->ID . ')';
            $editor_addon->add_insert_shortcode_menu(stripslashes($field['name']), trim(wpcf_fields_get_shortcode($field), '[]'), $group['name'], $callback);
        }
    }
}
开发者ID:SpencerNeitzke,项目名称:types,代码行数:35,代码来源:fields-post.php

示例3: _get_meta_form


//.........这里部分代码省略.........
      *
      *
      *
      *
      * Since Types 1.2
      * Avoid using parent (inherited) type
      * $this->config->inherited_field_type
      */
     // See if inherited data and merge
     if (isset($this->config->inherited_field_type)) {
         if (!array_key_exists($this->cf['type'], $this->_deprecated_inherited_allowed())) {
             //                _deprecated_argument( 'inherited_field_type', '1.2',
             //                        'Since Types 1.2 we encourage developers to completely define fields' );
         }
         $file = $this->_include_file_by_field_type($this->config->inherited_field_type);
         if (file_exists($file)) {
             if (function_exists('wpcf_fields_' . $this->config->inherited_field_type . '_meta_box_form')) {
                 $inherited = call_user_func_array('wpcf_fields_' . $this->config->inherited_field_type . '_meta_box_form', array($this->cf, $this));
                 // If single form - convert to array of elements
                 if (isset($inherited['#type'])) {
                     $inherited = array('wpcf_field_' . $this->unique_id => $inherited);
                 }
                 // One value?
                 if (count($inherited) > 1) {
                     $this->__multiple = true;
                 }
                 $form = $form + $inherited;
             }
         }
     }
     $func = 'wpcf_fields_' . $this->cf['type'] . '_meta_box_form';
     if (is_callable($func)) {
         /*
          *
          * From Types 1.2 use complete form setup
          */
         $form_meta_box = call_user_func_array('wpcf_fields_' . $this->cf['type'] . '_meta_box_form', array($this->cf, $this));
         // If single form - convert to array of elements
         if (isset($form_meta_box['#type'])) {
             $form_meta_box = array('wpcf_field_' . $this->unique_id => $form_meta_box);
         }
         // One value?
         if (count($form_meta_box) > 1) {
             $this->__multiple = true;
         }
         // Merge
         $form = array_merge($form, $form_meta_box);
     }
     if (!empty($form)) {
         // Process each field
         foreach ($form as $element_key => $element) {
             /*
              *
              * Start using __ in keys to skip element
              */
             // Skip protected
             if (strpos($element_key, '__') === 0) {
                 $form[$element_key] = $element;
                 continue;
             }
             // Add title and description
             // TODO WPML
             if (empty($started)) {
                 $_title = isset($element['#title']) ? $element['#title'] : $this->cf['name'];
                 $element['#title'] = wpcf_translate('field ' . $this->cf['id'] . ' name', $_title);
                 // Add asterisk for required fields
                 if (isset($this->cf['data']['validate']['required'])) {
                     $element['#title'] .= '*';
                 }
                 $_description = isset($element['#description']) ? $element['#description'] : $this->cf['description'];
                 $element['#description'] = wpautop(wpcf_translate('field ' . $this->cf['id'] . ' description', $_description));
                 $started = true;
             }
             // Set current element
             $this->__current_form_element = $element;
             // Process field
             $temp_processed = wpcf_admin_post_process_field($this);
             if (!empty($temp_processed['element'])) {
                 $element = $temp_processed['element'];
             }
             // Set form element
             $form[$element_key] = apply_filters('wpcf_post_edit_field', $element, $this->cf, $this->post, $this->context);
         }
         // Add to editor
         if ($this->add_to_editor) {
             wpcf_admin_post_add_to_editor($this->cf);
         }
         $this->enqueue_script();
         $this->enqueue_style();
     }
     // Close main wrapper
     if ($wrap) {
         $form['meta_form_CLOSE'] = array('#type' => 'markup', '#markup' => '' . '</div>');
     }
     // Add unique IDs
     foreach ($form as $k => $v) {
         $_form[$k . '_' . $this->unique_id] = $v;
     }
     return apply_filters('wpcf_meta_form', $_form);
 }
开发者ID:phuocdungit,项目名称:fundy,代码行数:101,代码来源:field.php

示例4: __wpcf_usermeta_test

function __wpcf_usermeta_test()
{
    require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields-post.php';
    $field['id'] = md5('date' . time());
    $here = array(basename($_SERVER['REQUEST_URI']), basename($_SERVER['SCRIPT_FILENAME']));
    global $post;
    // Get post_type
    if ($post) {
        $post_type = get_post_type($post);
    } else {
        if (!empty($_GET['post'])) {
            $post_type = get_post_type(sanitize_text_field($_GET['post']));
        } else {
            if (!empty($_GET['post_type'])) {
                $post_type = esc_html(sanitize_text_field($_GET['post_type']));
            }
        }
    }
    if ($here[0] == ('index.php' || 'wp-admin') && $here[1] != 'index.php') {
        /** This action is documented in embedded/bootstrap.php */
        $post_types_without_meta_boxes = apply_filters('toolset_filter_exclude_own_post_types', array('view', 'view-template', 'cred-form', 'cred-user-form'));
        if (isset($post_type) && in_array($post_type, $post_types_without_meta_boxes)) {
            return;
        }
        wpcf_admin_post_add_to_editor($field);
    }
}
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:27,代码来源:usermeta-init.php

示例5: __wpcf_usermeta_test

function __wpcf_usermeta_test()
{
    require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields-post.php';
    $field['id'] = md5('date' . time());
    $here = array(basename($_SERVER['REQUEST_URI']), basename($_SERVER['SCRIPT_FILENAME']));
    global $post;
    // Get post_type
    if ($post) {
        $post_type = get_post_type($post);
    } else {
        if (!empty($_GET['post'])) {
            $post_type = get_post_type(sanitize_text_field($_GET['post']));
        } else {
            if (!empty($_GET['post_type'])) {
                $post_type = esc_html(sanitize_text_field($_GET['post_type']));
            }
        }
    }
    if ($here[0] == ('index.php' || 'wp-admin') && $here[1] != 'index.php') {
        if (isset($post_type) && in_array($post_type, array('view', 'view-template', 'cred-form'))) {
            return;
        }
        wpcf_admin_post_add_to_editor($field);
    }
}
开发者ID:KryvunRoman,项目名称:yobko,代码行数:25,代码来源:usermeta-init.php

示例6: wpcf_admin_post_add_to_editor_js

/**
 * Renders JS for editor menu.
 * 
 * Core function. Works and stable. Do not move or change.
 * If required, add hooks only.
 * 
 * @return type 
 */
function wpcf_admin_post_add_to_editor_js()
{
    global $post;
    $fields = wpcf_admin_post_add_to_editor('get');
    $groups = wpcf_admin_post_get_post_groups_fields($post);
    if (empty($fields) || empty($groups)) {
        return false;
    }
    $editor_addon = new Editor_addon('types', __('Insert Types Shortcode', 'wpcf'), WPCF_EMBEDDED_RES_RELPATH . '/js/types_editor_plugin.js', WPCF_EMBEDDED_RES_RELPATH . '/images/bw-logo-16.png');
    foreach ($groups as $group) {
        if (empty($group['fields'])) {
            continue;
        }
        foreach ($group['fields'] as $group_field_id => $group_field) {
            if (!isset($fields[$group_field_id])) {
                continue;
            }
            $field = $fields[$group_field_id];
            $data = wpcf_fields_type_action($field['type']);
            $callback = '';
            if (isset($data['editor_callback'])) {
                $callback = sprintf($data['editor_callback'], $field['id']);
            } else {
                // Set callback if function exists
                $function = 'wpcf_fields_' . $field['type'] . '_editor_callback';
                $callback = function_exists($function) ? 'wpcfFieldsEditorCallback(\'' . $field['id'] . '\')' : '';
            }
            $editor_addon->add_insert_shortcode_menu(stripslashes($field['name']), trim(wpcf_fields_get_shortcode($field), '[]'), $group['name'], $callback);
        }
    }
}
开发者ID:adisonc,项目名称:MaineLearning,代码行数:39,代码来源:fields-post.php


注:本文中的wpcf_admin_post_add_to_editor函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。