本文整理汇总了PHP中WPCF_Loader::loadInclude方法的典型用法代码示例。如果您正苦于以下问题:PHP WPCF_Loader::loadInclude方法的具体用法?PHP WPCF_Loader::loadInclude怎么用?PHP WPCF_Loader::loadInclude使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WPCF_Loader
的用法示例。
在下文中一共展示了WPCF_Loader::loadInclude方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: set
/**
* Set current post and field.
*
* @param type $post
* @param type $cf
*/
function set($user_id, $cf)
{
global $wpcf;
/*
*
* Check if $cf is string
*/
if (is_string($cf)) {
WPCF_Loader::loadInclude('fields');
$cf = wpcf_admin_fields_get_field($this->__get_slug_no_prefix($cf));
if (empty($cf)) {
$this->_reset();
return false;
}
}
$this->currentUID = $user_id;
$this->ID = $cf['id'];
$this->cf = $cf;
$this->slug = wpcf_types_get_meta_prefix($this->cf) . $this->cf['slug'];
$this->meta = $this->_get_meta();
$this->config = $this->_get_config();
$this->unique_id = wpcf_unique_id(serialize((array) $this));
$this->cf['value'] = $this->meta;
// Debug
$wpcf->debug->fieds[$this->unique_id] = $this->cf;
$wpcf->debug->meta[$this->slug][] = $this->meta;
// Load files
if (isset($this->cf['type'])) {
$file = WPCF_EMBEDDED_INC_ABSPATH . '/fields/' . $this->cf['type'] . '.php';
if (file_exists($file)) {
include_once $file;
}
if (defined('WPCF_INC_ABSPATH')) {
$file = WPCF_INC_ABSPATH . '/fields/' . $this->cf['type'] . '.php';
if (file_exists($file)) {
include_once $file;
}
}
}
}
示例2: types_child_posts
/**
* Gets posts that belongs to current post.
*
* @global type $post
* @param type $post_type
* @param type $args
* @return type
*/
function types_child_posts($post_type, $args = array())
{
static $cache = array();
if (isset($args['post_id'])) {
$post = $args['post_id'] != '0' ? get_post($args['post_id']) : null;
} else {
global $post;
}
if (empty($post->ID)) {
return array();
}
$cache_key = md5($post->ID . serialize(func_get_args()));
if (isset($cache[$cache_key])) {
return $cache[$cache_key];
}
global $wp_post_types;
// WP allows querying inactive post types
if (!isset($wp_post_types[$post_type]) || !$wp_post_types[$post_type]->publicly_queryable) {
return array();
}
$defaults = array('post_status' => array('publish'));
$args = wp_parse_args($args, $defaults);
WPCF_Loader::loadModel('relationship');
WPCF_Loader::loadInclude('fields-post');
$child_posts = WPCF_Relationship_Model::getChildrenByPostType($post, $post_type, array(), array(), $args);
foreach ($child_posts as $child_post_key => $child_post) {
$child_posts[$child_post_key]->fields = array();
$groups = wpcf_admin_post_get_post_groups_fields($child_post);
foreach ($groups as $group) {
if (!empty($group['fields'])) {
// Process fields
foreach ($group['fields'] as $k => $field) {
$data = null;
if (types_is_repetitive($field)) {
$data = wpcf_get_post_meta($child_post->ID, wpcf_types_get_meta_prefix($field) . $field['slug'], false);
// get all field instances
} else {
$data = wpcf_get_post_meta($child_post->ID, wpcf_types_get_meta_prefix($field) . $field['slug'], true);
// get single field instance
// handle checkboxes which are one value serialized
if ($field['type'] == 'checkboxes' && !empty($data)) {
$data = maybe_unserialize($data);
}
}
if (!is_null($data)) {
$child_posts[$child_post_key]->fields[$k] = $data;
}
}
}
}
}
$cache[$cache_key] = $child_posts;
return $child_posts;
}
示例3: set
/**
* Set current post and field.
*
* @param type $post
* @param type $cf
*/
function set($post, $cf)
{
global $wpcf;
/*
*
* Check if $cf is string
*/
if (is_string($cf)) {
WPCF_Loader::loadInclude('fields');
$_cf = wpcf_admin_fields_get_field($this->__get_slug_no_prefix($cf));
// Check if found without prefix
if (empty($_cf)) {
$_cf = wpcf_admin_fields_get_field($cf);
}
if (empty($_cf)) {
/*
* TODO Check what happens if field is not found
*/
$this->_reset();
return false;
}
$cf = $_cf;
}
$this->post = is_integer($post) ? get_post($post) : $post;
// If empty post it is new
if (empty($this->post->ID)) {
$this->post = new stdClass();
$this->post->ID = 0;
}
$this->ID = $cf['id'];
$this->cf = $cf;
$this->slug = wpcf_types_get_meta_prefix($this->cf) . $this->cf['slug'];
$this->meta = $this->_get_meta();
$this->config = $this->_get_config();
$this->unique_id = wpcf_unique_id(serialize((array) $this));
$this->cf['value'] = $this->meta;
// Debug
$wpcf->debug->fields[$this->unique_id] = $this->cf;
$wpcf->debug->meta[$this->slug][] = $this->meta;
// Load files
$this->_include_file_by_field_type($this->cf['type']);
if (defined('WPCF_INC_ABSPATH')) {
$file = WPCF_INC_ABSPATH . '/fields/' . preg_replace('/[^\\w]+/', '', $this->cf['type']) . '.php';
if (file_exists($file)) {
include_once $file;
}
}
}
示例4: wpcf_cd_admin_form_single_filter
/**
* Single condition form elements.
*
* @param type $data
* @param type $condition
* @param type $key
* @return string
*/
function wpcf_cd_admin_form_single_filter($data, $condition, $key = null, $group = false, $force_multi = false)
{
global $wpcf;
if ($group) {
$name = 'wpcf[group][conditional_display]';
} else {
$name = 'wpcf[fields][' . $data['id'] . '][conditional_display]';
}
$group_id = isset($_GET['group_id']) ? intval($_GET['group_id']) : false;
/*
*
*
* TODO Review this allowing fields from same group as conditional (self loop)
* I do not remember allowing fields from same group as conditional (self loop)
* on Group Fields edit screen.
*/
// if ( $group_id && !$group ) {// Allow group to use other fields
// $fields = wpcf_admin_fields_get_fields_by_group( $group_id );
// } else {
$fields = wpcf_admin_fields_get_fields(true, false, true);
ksort($fields, SORT_STRING);
// }
if ($group) {
$_distinct = wpcf_admin_fields_get_fields_by_group($group_id);
foreach ($_distinct as $_field_id => $_field) {
if (isset($fields[$_field_id])) {
unset($fields[$_field_id]);
}
}
}
$options = array();
$ignore_field_type_array = array('audio', 'checkboxes', 'embed', 'file', 'image', 'video', 'wysiwyg');
$flag_repetitive = false;
foreach ($fields as $field_id => $field) {
if (!$group && $data['id'] == $field_id) {
continue;
}
// WE DO NOT ALLOW repetitive fields to be compared.
if (wpcf_admin_is_repetitive($field)) {
$flag_repetitive = true;
continue;
}
/**
* Skip some files
*/
if (in_array($field['type'], $ignore_field_type_array)) {
continue;
}
/**
* build options
*/
$options[$field_id] = array('#value' => $field_id, '#title' => stripslashes($field['name']), '#attributes' => array('class' => 'wpcf-conditional-select-' . $field['type']));
}
/*
* Special case
* https://icanlocalize.basecamphq.com/projects/7393061-wp-views/todo_items/153565054/comments
*
* When field is new and only one diff field in list - that
* means one field is saved but other not yet.
*/
$is_new = isset($data['id']) && isset($fields[$data['id']]) ? false : true;
$special_stop = false;
if ($is_new) {
if (count($options) == 1) {
$special_stop = true;
}
}
/*
*
* This means all fields are repetitive and no one left to compare with.
* WE DO NOT ALLOW repetitive fields to be compared.
*/
if (!$group && empty($options) && $flag_repetitive) {
return array('cd' => array('#type' => 'markup', '#markup' => '<p class="wpcf-error">' . __('Conditional display is only working based on non-repeating fields. All fields in this group are repeating, so you cannot set their display based on other fields.', 'wpcf') . '</p>' . wpcf_conditional_disable_add_js($data['id'])));
} else {
if (!$group && (empty($options) || $special_stop)) {
return array('cd' => array('#type' => 'markup', '#markup' => '<p>' . __('You will be able to set conditional field display when you save more fields.', 'wpcf') . '</p>'));
}
}
$id = !is_null($key) ? $key : strval('condition_' . wpcf_unique_id(serialize($data) . serialize($condition) . $key . $group));
$form = array();
$before = '<div class="wpcf-cd-entry"><br />';
$form['cd']['field_' . $id] = array('#type' => 'select', '#name' => $name . '[conditions][' . $id . '][field]', '#options' => $options, '#inline' => true, '#before' => $before, '#default_value' => isset($condition['field']) ? $condition['field'] : null, '#attributes' => array('class' => 'wpcf-cd-field'));
$form['cd']['operation_' . $id] = array('#type' => 'select', '#name' => $name . '[conditions][' . $id . '][operation]', '#options' => array_flip(wpcf_cd_admin_operations()), '#inline' => true, '#default_value' => isset($condition['operation']) ? $condition['operation'] : null, '#attributes' => array('class' => 'wpcf-cd-operation'));
$form['cd']['value_' . $id] = array('#type' => 'textfield', '#name' => $name . '[conditions][' . $id . '][value]', '#inline' => true, '#value' => isset($condition['value']) ? $condition['value'] : '', '#attributes' => array('class' => 'wpcf-cd-value'));
/*
*
* Adjust for date
*/
if (!empty($condition['value'])) {
WPCF_Loader::loadInclude('fields/date/functions.php');
$timestamp = wpcf_fields_date_convert_datepicker_to_timestamp($condition['value']);
//.........这里部分代码省略.........
示例5: _e
_e('Crop images, so that they fill the specified dimensions exactly.', 'wpcf');
?>
</label>
</p>
</div>
</div>
<p class="form-inline">
<input id="image-url" type="checkbox" name="url" value="1" data-bind="checked: imageUrl, click: imageUrlDisable" />
<label for="image-url"><?php
_e('Output only the URL of the re-sized image instead of the img tag', 'wpcf');
?>
</label>
</p>
<!--<input id="image-onload" type="text" name="onload" value="<?php
echo $data['onload'];
?>
" />
<label for="image-onload"><?php
_e('Onload callback', 'wpcf');
?>
</label>-->
</script><!--END TYPES MODAL IMAGE-->
<?php
WPCF_Loader::loadInclude('fields/colorpicker');
wpcf_fields_colorpicker_enqueue_scripts();
wpcf_fields_colorpicker_render_js();
示例6: evaluate
//.........这里部分代码省略.........
remove_filter('get_post_metadata', array('WPCF_Evaluate', 'relationship_custom_statement_meta_ajax_validation_filter'), 10, 4);
} else {
remove_filter('get_post_metadata', array('WPCF_Evaluate', 'meta_ajax_validation_filter'), 10, 4);
}
} else {
/*
*
*
*
*
*
*
*
*
* TYPES
*
* If not custom code, use Types built-in check.
* wpcf_cd_admin_compare()
*/
$passed_all = true;
$passed_one = false;
// Basic check
if (empty($field['data']['conditional_display']['conditions'])) {
return false;
}
// Keep count to see if OR/AND relation needed
$count = count($field['data']['conditional_display']['conditions']);
foreach ($field['data']['conditional_display']['conditions'] as $condition) {
/*
*
*
* Malformed condition and should be treated as forbidden
*/
if (!isset($condition['field']) || !isset($condition['operation']) || !isset($condition['value'])) {
$passed_one = false;
continue;
}
/*
*
*
* This field value is checked
*/
$f = wpcf_admin_fields_get_field(trim(strval($condition['field'])));
if (empty($f)) {
return false;
}
$c = new WPCF_Field();
$c->set($post, $f);
/*
*
* Since Types 1.2
* meta is property of WPCF_Field::$__meta
*
* BREAKPOINT
* This is where values for evaluation are set.
* Please do not allow other places - use hooks.
*
* TODO Monitor this
* 1.3 Change use of $c->_get_meta( 'POST' )
* to $c->get_submitted_data()
*/
// $value = defined( 'DOING_AJAX' ) ? $c->_get_meta( 'POST' ) : $c->__meta;
$value = defined('DOING_AJAX') ? $c->get_submitted_data() : $c->__meta;
/*
*
* Apply filters
*/
$value = apply_filters('wpcf_conditional_display_compare_meta_value', $value, $c->cf['id'], $condition['operation'], $c->slug, $post);
$condition['value'] = apply_filters('wpcf_conditional_display_compare_condition_value', $condition['value'], $c->cf['id'], $condition['operation'], $c->slug, $post);
/*
*
*
* Call built-in Types compare func
*/
WPCF_Loader::loadInclude('conditional-display');
$passed = wpcf_cd_admin_compare($condition['operation'], $value, $condition['value']);
if (!$passed) {
$passed_all = false;
} else {
$passed_one = true;
}
}
/*
*
*
* Check OR/AND relation
*/
if ($count > 1) {
if ($field['data']['conditional_display']['relation'] == 'AND') {
$passed = $passed_all;
} else {
if ($field['data']['conditional_display']['relation'] == 'OR') {
$passed = $passed_one;
}
}
}
}
}
return (bool) $passed;
}
示例7: conditionalVerify
/**
* Process AJAX conditional verify.
*
* @global type $wpcf
* @param type $data
* @return boolean|string
*/
public static function conditionalVerify($data)
{
WPCF_Loader::loadInclude('fields');
WPCF_Loader::loadInclude('fields-post');
WPCF_Loader::loadInclude('conditional-display');
global $wpcf;
$js_execute = '';
$_flag_relationship = false;
/*
*
* Determine post.
*/
if (empty($data['wpcf']) && !empty($data['wpcf_post_relationship'])) {
/*
* Relationship case
*/
$_temp = $data['wpcf_post_relationship'];
$parent_id = key($_temp);
$_data = array_shift($_temp);
$post_id = key($_data);
$post = get_post($post_id);
$posted_fields = $_data[$post_id];
$_flag_relationship = true;
/*
*
* Regular submission
*/
} else {
if (isset($data['wpcf_main_post_id'])) {
$post_id = intval($data['wpcf_main_post_id']);
$post = get_post($post_id);
}
}
// No post
if (empty($post->ID)) {
return false;
}
// Get Groups (Fields) for current post
$groups = wpcf_admin_post_get_post_groups_fields($post);
$_processed = array();
foreach ($groups as $group) {
if (!empty($group['fields'])) {
foreach ($group['fields'] as $field_id => $field) {
// Check if already processed
if (isset($_processed[$field_id])) {
continue;
}
if ($wpcf->conditional->is_conditional($field_id)) {
if ($_flag_relationship) {
// Process only submitted fields
if (!isset($posted_fields[WPCF_META_PREFIX . $field_id])) {
continue;
}
$wpcf->conditional->set($post, $field_id);
$wpcf->conditional->context = 'relationship';
$_relationship_name = false;
// Set name and other values processed by hooks
$parent = get_post($parent_id);
if (!empty($parent->ID)) {
$wpcf->relationship->set($parent, $post);
$wpcf->relationship->cf->set($post, $field_id);
$_child = $wpcf->relationship->get_child();
$_child->form->cf->set($post, $field_id);
$_relationship_name = $_child->form->alter_form_name('wpcf[' . $wpcf->conditional->cf['id'] . ']');
}
if (!$_relationship_name) {
continue;
}
/*
* BREAKPOINT
* Adds filtering regular evaluation (not wpv_conditional)
*/
add_filter('types_field_get_submitted_data', 'wpcf_relationship_ajax_data_filter', 10, 2);
$name = $_relationship_name;
} else {
$wpcf->conditional->set($post, $field_id);
$name = 'wpcf[' . $wpcf->conditional->cf['id'] . ']';
}
// Evaluate
$passed = $wpcf->conditional->evaluate();
if ($passed) {
$js_execute .= 'jQuery(\'[name^="' . $name . '"]\').parents(\'.' . 'wpcf-conditional' . '\').show().removeClass(\'' . 'wpcf-conditional' . '-failed\').addClass(\'' . 'wpcf-conditional' . '-passed\');' . " ";
$js_execute .= 'jQuery(\'[name^="' . $name . '"]\').parents(\'.wpcf-repetitive-wrapper\').show();';
} else {
$js_execute .= 'jQuery(\'[name^="' . $name . '"]\').parents(\'.wpcf-repetitive-wrapper\').hide();';
$js_execute .= 'jQuery(\'[name^="' . $name . '"]\').parents(\'.' . 'wpcf-conditional' . '\').hide().addClass(\'' . 'wpcf-conditional' . '-failed\').removeClass(\'' . 'wpcf-conditional' . '-passed\');' . " ";
}
}
$_processed[$field_id] = true;
}
}
}
return $js_execute;
//.........这里部分代码省略.........