本文整理汇总了PHP中wpcf_custom_types_register_translation函数的典型用法代码示例。如果您正苦于以下问题:PHP wpcf_custom_types_register_translation函数的具体用法?PHP wpcf_custom_types_register_translation怎么用?PHP wpcf_custom_types_register_translation使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wpcf_custom_types_register_translation函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: wpcf_admin_bulk_string_translation
/**
* Bulk translation.
*/
function wpcf_admin_bulk_string_translation()
{
if (!function_exists('icl_register_string')) {
return false;
}
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
require_once WPCF_EMBEDDED_INC_ABSPATH . '/custom-types.php';
require_once WPCF_INC_ABSPATH . '/custom-types-form.php';
require_once WPCF_EMBEDDED_INC_ABSPATH . '/custom-taxonomies.php';
require_once WPCF_INC_ABSPATH . '/custom-taxonomies-form.php';
// Register groups
$groups = wpcf_admin_fields_get_groups();
foreach ($groups as $group_id => $group) {
wpcf_translate_register_string('plugin Types', 'group ' . $group_id . ' name', $group['name']);
if (isset($group['description'])) {
wpcf_translate_register_string('plugin Types', 'group ' . $group_id . ' description', $group['description']);
}
}
// Register fields
$fields = wpcf_admin_fields_get_fields();
foreach ($fields as $field_id => $field) {
wpcf_translate_register_string('plugin Types', 'field ' . $field_id . ' name', $field['name']);
if (isset($field['description'])) {
wpcf_translate_register_string('plugin Types', 'field ' . $field_id . ' description', $field['description']);
}
// For radios or select
if (!empty($field['data']['options'])) {
foreach ($field['data']['options'] as $name => $option) {
if ($name == 'default') {
continue;
}
if (isset($option['title'])) {
wpcf_translate_register_string('plugin Types', 'field ' . $field_id . ' option ' . $name . ' title', $option['title']);
}
if (isset($option['value'])) {
wpcf_translate_register_string('plugin Types', 'field ' . $field_id . ' option ' . $name . ' value', $option['value']);
}
if (isset($option['display_value'])) {
wpcf_translate_register_string('plugin Types', 'field ' . $field_id . ' option ' . $name . ' display value', $option['display_value']);
}
}
}
if ($field['type'] == 'checkbox' && (isset($field['set_value']) && $field['set_value'] != '1')) {
// we need to translate the check box value to store
wpcf_translate_register_string('plugin Types', 'field ' . $field_id . ' checkbox value', $field['set_value']);
}
if ($field['type'] == 'checkbox' && !empty($field['display_value_selected'])) {
// we need to translate the check box value to store
wpcf_translate_register_string('plugin Types', 'field ' . $field_id . ' checkbox value selected', $field['display_value_selected']);
}
if ($field['type'] == 'checkbox' && !empty($field['display_value_not_selected'])) {
// we need to translate the check box value to store
wpcf_translate_register_string('plugin Types', 'field ' . $field_id . ' checkbox value not selected', $field['display_value_not_selected']);
}
// Validation message
if (!empty($field['data']['validate'])) {
foreach ($field['data']['validate'] as $method => $validation) {
if (!empty($validation['message'])) {
// Skip if it's same as default
$default_message = wpcf_admin_validation_messages($method);
if ($validation['message'] != $default_message) {
wpcf_translate_register_string('plugin Types', 'field ' . $field_id . ' validation message ' . $method, $validation['message']);
}
}
}
}
}
// Register types
$custom_types = get_option('wpcf-custom-types', array());
foreach ($custom_types as $post_type => $data) {
wpcf_custom_types_register_translation($post_type, $data);
}
// Register taxonomies
$custom_taxonomies = get_option('wpcf-custom-taxonomies', array());
foreach ($custom_taxonomies as $taxonomy => $data) {
wpcf_custom_taxonimies_register_translation($taxonomy, $data);
}
}
开发者ID:sriram911,项目名称:pls,代码行数:81,代码来源:admin.php
示例2: wpcf_admin_custom_types_form_submit
//.........这里部分代码省略.........
if (isset($data['wpcf-post-type'])) {
$update = true;
$data['wpcf-post-type'] = sanitize_title($data['wpcf-post-type']);
}
if (isset($data['slug'])) {
$data['slug'] = sanitize_title($data['slug']);
}
if (isset($data['rewrite']['slug'])) {
$data['rewrite']['slug'] = remove_accents($data['rewrite']['slug']);
$data['rewrite']['slug'] = strtolower($data['rewrite']['slug']);
$data['rewrite']['slug'] = trim($data['rewrite']['slug']);
}
// Set post type name
$post_type = '';
if (!empty($data['slug'])) {
$post_type = $data['slug'];
} else {
if (!empty($data['wpcf-post-type'])) {
$post_type = $data['wpcf-post-type'];
} else {
if (!empty($data['labels']['singular_name'])) {
$post_type = sanitize_title($data['labels']['singular_name']);
}
}
}
if (empty($post_type)) {
wpcf_admin_message(__('Please set post type name', 'wpcf'), 'error');
// $form->triggerError();
return false;
}
$data['slug'] = $post_type;
$custom_types = get_option('wpcf-custom-types', array());
// Check reserved name
$reserved = wpcf_is_reserved_name($post_type);
if (is_wp_error($reserved)) {
wpcf_admin_message($reserved->get_error_message(), 'error');
return false;
}
// Check overwriting
if (!$update && array_key_exists($post_type, $custom_types)) {
wpcf_admin_message(__('Custom post type already exists', 'wpcf'), 'error');
// $form->triggerError();
return false;
}
/*
* Since Types 1.2
* We do not allow plural and singular names to be same.
*/
if ($wpcf->post_types->check_singular_plural_match($data)) {
wpcf_admin_message($wpcf->post_types->message('warning_singular_plural_match'), 'error');
return false;
}
// Check if renaming then rename all post entries and delete old type
if (!empty($data['wpcf-post-type']) && $data['wpcf-post-type'] != $post_type) {
global $wpdb;
$wpdb->update($wpdb->posts, array('post_type' => $post_type), array('post_type' => $data['wpcf-post-type']), array('%s'), array('%s'));
// Set protected data
$protected_data_check = $custom_types[$data['wpcf-post-type']];
// Delete old type
unset($custom_types[$data['wpcf-post-type']]);
$data['wpcf-post-type'] = $post_type;
} else {
// Set protected data
$protected_data_check = !empty($custom_types[$post_type]) ? $custom_types[$post_type] : array();
}
// Check if active
if (isset($custom_types[$post_type]['disabled'])) {
$data['disabled'] = $custom_types[$post_type]['disabled'];
}
// Sync taxes with custom taxes
if (!empty($data['taxonomies'])) {
$taxes = get_option('wpcf-custom-taxonomies', array());
foreach ($taxes as $id => $tax) {
if (array_key_exists($id, $data['taxonomies'])) {
$taxes[$id]['supports'][$data['slug']] = 1;
} else {
unset($taxes[$id]['supports'][$data['slug']]);
}
}
update_option('wpcf-custom-taxonomies', $taxes);
}
// Preserve protected data
foreach ($protected_data_check as $key => $value) {
if (strpos($key, '_') !== 0) {
unset($protected_data_check[$key]);
}
}
// Merging protected data
$custom_types[$post_type] = array_merge($protected_data_check, $data);
update_option('wpcf-custom-types', $custom_types);
// WPML register strings
wpcf_custom_types_register_translation($post_type, $data);
wpcf_admin_message_store(apply_filters('types_message_custom_post_type_saved', __('Custom post type saved', 'wpcf'), $data, $update), 'custom');
// Flush rewrite rules
flush_rewrite_rules();
do_action('wpcf_custom_types_save', $data);
// Redirect
wp_redirect(admin_url('admin.php?page=wpcf-edit-type&wpcf-post-type=' . $post_type . '&wpcf-rewrite=1'));
die;
}
开发者ID:adisonc,项目名称:MaineLearning,代码行数:101,代码来源:custom-types-form.php
示例3: wpcf_admin_custom_types_form_submit
//.........这里部分代码省略.........
return false;
}
// Check if renaming then rename all post entries and delete old type
if (!empty($data['wpcf-post-type']) && $data['wpcf-post-type'] != $post_type) {
global $wpdb;
$wpdb->update($wpdb->posts, array('post_type' => $post_type), array('post_type' => $data['wpcf-post-type']), array('%s'), array('%s'));
/**
* update post meta "_wp_types_group_post_types"
*/
$sql = sprintf('select meta_id, meta_value from %s where meta_key = \'%s\'', $wpdb->postmeta, '_wp_types_group_post_types');
$all_meta = $wpdb->get_results($sql, OBJECT_K);
$re = sprintf('/,%s,/', $data['wpcf-post-type']);
foreach ($all_meta as $meta) {
if (!preg_match($re, $meta->meta_value)) {
continue;
}
$wpdb->update($wpdb->postmeta, array('meta_value' => preg_replace($re, ',' . $post_type . ',', $meta->meta_value)), array('meta_id' => $meta->meta_id), array('%s'), array('%d'));
}
/**
* update _wpcf_belongs_{$data['wpcf-post-type']}_id
*/
$wpdb->update($wpdb->postmeta, array('meta_key' => sprintf('_wpcf_belongs_%s_id', $post_type)), array('meta_key' => sprintf('_wpcf_belongs_%s_id', $data['wpcf-post-type'])), array('%s'), array('%s'));
/**
* update options "wpv_options"
*/
$wpv_options = get_option('wpv_options', true);
if (is_array($wpv_options)) {
$re = sprintf('/(views_template_(archive_)?for_)%s/', $data['wpcf-post-type']);
foreach ($wpv_options as $key => $value) {
if (!preg_match($re, $key)) {
continue;
}
unset($wpv_options[$key]);
$key = preg_replace($re, "\$1" . $post_type, $key);
$wpv_options[$key] = $value;
}
update_option('wpv_options', $wpv_options);
}
/**
* update option "wpcf-custom-taxonomies"
*/
$wpcf_custom_taxonomies = get_option('wpcf-custom-taxonomies', true);
if (is_array($wpcf_custom_taxonomies)) {
$update_wpcf_custom_taxonomies = false;
foreach ($wpcf_custom_taxonomies as $key => $value) {
if (array_key_exists('supports', $value) && array_key_exists($data['wpcf-post-type'], $value['supports'])) {
unset($wpcf_custom_taxonomies[$key]['supports'][$data['wpcf-post-type']]);
$update_wpcf_custom_taxonomies = true;
}
}
if ($update_wpcf_custom_taxonomies) {
update_option('wpcf-custom-taxonomies', $wpcf_custom_taxonomies);
}
}
// Sync action
do_action('wpcf_post_type_renamed', $post_type, $data['wpcf-post-type']);
// Set protected data
$protected_data_check = $custom_types[$data['wpcf-post-type']];
// Delete old type
unset($custom_types[$data['wpcf-post-type']]);
$data['wpcf-post-type'] = $post_type;
} else {
// Set protected data
$protected_data_check = !empty($custom_types[$post_type]) ? $custom_types[$post_type] : array();
}
// Check if active
if (isset($custom_types[$post_type]['disabled'])) {
$data['disabled'] = $custom_types[$post_type]['disabled'];
}
// Sync taxes with custom taxes
if (!empty($data['taxonomies'])) {
$taxes = get_option('wpcf-custom-taxonomies', array());
foreach ($taxes as $id => $tax) {
if (array_key_exists($id, $data['taxonomies'])) {
$taxes[$id]['supports'][$data['slug']] = 1;
} else {
unset($taxes[$id]['supports'][$data['slug']]);
}
}
update_option('wpcf-custom-taxonomies', $taxes);
}
// Preserve protected data
foreach ($protected_data_check as $key => $value) {
if (strpos($key, '_') !== 0) {
unset($protected_data_check[$key]);
}
}
// Merging protected data
$custom_types[$post_type] = array_merge($protected_data_check, $data);
update_option('wpcf-custom-types', $custom_types);
// WPML register strings
wpcf_custom_types_register_translation($post_type, $data);
wpcf_admin_message_store(apply_filters('types_message_custom_post_type_saved', __('Custom post type saved', 'wpcf'), $data, $update), 'custom');
// Flush rewrite rules
flush_rewrite_rules();
do_action('wpcf_custom_types_save', $data);
// Redirect
wp_redirect(add_query_arg(array('page' => 'wpcf-edit-type', 'wpcf-post-type' => $post_type, 'wpcf-rewrite' => 1, 'wpcf-message' => 'view'), admin_url('admin.php')));
die;
}
开发者ID:sandum150,项目名称:cheltuieli,代码行数:101,代码来源:custom-types-form.php
示例4: save
//.........这里部分代码省略.........
unset($custom_types[$data[$this->get_id]]);
$data[$this->get_id] = $post_type;
} else {
// Set protected data
$protected_data_check = !empty($custom_types[$post_type]) ? $custom_types[$post_type] : array();
}
// Check if active
if (isset($custom_types[$post_type]['disabled'])) {
$data['disabled'] = $custom_types[$post_type]['disabled'];
}
}
// Sync taxes with custom taxes
$taxes = get_option(WPCF_OPTION_NAME_CUSTOM_TAXONOMIES, array());
foreach ($taxes as $id => $tax) {
if (isset($data['taxonomies']) && !empty($data['taxonomies']) && array_key_exists($id, $data['taxonomies'])) {
$taxes[$id]['supports'][$data['slug']] = 1;
} else {
if (isset($taxes[$id]['supports'][$data['slug']])) {
unset($taxes[$id]['supports'][$data['slug']]);
}
}
}
update_option(WPCF_OPTION_NAME_CUSTOM_TAXONOMIES, $taxes);
// Preserve protected data
foreach ($protected_data_check as $key => $value) {
if (strpos($key, '_') !== 0) {
unset($protected_data_check[$key]);
}
}
/**
* save custom field group
*/
/* removed types-608
$post_to_groups = isset($_POST['ct']['custom-field-group'])?$_POST['ct']['custom-field-group']:array();
$groups = $this->fields->get_groups_with_post_types();
foreach( $groups as $group) {
$post_types_to_save = $group['_wp_types_group_post_types'];
// save
if ( array_key_exists($group['id'], $post_to_groups)) {
$post_types_to_save[] = $data['slug'];
} else {
if(($key = array_search($data['slug'], $post_types_to_save)) !== false) {
unset($post_types_to_save[$key]);
}
if (
false
|| empty($post_types_to_save)
|| (
true
&& 1 == sizeof($post_types_to_save)
&& 'all' == current($post_types_to_save)
)
) {
$post_types_to_save = array();
foreach( get_post_types() as $key => $value ) {
if ( $data['slug'] == $value) {
continue;
}
if ( in_array($value, $wpcf->excluded_post_types) ) {
continue;
}
$post_types_to_save[] = $value;
}
}
}
wpcf_admin_fields_save_group_post_types($group['id'], $post_types_to_save);
}
*/
/**
* set last edit time
*/
$data[TOOLSET_EDIT_LAST] = time();
/**
* set last edit author
*/
$data[WPCF_AUTHOR] = get_current_user_id();
/**
* add builid in
*/
if ($data['_builtin'] && !isset($protected_data_check[$data['slug']])) {
$protected_data_check[$data['slug']] = array();
}
// Merging protected data
$custom_types[$post_type] = array_merge($protected_data_check, $data);
update_option(WPCF_OPTION_NAME_CUSTOM_TYPES, $custom_types);
// WPML register strings
if (!$data['_builtin']) {
wpcf_custom_types_register_translation($post_type, $data);
}
// success message
$msg = $update ? __('Post Type saved.', 'wpcf') : __('New Post Type created.', 'wpcf');
wpcf_admin_message_store($msg, 'updated notice notice-success is-dismissible');
flush_rewrite_rules();
if (!$data['_builtin']) {
do_action('wpcf_custom_types_save', $data);
}
// Redirect
wp_safe_redirect(esc_url_raw(add_query_arg(array('page' => 'wpcf-edit-type', $this->get_id => $post_type, 'wpcf-message' => 'view', 'flush' => '1'), admin_url('admin.php'))));
die;
}
开发者ID:axeljohansson1988,项目名称:oddcv,代码行数:101,代码来源:class.types.admin.edit.post.type.php
示例5: wpcf_admin_custom_types_form_submit
/**
* Submit function
*/
function wpcf_admin_custom_types_form_submit($form)
{
if (!isset($_POST['ct'])) {
return false;
}
$data = $_POST['ct'];
$update = false;
// Sanitize data
if (isset($data['wpcf-post-type'])) {
$update = true;
$data['wpcf-post-type'] = sanitize_title($data['wpcf-post-type']);
}
if (isset($data['slug'])) {
$data['slug'] = sanitize_title($data['slug']);
}
if (isset($data['rewrite']['slug'])) {
$data['rewrite']['slug'] = remove_accents($data['rewrite']['slug']);
$data['rewrite']['slug'] = strtolower($data['rewrite']['slug']);
$data['rewrite']['slug'] = trim($data['rewrite']['slug']);
}
// Set post type name
$post_type = '';
if (!empty($data['slug'])) {
$post_type = $data['slug'];
} else {
if (!empty($data['wpcf-post-type'])) {
$post_type = $data['wpcf-post-type'];
} else {
if (!empty($data['labels']['singular_name'])) {
$post_type = sanitize_title($data['labels']['singular_name']);
}
}
}
if (empty($post_type)) {
wpcf_admin_message(__('Please set post type name', 'wpcf'), 'error');
// $form->triggerError();
return false;
}
$data['slug'] = $post_type;
$custom_types = get_option('wpcf-custom-types', array());
// Check overwriting
if (!$update && array_key_exists($post_type, $custom_types)) {
wpcf_admin_message(__('Custom post type already exists', 'wpcf'), 'error');
// $form->triggerError();
return false;
}
// Check if renaming then rename all post entries and delete old type
if (!empty($data['wpcf-post-type']) && $data['wpcf-post-type'] != $post_type) {
global $wpdb;
$wpdb->update($wpdb->posts, array('post_type' => $post_type), array('post_type' => $data['wpcf-post-type']), array('%s'), array('%s'));
// Delete old type
unset($custom_types[$data['wpcf-post-type']]);
}
// Check if active
if (isset($custom_types[$post_type]['disabled'])) {
$data['disabled'] = $custom_types[$post_type]['disabled'];
}
// Sync taxes with custom taxes
if (!empty($data['taxonomies'])) {
$taxes = get_option('wpcf-custom-taxonomies', array());
foreach ($taxes as $id => $tax) {
if (array_key_exists($id, $data['taxonomies'])) {
$taxes[$id]['supports'][$data['slug']] = 1;
} else {
unset($taxes[$id]['supports'][$data['slug']]);
}
}
update_option('wpcf-custom-taxonomies', $taxes);
}
$custom_types[$post_type] = $data;
update_option('wpcf-custom-types', $custom_types);
// WPML register strings
wpcf_custom_types_register_translation($post_type, $data);
wpcf_admin_message_store(__('Custom post type saved', 'wpcf'));
// Flush rewrite rules
flush_rewrite_rules();
do_action('wpcf_custom_types_save', $data);
// Redirect
wp_redirect(admin_url('admin.php?page=wpcf-edit-type&wpcf-post-type=' . $post_type . '&wpcf-rewrite=1'));
die;
}
开发者ID:Netsoro,项目名称:gdnlteamgroup,代码行数:84,代码来源:custom-types-form.php
注:本文中的wpcf_custom_types_register_translation函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论