本文整理汇总了PHP中wpcf_admin_get_edited_post函数的典型用法代码示例。如果您正苦于以下问题:PHP wpcf_admin_get_edited_post函数的具体用法?PHP wpcf_admin_get_edited_post怎么用?PHP wpcf_admin_get_edited_post使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wpcf_admin_get_edited_post函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: valid
public function valid()
{
if (self::$layout_id !== null && self::$layout_id !== false) {
return true;
}
$post = wpcf_admin_get_edited_post();
if (!empty($post)) {
return $this->valid_per_post($post);
}
return $this->valid_per_post_type();
}
开发者ID:axeljohansson1988,项目名称:oddcv,代码行数:11,代码来源:template_exists.php
示例2: __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
示例3: editorDropdownFilter
/**
* Adds items to view dropdown.
*
* @param type $items
* @return type
*/
public static function editorDropdownFilter($items)
{
$post = wpcf_admin_get_edited_post();
if (empty($post)) {
$post = (object) array('ID' => -1);
}
$groups = wpcf_admin_fields_get_groups('wp-types-group', 'group_active');
$all_post_types = implode(' ', get_post_types(array('public' => true)));
$add = array();
if (!empty($groups)) {
// $group_id is blank therefore not equal to $group['id']
// use array for item key and CSS class
$item_styles = array();
foreach ($groups as $group) {
$fields = wpcf_admin_fields_get_fields_by_group($group['id'], 'slug', true, false, true);
if (!empty($fields)) {
// code from Types used here without breaking the flow
// get post types list for every group or apply all
$post_types = get_post_meta($group['id'], '_wp_types_group_post_types', true);
if ($post_types == 'all') {
$post_types = $all_post_types;
}
$post_types = trim(str_replace(',', ' ', $post_types));
$item_styles[$group['name']] = $post_types;
foreach ($fields as $field) {
$callback = 'wpcfFieldsEditorCallback(\'' . $field['id'] . '\', \'postmeta\', ' . $post->ID . ')';
$add[$group['name']][stripslashes($field['name'])] = array(stripslashes($field['name']), trim(wpcf_fields_get_shortcode($field), '[]'), $group['name'], $callback);
// TODO Remove - it's not post edit screen (meta box JS and CSS)
WPCF_Fields::enqueueScript($field['type']);
WPCF_Fields::enqueueStyle($field['type']);
}
}
}
}
$search_key = '';
// Iterate all items to be displayed in the "V" menu
foreach ($items as $key => $item) {
if ($key == __('Basic', 'wpv-views')) {
$search_key = 'found';
continue;
}
if ($search_key == 'found') {
$search_key = $key;
}
if ($key == __('Field', 'wpv-views') && isset($item[trim(wpcf_types_get_meta_prefix(), '-')])) {
unset($items[$key][trim(wpcf_types_get_meta_prefix(), '-')]);
}
}
if (empty($search_key) || $search_key == 'found') {
$search_key = count($items);
}
$insert_position = array_search($search_key, array_keys($items));
$part_one = array_slice($items, 0, $insert_position);
$part_two = array_slice($items, $insert_position);
$items = $part_one + $add + $part_two;
// apply CSS styles to each item based on post types
foreach ($items as $key => $value) {
if (isset($item_styles[$key])) {
$items[$key]['css'] = $item_styles[$key];
} else {
$items[$key]['css'] = $all_post_types;
}
}
return $items;
}
开发者ID:CrankMaster336,项目名称:FFW-TR,代码行数:71,代码来源:wpviews.php
示例4: wpcf_get_post_id
/**
* 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;
}
开发者ID:CrankMaster336,项目名称:FFW-TR,代码行数:28,代码来源:functions.php
示例5: wpcf_post_preview_warning
function wpcf_post_preview_warning()
{
$post = wpcf_admin_get_edited_post();
// Add preview warning
if (isset($post->post_status) && !in_array($post->post_status, array('auto-draft', 'draft')) && !in_array($post->post_type, array('cred', 'view', 'view-template'))) {
// require_once WPCF_EMBEDDED_ABSPATH . '/common/wp-pointer.php';
//
// $pointer = new WPV_wp_pointer('types-post-preview-warning');
// $pointer->add_pointer(__('Preview warning'),
// sprintf(__('Custom field changes cannot be previewed until %s is updated'), $post->post_type),
// $jquery_id = '#types-preview-warning',
// $position = 'left',
// $pointer_name = 'types_preview_warning',
// $activate_function = null,
// $activate_selector = false
// );
// $pointer->admin_enqueue_scripts();
wp_enqueue_style('wp-pointer');
wp_enqueue_script('wp-pointer');
?>
<script type="text/javascript">typesPostScreen.previewWarning('<?php
_e('Preview warning', 'wpcf');
?>
', '<?php
printf(__('Custom field changes cannot be previewed until %s is updated', 'wpcf'), $post->post_type);
?>
');</script><?php
}
}
开发者ID:SpencerNeitzke,项目名称:types,代码行数:29,代码来源:fields-post.php
示例6: wpcf_admin_post_add_usermeta_to_editor_js
/**
* Add User Fields to editor
*
* @author Gen [email protected]
* @since Types 1.3
*/
function wpcf_admin_post_add_usermeta_to_editor_js($menu, $views_callback = false)
{
global $wpcf;
$post = wpcf_admin_get_edited_post();
if (empty($post)) {
$post = (object) array('ID' => -1);
}
$groups = wpcf_admin_fields_get_groups('wp-types-user-group');
$user_id = wpcf_usermeta_get_user();
if (!empty($groups)) {
$item_styles = array();
foreach ($groups as $group_id => $group) {
if (empty($group['is_active'])) {
continue;
}
$group_name = sprintf(__('%s (Usermeta fields)', 'wpcf'), $group['name']);
$fields = wpcf_admin_fields_get_fields_by_group($group['id'], 'slug', true, false, true, 'wp-types-user-group', 'wpcf-usermeta');
if (!empty($fields)) {
foreach ($fields as $field_id => $field) {
// Use field class
$wpcf->usermeta_field->set($user_id, $field);
// Get field data
$data = (array) $wpcf->usermeta_field->config;
// Get inherited field
if (isset($data['inherited_field_type'])) {
$inherited_field_data = wpcf_fields_type_action($data['inherited_field_type']);
}
$callback = 'wpcfFieldsEditorCallback(\'' . $field['id'] . '\', \'usermeta\', ' . $post->ID . ')';
// Added for Views:users filter Vicon popup
if ($views_callback) {
$callback = 'wpcfFieldsEditorCallback(\'' . $field['id'] . '\', \'views-usermeta\', ' . $post->ID . ')';
}
$menu[$group_name][stripslashes($field['name'])] = array(stripslashes($field['name']), trim(wpcf_usermeta_get_shortcode($field), '[]'), $group_name, $callback);
}
/*
* Since Types 1.2
* We use field class to enqueue JS and CSS
*/
$wpcf->usermeta_field->enqueue_script();
$wpcf->usermeta_field->enqueue_style();
}
}
}
return $menu;
}
开发者ID:KryvunRoman,项目名称:yobko,代码行数:51,代码来源:usermeta-init.php
示例7: wpcf_admin_fields_postfields_styles
/**
* Add styles to admin fields groups
*/
function wpcf_admin_fields_postfields_styles()
{
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields-post.php';
// $groups = wpcf_admin_fields_get_groups();
$groups = wpcf_admin_post_get_post_groups_fields(wpcf_admin_get_edited_post());
if (!empty($groups)) {
echo '<style type="text/css">';
foreach ($groups as $group) {
echo str_replace("}", "}\n", wpcf_admin_get_groups_admin_styles_by_group($group['id']));
}
echo '</style>';
}
}
开发者ID:lytranuit,项目名称:wordpress,代码行数:17,代码来源:admin.php
示例8: wpcf_wpml_have_original
function wpcf_wpml_have_original($post = null)
{
static $cache = array();
global $pagenow;
$res = false;
// WPML There is no lang on new post
if ($pagenow == 'post-new.php') {
return isset($_GET['trid']);
}
if (empty($post->ID)) {
$post = wpcf_admin_get_edited_post();
}
if (!empty($post->ID)) {
$cache_key = $post->ID;
if (isset($cache[$cache_key])) {
return $cache[$cache_key];
}
global $wpdb, $sitepress;
$post_lang = $sitepress->get_element_language_details($post->ID, 'post_' . $post->post_type);
if (isset($post_lang->language_code)) {
$sql = $wpdb->prepare("SELECT trid FROM {$wpdb->prefix}icl_translations\n WHERE language_code = %s\n AND element_id = %d\n AND element_type = %s\n AND source_language_code IS NOT NULL", $post_lang->language_code, $post->ID, sprintf('post_%s', $post->post_type));
$res = (bool) $wpdb->get_var($sql);
}
$cache[$cache_key] = $res;
}
return $res;
}
开发者ID:evdant,项目名称:firstwp,代码行数:27,代码来源:wpml.php
示例9: editorDropdownFilter
/**
* Adds items to view dropdown.
*
* @param type $items
* @return type
*/
public static function editorDropdownFilter($menu)
{
$post = wpcf_admin_get_edited_post();
if (empty($post)) {
$post = (object) array('ID' => -1);
}
$groups = wpcf_admin_fields_get_groups('wp-types-group', 'group_active');
$all_post_types = implode(' ', get_post_types(array('public' => true)));
$add = array();
if (!empty($groups)) {
// $group_id is blank therefore not equal to $group['id']
// use array for item key and CSS class
$item_styles = array();
foreach ($groups as $group) {
$fields = wpcf_admin_fields_get_fields_by_group($group['id'], 'slug', true, false, true);
if (!empty($fields)) {
// code from Types used here without breaking the flow
// get post types list for every group or apply all
$post_types = get_post_meta($group['id'], '_wp_types_group_post_types', true);
if ($post_types == 'all') {
$post_types = $all_post_types;
}
$post_types = trim(str_replace(',', ' ', $post_types));
$item_styles[$group['name']] = $post_types;
foreach ($fields as $field) {
$callback = 'wpcfFieldsEditorCallback(\'' . $field['id'] . '\', \'postmeta\', ' . $post->ID . ')';
$menu[$group['name']][stripslashes($field['name'])] = array(stripslashes($field['name']), trim(wpcf_fields_get_shortcode($field), '[]'), $group['name'], $callback);
// TODO Remove - it's not post edit screen (meta box JS and CSS)
WPCF_Fields::enqueueScript($field['type']);
WPCF_Fields::enqueueStyle($field['type']);
}
}
}
}
return $menu;
}
开发者ID:SpencerNeitzke,项目名称:types,代码行数:42,代码来源:wpviews.php
示例10: wpcf_post_preview_warning
function wpcf_post_preview_warning()
{
$post = wpcf_admin_get_edited_post();
// Add preview warning
if (isset($post->post_status) && !in_array($post->post_status, array('auto-draft', 'draft')) && !in_array($post->post_type, array('cred', 'view', 'view-template'))) {
wp_enqueue_style('wp-pointer');
wp_enqueue_script('wp-pointer');
?>
<script type="text/javascript">
if ( "undefined" != typeof typesPostScreen ) {
typesPostScreen.previewWarning(
'<?php
esc_attr_e(__('Preview warning', 'wpcf'));
?>
',
'<?php
esc_attr_e(sprintf(__('Custom field changes cannot be previewed until %s is updated', 'wpcf'), $post->post_type));
?>
');
}
</script><?php
}
}
开发者ID:torch2424,项目名称:Team-No-Comply-Games-Wordpress,代码行数:23,代码来源:fields-post.php
示例11: wpcf_admin_get_current_edited_post
function wpcf_admin_get_current_edited_post($current_post = null)
{
$current_post = wpcf_admin_get_edited_post();
if (empty($current_post)) {
return null;
}
return $current_post;
}
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:8,代码来源:admin.php
示例12: wpcf_get_post_id
/**
* Get main post ID.
*
* @param type $context
* @return type
*/
function wpcf_get_post_id($context = 'group')
{
if (!is_admin()) {
$post = get_post();
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;
}
开发者ID:pwillems,项目名称:mimosa-contents,代码行数:18,代码来源:functions.php
注:本文中的wpcf_admin_get_edited_post函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论