• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP wpcf_wpml_field_is_copied函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: wpcf_fields_file_meta_box_form

/**
 * Form data for post edit page.
 *
 * @global object $wpdb
 *
 * @param type $field
 */
function wpcf_fields_file_meta_box_form($field)
{
    add_thickbox();
    $button_text = sprintf(__('Select %s', 'wpcf'), $field['type']);
    // Set ID
    $element_id = 'wpcf-fields-' . wpcf_unique_id(serialize(func_get_args()));
    $attachment_id = false;
    // Get attachment by guid
    global $wpdb;
    if (!empty($field['value'])) {
        $attachment_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_type = 'attachment' AND guid=%s", $field['value']));
    }
    // Set preview
    $preview = '';
    // TODO WPML move
    if (!wpcf_wpml_field_is_copied($field)) {
        if (!empty($attachment_id)) {
            $preview = wp_get_attachment_image($attachment_id, 'thumbnail');
        } else {
            // If external image set preview
            $file_path = parse_url($field['value']);
            if ($file_path && isset($file_path['path'])) {
                $file = pathinfo($file_path['path']);
            } else {
                $file = pathinfo($field['value']);
            }
            if (isset($file['extension']) && in_array(strtolower($file['extension']), array('jpg', 'jpeg', 'gif', 'png'))) {
                $preview = '<img alt="" src="' . $field['value'] . '" />';
            }
        }
    }
    // Set button
    // TODO WPML move
    if (!wpcf_wpml_field_is_copied($field)) {
        if (!empty($field['#attributes']['readonly']) || !empty($field['#attributes']['disabled'])) {
            $button = '';
        } else {
            $button = '<a href="javascript:void(0);"' . ' class="wpcf-fields-' . ($field['type'] == 'image' ? 'image' : 'file') . '-upload-link button-secondary"' . ' id="' . $element_id . '-upload" ' . "data-types='{\"type\":\"{$field['type']}\",\"id\":\"{$field['id']}\"}'>" . $button_text . '</a>';
        }
    } else {
        $button = '';
    }
    // Set form
    $form = array('#type' => 'textfield', '#id' => $element_id . '-upload-holder', '#name' => 'wpcf[' . $field['slug'] . ']', '#suffix' => '&nbsp;' . $button, '#after' => '<div id="' . $element_id . '-upload-holder-preview"' . ' class="wpcf-fields-file-preview">' . $preview . '</div>', '#attributes' => array('class' => 'wpcf-fields-file-textfield'));
    return $form;
}
开发者ID:olechka1505,项目名称:hungrylemur,代码行数:53,代码来源:file.php


示例2: wpcf_admin_post_process_field


