本文整理汇总了PHP中wpcf_admin_get_edited_post_type函数的典型用法代码示例。如果您正苦于以下问题:PHP wpcf_admin_get_edited_post_type函数的具体用法?PHP wpcf_admin_get_edited_post_type怎么用?PHP wpcf_admin_get_edited_post_type使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wpcf_admin_get_edited_post_type函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: __construct
private function __construct()
{
$post = wpcf_admin_get_edited_post();
$post_type = wpcf_admin_get_edited_post_type($post);
// if no post or no page
if ($post_type != 'post' && $post_type != 'page') {
$custom_types = get_option(WPCF_OPTION_NAME_CUSTOM_TYPES, array());
// abort if also no custom post type of types
if (!array_key_exists($post_type, $custom_types)) {
return false;
}
}
$this->prepare();
}
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:14,代码来源:edit_post.php
示例2: wpcf_pr_admin_post_meta_box_output
/**
* Meta boxes contents output.
*
* @param type $post
* @param type $args
*/
function wpcf_pr_admin_post_meta_box_output($post, $args)
{
if (empty($post) || empty($post->ID)) {
return array();
}
global $wpcf;
$output = '';
$relationships = $args;
$post_id = !empty($post->ID) ? $post->ID : -1;
$current_post_type = wpcf_admin_get_edited_post_type($post);
/*
* Render has form (child form)
*/
if (!empty($relationships['has'])) {
foreach ($relationships['has'] as $post_type => $data) {
if (isset($data['fields_setting']) && 'only_list' == $data['fields_setting']) {
$output .= $wpcf->relationship->child_list($post, $post_type, $data);
} else {
$output .= $wpcf->relationship->child_meta_form($post, $post_type, $data);
}
}
}
/*
* Render belongs form (parent form)
*/
if (!empty($relationships['belongs'])) {
$meta = get_post_custom($post_id);
$belongs = array('belongs' => array(), 'posts' => array());
foreach ($meta as $meta_key => $meta_value) {
if (strpos($meta_key, '_wpcf_belongs_') === 0) {
$temp_post = get_post($meta_value[0]);
if (!empty($temp_post)) {
$belongs['posts'][$temp_post->ID] = $temp_post;
$belongs['belongs'][$temp_post->post_type] = $temp_post->ID;
}
}
}
foreach ($relationships['belongs'] as $post_type => $data) {
$parent_post_type_object = get_post_type_object($post_type);
$output .= '<div class="belongs">';
$form = wpcf_pr_admin_post_meta_box_belongs_form($post, $post_type, $belongs);
if (isset($form[$post_type])) {
$form[$post_type]['#before'] = sprintf('<p>%s %s</p>', sprintf(__('This <em>%s</em> belongs to <em>%s</em>', 'wpcf'), get_post_type_object($current_post_type)->labels->singular_name, $parent_post_type_object->labels->singular_name), sprintf(' <a href="%s" class="button disabled">%s</a>', get_edit_post_link($form[$post_type]['#value']), $parent_post_type_object->labels->edit_item));
}
if ($x = wpcf_form_simple($form)) {
$output .= $x;
} else {
$output .= $parent_post_type_object->labels->not_found;
}
$output .= '</div>';
unset($parent_post_type_object);
}
}
return $output;
}
开发者ID:VanessaGarcia-Freelance,项目名称:CrowdsLine,代码行数:61,代码来源:post-relationship.php
示例3: wpcf_admin_post_init
/**
* Init functions for post edit pages.
*
* Core function. Works and stable. Do not move or change.
* If required, add hooks only.
*
* @param type $post
*/
function wpcf_admin_post_init($post)
{
add_action('admin_footer', 'wpcf_admin_fields_postfields_styles');
wpcf_admin_add_js_settings('wpcf_nonce_toggle_group', '\'' . wp_create_nonce('group_form_collapsed') . '\'');
wpcf_admin_add_js_settings('wpcf_nonce_toggle_fieldset', '\'' . wp_create_nonce('form_fieldset_toggle') . '\'');
// Get post_type
$post_type = wpcf_admin_get_edited_post_type($post);
/*
*
* This is left to maintain compatibility with older versions
* TODO Remove
*/
// Add items to View dropdown
if (in_array($post_type, array('view', 'view-template', 'cred-form'))) {
add_filter('editor_addon_menus_wpv-views', 'wpcf_admin_post_editor_addon_menus_filter');
add_action('admin_footer', 'wpcf_admin_post_js_validation');
wpcf_enqueue_scripts();
wp_enqueue_script('toolset-colorbox');
wp_enqueue_style('toolset-colorbox');
}
// Never show on 'Views' and 'View Templates'
if (in_array($post_type, array('view', 'view-template'))) {
return false;
}
// Add marketing box
if (!in_array($post_type, array('post', 'page', 'cred-form')) && !defined('WPCF_RUNNING_EMBEDDED')) {
$hide_help_box = true;
$help_box = wpcf_get_settings('help_box');
$custom_types = get_option(WPCF_OPTION_NAME_CUSTOM_TYPES, array());
if ($help_box != 'no') {
if ($help_box == 'by_types' && array_key_exists($post_type, $custom_types)) {
$hide_help_box = false;
}
if (function_exists('wprc_is_logged_to_repo') && wprc_is_logged_to_repo(WPCF_REPOSITORY)) {
$hide_help_box = true;
}
if ($help_box == 'all') {
$hide_help_box = false;
}
if (!$hide_help_box && !defined('WPV_VERSION')) {
add_meta_box('wpcf-marketing', __('Display Custom Content', 'wpcf'), 'wpcf_admin_post_marketing_meta_box', $post_type, 'side', 'high');
}
}
}
// Are Types active?
$wpcf_active = false;
// Get groups
$groups = wpcf_admin_post_get_post_groups_fields($post);
foreach ($groups as $group) {
$only_preview = '';
//If Access plugin activated
if (function_exists('wpcf_access_register_caps')) {
//If user can't view own profile fields
if (!current_user_can('view_fields_in_edit_page_' . $group['slug'])) {
continue;
}
//If user can modify current group in own profile
if (!current_user_can('modify_fields_in_edit_page_' . $group['slug'])) {
$only_preview = 1;
}
}
if (!empty($group['fields']) && empty($only_preview)) {
$wpcf_active = true;
break;
}
}
// Activate scripts
if ($wpcf_active) {
add_action('admin_head', 'wpcf_post_preview_warning');
wpcf_edit_post_screen_scripts();
}
// Add validation
add_action('admin_footer', 'wpcf_admin_post_js_validation');
/*
* TODO Review
* This is forced because of various Child cases
* and when field are rendered via AJAX but not registered yet.
*
* Basically all fields that require additional JS should be added here.
*
* This is a must for now.
* These fields need init JS in various cases.
*/
wpcf_field_enqueue_scripts('date');
wpcf_field_enqueue_scripts('image');
wpcf_field_enqueue_scripts('file');
wpcf_field_enqueue_scripts('skype');
wpcf_field_enqueue_scripts('numeric');
do_action('wpcf_admin_post_init', $post_type, $post, $groups, $wpcf_active);
}
开发者ID:SpencerNeitzke,项目名称:types,代码行数:98,代码来源:fields-post.php
示例4: wpcf_pr_admin_post_meta_box_output
/**
* Meta boxes contents output.
*
* @param type $post
* @param type $args
*/
function wpcf_pr_admin_post_meta_box_output($post, $args)
{
if (empty($post) || empty($post->ID)) {
return array();
}
global $wpcf;
$output = '';
$relationships = $args;
$post_id = !empty($post->ID) ? $post->ID : -1;
$current_post_type = wpcf_admin_get_edited_post_type($post);
/*
* Render has form (child form)
*/
if (!empty($relationships['has'])) {
foreach ($relationships['has'] as $post_type => $data) {
if (isset($data['fields_setting']) && 'only_list' == $data['fields_setting']) {
$output .= $wpcf->relationship->child_list($post, $post_type, $data);
} else {
$output .= $wpcf->relationship->child_meta_form($post, $post_type, $data);
}
}
}
/*
* Render belongs form (parent form)
*/
if (!empty($relationships['belongs'])) {
$meta = get_post_custom($post_id);
$belongs = array('belongs' => array(), 'posts' => array());
foreach ($meta as $meta_key => $meta_value) {
if (strpos($meta_key, '_wpcf_belongs_') === 0) {
$temp_post = get_post($meta_value[0]);
if (!empty($temp_post)) {
$belongs['posts'][$temp_post->ID] = $temp_post;
$belongs['belongs'][$temp_post->post_type] = $temp_post->ID;
}
}
}
foreach ($relationships['belongs'] as $post_type => $data) {
$output .= '<div style="margin: 20px 0 10px 0">';
if ($x = wpcf_form_simple(wpcf_pr_admin_post_meta_box_belongs_form($post, $post_type, $belongs))) {
$output .= sprintf(__('This <i>%s</i> belongs to:', 'wpcf'), get_post_type_object($current_post_type)->labels->singular_name);
$output .= $x;
} else {
$output .= get_post_type_object($post_type)->labels->not_found;
}
$output .= '</div>';
}
}
return $output;
}
开发者ID:SpencerNeitzke,项目名称:types,代码行数:56,代码来源:post-relationship.php
示例5: wpcf_wpml_post_is_original
/**
* Determine if post is in original language.
*
* @global type $sitepress
* @global type $pagenow
* @param type $field
* @param type $post
* @return boolean
*/
function wpcf_wpml_post_is_original($post = null)
{
if (defined('ICL_SITEPRESS_VERSION')) {
global $sitepress, $pagenow;
// WPML There is no lang on new post
if ($pagenow == 'post-new.php') {
$post_type = wpcf_admin_get_edited_post_type();
$current_lang = isset($_GET['lang']) ? sanitize_text_field($_GET['lang']) : $sitepress->get_current_language();
if (in_array($post_type, array_keys($sitepress->get_translatable_documents()))) {
return $sitepress->get_default_language() == $current_lang;
}
} else {
if (empty($post->ID)) {
$post = wpcf_admin_get_edited_post();
}
if (!empty($post->ID)) {
if (in_array($post->post_type, array_keys($sitepress->get_translatable_documents()))) {
$post_lang = $sitepress->get_element_language_details($post->ID, 'post_' . $post->post_type);
// Suggestion from Black Studio
// http://wp-types.com/forums/topic/major-bug-on-types-when-setting-fields-to-be-copied-wo-wpml-translated-posts/#post-146182
if (isset($post_lang->source_language_code)) {
return $post_lang->source_language_code == null;
// return $sitepress->get_default_language() == $post_lang->language_code;
}
}
}
}
}
return true;
}
开发者ID:evdant,项目名称:firstwp,代码行数:39,代码来源:wpml.php
示例6: wpcf_admin_post_init
/**
* Init functions for post edit pages.
*
* Core function. Works and stable. Do not move or change.
* If required, add hooks only.
*
* @param type $post
*/
function wpcf_admin_post_init($post)
{
add_action('admin_footer', 'wpcf_admin_fields_postfields_styles');
wpcf_admin_add_js_settings('wpcf_nonce_toggle_group', '\'' . wp_create_nonce('group_form_collapsed') . '\'');
wpcf_admin_add_js_settings('wpcf_nonce_toggle_fieldset', '\'' . wp_create_nonce('form_fieldset_toggle') . '\'');
// Get post_type
$post_type = wpcf_admin_get_edited_post_type($post);
/*
*
* This is left to maintain compatibility with older versions
* TODO Remove
*/
// Add items to View dropdown
if (in_array($post_type, array('view', 'view-template', 'cred-form', 'cred-user-form'))) {
add_filter('editor_addon_menus_wpv-views', 'wpcf_admin_post_editor_addon_menus_filter');
add_action('admin_footer', 'wpcf_admin_post_js_validation');
wpcf_enqueue_scripts();
wp_enqueue_script('toolset-colorbox');
wp_enqueue_style('toolset-colorbox');
}
// Never show on 'Views' and 'Content Templates'
if (in_array($post_type, array('view', 'view-template'))) {
return false;
}
/**
* remove custom field WordPress metabox
*/
if ('hide' == wpcf_get_settings('hide_standard_custom_fields_metabox')) {
foreach (array('normal', 'advanced', 'side') as $context) {
remove_meta_box('postcustom', $post_type, $context);
}
}
// Add marketing box
if (!wpcf_is_client() && !in_array($post_type, array('post', 'page', 'cred-form', 'cred-user-form')) && !defined('WPCF_RUNNING_EMBEDDED')) {
$settings_help_box = wpcf_get_settings('help_box');
$custom_types = get_option(WPCF_OPTION_NAME_CUSTOM_TYPES, array());
if ($settings_help_box == 'all' || array_key_exists($post_type, $custom_types)) {
$displaying_custom_content = (include WPCF_ABSPATH . '/marketing/displaying-custom-content/title-content.php');
add_meta_box('add_box_howto', $displaying_custom_content['title'], 'wpcf_admin_post_marketing_displaying_custom_content', $post_type, 'side', 'high');
}
}
// Are Types active?
$wpcf_active = false;
// Get groups
$groups = wpcf_admin_post_get_post_groups_fields($post);
foreach ($groups as $group) {
$only_preview = '';
//If Access plugin activated
if (function_exists('wpcf_access_register_caps')) {
//If user can't view own profile fields
if (!current_user_can('view_fields_in_edit_page_' . $group['slug'])) {
continue;
}
//If user can modify current group in own profile
if (!current_user_can('modify_fields_in_edit_page_' . $group['slug'])) {
$only_preview = 1;
}
}
if (!empty($group['fields']) && empty($only_preview)) {
$wpcf_active = true;
break;
}
}
// Activate scripts
if ($wpcf_active) {
add_action('admin_head', 'wpcf_post_preview_warning');
wpcf_edit_post_screen_scripts();
}
// Add validation
add_action('admin_footer', 'wpcf_admin_post_js_validation');
/*
* TODO Review
* This is forced because of various Child cases
* and when field are rendered via AJAX but not registered yet.
*
* Basically all fields that require additional JS should be added here.
*
* This is a must for now.
* These fields need init JS in various cases.
*/
wpcf_field_enqueue_scripts('date');
wpcf_field_enqueue_scripts('image');
wpcf_field_enqueue_scripts('file');
wpcf_field_enqueue_scripts('skype');
wpcf_field_enqueue_scripts('numeric');
do_action('wpcf_admin_post_init', $post_type, $post, $groups, $wpcf_active);
}
开发者ID:torch2424,项目名称:Team-No-Comply-Games-Wordpress,代码行数:95,代码来源:fields-post.php
示例7: wpcf_pr_admin_post_meta_box_output
/**
* Meta boxes contents output.
*
* @param type $post
* @param type $args
*/
function wpcf_pr_admin_post_meta_box_output($post, $args)
{
if (empty($post->ID)) {
return array();
}
global $wpcf;
$output = '';
$relationships = $args;
$post_id = !empty($post->ID) ? $post->ID : -1;
$current_post_type = wpcf_admin_get_edited_post_type($post);
/*
* Render has form (child form)
*/
if (!empty($relationships['has'])) {
foreach ($relationships['has'] as $post_type => $data) {
$output .= $wpcf->relationship->child_meta_form($post, $post_type, $data);
}
}
/*
* Render belongs form (parent form)
*/
if (!empty($relationships['belongs'])) {
$meta = get_post_custom($post_id);
$belongs = array('belongs' => array(), 'posts' => array());
foreach ($meta as $meta_key => $meta_value) {
if (strpos($meta_key, '_wpcf_belongs_') === 0) {
$temp_post = get_post($meta_value[0]);
if (!empty($temp_post)) {
$belongs['posts'][$temp_post->ID] = $temp_post;
$belongs['belongs'][$temp_post->post_type] = $temp_post->ID;
}
}
}
$output_temp = '';
foreach ($relationships['belongs'] as $post_type => $data) {
$output_temp .= wpcf_form_simple(wpcf_pr_admin_post_meta_box_belongs_form($post, $post_type, $belongs));
}
if (!empty($output_temp)) {
$types_existing = get_option('wpcf-custom-types', array());
$output .= '<div style="margin: 20px 0 10px 0">';
$output .= sprintf(__('This <i>%s</i> belongs to:', 'wpcf'), $types_existing[$current_post_type]['labels']['singular_name']);
$output .= '</div>' . $output_temp;
}
}
return $output;
}
开发者ID:MiquelAdell,项目名称:miqueladell,代码行数:52,代码来源:post-relationship.php
注:本文中的wpcf_admin_get_edited_post_type函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论