//.........这里部分代码省略.........
            }
        }
        // Set atributes #2 (override)
        if (isset($field['disable'])) {
            $element['#disable'] = $field['disable'];
        }
        if (!empty($field['disable'])) {
            $element['#attributes']['disabled'] = 'disabled';
        }
        if (!empty($field['readonly'])) {
            $element['#attributes']['readonly'] = 'readonly';
            if (!empty($element['#options'])) {
                foreach ($element['#options'] as $key => $option) {
                    if (!is_array($option)) {
                        $element['#options'][$key] = array('#title' => $key, '#value' => $option);
                    }
                    $element['#options'][$key]['#attributes']['readonly'] = 'readonly';
                    if ($element['#type'] == 'select') {
                        $element['#options'][$key]['#attributes']['disabled'] = 'disabled';
                    }
                }
            }
            if ($element['#type'] == 'select') {
                $element['#attributes']['disabled'] = 'disabled';
            }
        }
        // Check if it was invalid on submit and add error message
        if ($post && !empty($invalid_fields)) {
            if (isset($invalid_fields[$element['#id']]['#error'])) {
                $element['#error'] = $invalid_fields[$element['#id']]['#error'];
            }
        }
        // TODO WPML move Set WPML locked icon
        if (wpcf_wpml_field_is_copied($field)) {
            $element['#title'] .= '<img src="' . WPCF_EMBEDDED_RES_RELPATH . '/images/locked.png" alt="' . __('This field is locked for editing because WPML will copy its value from the original language.', 'wpcf') . '" title="' . __('This field is locked for editing because WPML will copy its value from the original language.', 'wpcf') . '" style="position:relative;left:2px;top:2px;" />';
        }
        // Add repetitive class
        // TODO WPML move
        if (types_is_repetitive($field) && $context != 'post_relationship' && wpcf_wpml_field_is_copied($field)) {
            if (!empty($element['#options']) && $element['#type'] != 'select') {
                foreach ($element['#options'] as $temp_key => $temp_value) {
                    $element['#options'][$temp_key]['#attributes']['class'] = isset($element['#attributes']['class']) ? $element['#attributes']['class'] . ' wpcf-repetitive' : 'wpcf-repetitive';
                }
            } else {
                $element['#attributes']['class'] = isset($element['#attributes']['class']) ? $element['#attributes']['class'] . ' wpcf-repetitive' : 'wpcf-repetitive';
            }
            /*
            *
            *
            * Since Types 1.2 we allow same field values
            *
            * TODO Remove
            *
            * wpcf_admin_add_js_settings('wpcfFormRepetitiveUniqueValuesCheckText',
             '\'' . __('Warning: same values set', 'wpcf') . '\'');
            */
        }
        // Set read-only if copied by WPML
        // TODO WPML Move this to separate WPML code and use only hooks 1.1.5
        if (wpcf_wpml_field_is_copied($field)) {
            if (isset($element['#options'])) {
                foreach ($element['#options'] as $temp_key => $temp_value) {
                    if (isset($temp_value['#attributes'])) {
                        $element['#options'][$temp_key]['#attributes']['readonly'] = 'readonly';
                    } else {
                        $element['#options'][$temp_key]['#attributes'] = array('readonly' => 'readonly');
开发者ID:SpencerNeitzke,项目名称:types,代码行数:67,代码来源:fields-post.php


示例3: wpcf_field_skype_repetitive

/**
 * Processes repetitive Skype fields.
 *
 * Each form element is sent separately.
 * Determine which is which and process it.
 *
 * @staticvar array $repetitive_started
 * @staticvar array $repetitive_index
 * @param type $post
 * @param string $field
 * @param type $skype_element
 * @return string
 */
function wpcf_field_skype_repetitive($element, $post, $field, $array_key)
{
    global $wpcf;
    if ($field['type'] != 'skype') {
        return $element;
    }
    switch ($array_key) {
        case 'skypename':
            // TODO WPML move
            if (wpcf_wpml_field_is_copied($field)) {
                $element['#after'] .= '<input type="hidden" name="wpcf_repetitive_copy[' . $field['id'] . '][' . $wpcf->repeater->index . ']" value="1" />';
            }
            /*
             *
             * If added via AJAX set value
             */
            if (defined('DOING_AJAX')) {
                $field['value'] = '__wpcf_repetitive_new_field';
                $element['#value'] = '';
            }
            break;
        default:
            break;
    }
    return $element;
}
开发者ID:SpencerNeitzke,项目名称:types,代码行数:39,代码来源:skype.php


示例4: renderElement

 /**
  * Renders element.
  *
  * Depending on element type, it calls class methods.
  *
  * @param array $element
  * @return HTML formatted output
  */
 public function renderElement($element)
 {
     $method = $element['#type'];
     if (!isset($element['#name']) && !in_array($element['#type'], array('markup', 'checkboxes'))) {
         if (!isset($element['#attributes']['name'])) {
             return '#name or #attributes[\'name\'] required!';
         } else {
             $element['#name'] = $element['#attributes']['name'];
         }
     }
     if (is_callable(array($this, $method))) {
         $custom_field_title = '';
         if (isset($element['#title']) && !empty($element['#title'])) {
             $custom_field_title = $element['#title'];
         }
         if (empty($custom_field_title) && isset($element['#name']) && !empty($element['#name'])) {
             $custom_field_title = $element['#name'];
         }
         if (!isset($element['#id'])) {
             if (isset($element['#attributes']['id'])) {
                 $element['#id'] = $element['#attributes']['id'];
             } else {
                 $_id = isset($this->_id) ? $this->_id . '-' : '';
                 $element['#id'] = "{$_id}{$element['#type']}-" . $this->_count($element['#type']) . '-' . time();
             }
         }
         if (isset($this->_errors[$element['#id']])) {
             $element['#error'] = $this->_errors[$element['#id']];
         }
         // Add JS validation
         if (!empty($element['#validate'])) {
             if (isset($element['#validate']['required']) && !empty($element['#title'])) {
                 // Asterisk
                 $element['#title'] .= '&#42;';
             }
             $element['#attributes']['data-wpt-validate'] = esc_html(self::json_encode(apply_filters('wptoolset_forms_field_js_validation_data_' . $this->_id, $element['#validate'])));
             $element['#attributes']['data-wpt-field-title'] = esc_js($custom_field_title);
         }
         if ($element['#type'] == 'radios' && !empty($element['#options'])) {
             foreach ($element['#options'] as &$option) {
                 if (!empty($option['#validate'])) {
                     $option['#attributes']['data-wpt-validate'] = esc_html(self::json_encode(apply_filters('wptoolset_forms_field_js_validation_data_' . $this->_id, $option['#validate'])));
                     $option['#attributes']['data-wpt-field-title'] = esc_js($custom_field_title);
                 }
             }
         }
         /**
          * WPML - lock CF is has option "copy from original".
          */
         if (is_admin() && function_exists('wpcf_wpml_field_is_copied') && wpcf_wpml_field_is_copied($element)) {
             $element['#title'] .= sprintf('<img src="%s/images/locked.png" alt="%s" title="%s" style="position:relative;left:2px;top:2px;" />', WPCF_EMBEDDED_RES_RELPATH, __('This field is locked for editing because WPML will copy its value from the original language.', 'wpcf'), __('This field is locked for editing because WPML will copy its value from the original language.', 'wpcf'));
             $element['#attributes']['readonly'] = true;
         }
         return $this->{$method}($element);
     }
 }
开发者ID:Kilbourne,项目名称:restart,代码行数:64,代码来源:class.eforms.php


示例5: wpcf_fields_date_meta_box_form

/**
 * From data for post edit page.
 * 
 * @param type $field 
 * @param type $data
 * @param type $field_object Field instance 
 */
function wpcf_fields_date_meta_box_form($field, $field_object = null)
{
    /*
     * Added extra fields 'hour' and 'minute'.
     * 
     * If value is not array it is assumed that DB entry is timestamp()
     * and data is converted to array.
     */
    $value = $field['value'] = wpcf_fields_date_value_get_filter($field['value'], $field_object);
    // TODO WPML Set disable_in_form or similar to true, use hook for WPML
    if (wpcf_wpml_field_is_copied($field)) {
        $attributes = array('style' => 'width:150px;');
    } else {
        $attributes = array('class' => 'wpcf-datepicker', 'style' => 'width:150px;');
    }
    /*
     * 
     * Do not forget to trigger datepicker script
     * Only trigger on AJAX call (inserting new)
     */
    $js_trigger = defined('DOING_AJAX') ? '<script type="text/javascript">wpcfFieldsDateInit(\'\');</script>' : '';
    /*
     * 
     * 
     * Set Form
     */
    $unique_id = wpcf_unique_id(serialize($field));
    $form = array();
    $form[$unique_id . '-datepicker'] = array('#type' => 'textfield', '#title' => '&nbsp;' . $field['name'], '#attributes' => $attributes, '#name' => 'wpcf[' . $field['slug'] . '][datepicker]', '#id' => 'wpcf-date-' . $field['slug'] . '-datepicker-' . $unique_id, '#value' => $value['datepicker'], '#after' => '' . $js_trigger, '#_validate_this' => true);
    // Add warning about supported timestamp
    if (!fields_date_timestamp_neg_supported()) {
        $_visible = !empty($value['datepicker']) && intval($value['timestamp']) < 0 ? '' : ' style="display:none;"';
        $form[$unique_id . '-warning'] = array('#type' => 'markup', '#markup' => '<div class="wpcf-form-error"' . $_visible . '><p>' . __('Please enter a date after 1 January 1970', 'wpcf') . '</p></div>');
    }
    /*
     * 
     * If set 'date_and_time' add time
     */
    if (!empty($field['data']['date_and_time']) && $field['data']['date_and_time'] == 'and_time') {
        // Set parent CSS inline
        $form[$unique_id . '-datepicker']['#inline'] = true;
        $hours = 24;
        $minutes = 60;
        $options = array();
        // Hour
        for ($index = 0; $index < $hours; $index++) {
            $prefix = $index < 10 ? '0' : '';
            $options[$index] = array('#title' => $prefix . strval($index), '#value' => $index);
        }
        $form[$unique_id . 'time_hour'] = array('#type' => 'select', '#title' => __('Hour', 'wpcf'), '#inline' => true, '#before' => '<br />', '#after' => '&nbsp;&nbsp;', '#options' => $options, '#default_value' => $value['hour'], '#name' => 'wpcf[' . $field['slug'] . '][hour]', '#id' => 'wpcf-date-' . $field['slug'] . '-select-hour-' . $unique_id, '#inline' => true);
        // Minutes
        for ($index = 1; $index < $minutes; $index++) {
            $prefix = $index < 10 ? '0' : '';
            $options[$index] = array('#title' => $prefix . strval($index), '#value' => $index);
        }
        $form[$unique_id . 'time_minute'] = array('#type' => 'select', '#title' => __('Minute', 'wpcf'), '#after' => '<br /><br />', '#inline' => true, '#options' => $options, '#default_value' => $value['minute'], '#name' => 'wpcf[' . $field['slug'] . '][minute]', '#id' => 'wpcf-date-' . $field['slug'] . '-minute-' . $unique_id);
    }
    return $form;
}
开发者ID:CrankMaster336,项目名称:FFW-TR,代码行数:66,代码来源:date.php


示例6: wpcf_repetitive_drag_button

/**
 * Returns HTML formatted drag button.
 * 
 * @param type $field
 * @param type $post
 * @return string 
 */
function wpcf_repetitive_drag_button($field, $post)
{
    // TODO WPML move
    if (wpcf_wpml_field_is_copied($field)) {
        return '';
    }
    return '<div class="wpcf-repetitive-drag">&nbsp;</div>';
}
开发者ID:santikrass,项目名称:apache,代码行数:15,代码来源:repetitive-fields-ordering.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wpcf_wpml_post_is_original函数代码示例发布时间:2022-05-23
下一篇:
PHP wpcf_usermeta_get_user函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap