本文整理汇总了PHP中WPCF_Loader::loadModel方法的典型用法代码示例。如果您正苦于以下问题:PHP WPCF_Loader::loadModel方法的具体用法?PHP WPCF_Loader::loadModel怎么用?PHP WPCF_Loader::loadModel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WPCF_Loader
的用法示例。
在下文中一共展示了WPCF_Loader::loadModel方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Construct function.
*/
function __construct($parent_post, $child_post_type, $data)
{
WPCF_Loader::loadModel('relationship');
$this->parent = $parent_post;
$this->parent_post_type = $parent_post->post_type;
$this->child_post_type = $child_post_type;
$this->data = $data;
// Clean data
if (empty($this->data['fields_setting'])) {
$this->data['fields_setting'] = 'all_cf';
}
$this->cf = new WPCF_Field();
$this->cf->context = 'relationship';
$this->children = WPCF_Relationship_Model::getChildrenByPostType($this->parent, $this->child_post_type, $this->data, $_GET);
// If no children - use dummy post
if (empty($this->children)) {
$_dummy_post = get_default_post_to_edit($this->child_post_type, false);
$this->children = array($_dummy_post);
$this->_dummy_post = true;
}
$this->child_post_type_object = get_post_type_object($this->child_post_type);
// Collect params from request
foreach ($this->__params as $__param) {
if (isset($_GET[$__param])) {
$this->__urlParams[$__param] = $_GET[$__param];
}
}
$post_types = get_option('wpcf-custom-types', array());
if (array_key_exists($child_post_type, $post_types) && array_key_exists('supports', $post_types[$child_post_type])) {
foreach ($post_types[$child_post_type]['supports'] as $key => $value) {
$this->child_supports[$key] = (bool) $value;
}
}
unset($post_types);
}
示例2: __construct
/**
* Construct function.
*/
function __construct($parent_post, $child_post_type, $data)
{
WPCF_Loader::loadModel('relationship');
$this->parent = $parent_post;
$this->parent_post_type = $parent_post->post_type;
$this->child_post_type = $child_post_type;
$this->data = $data;
// Clean data
if (empty($this->data['fields_setting'])) {
$this->data['fields_setting'] = 'all_cf';
}
$this->cf = new WPCF_Field();
$this->cf->context = 'relationship';
$this->children = WPCF_Relationship_Model::getChildrenByPostType($this->parent, $this->child_post_type, $this->data, $_GET);
// If no children - use dummy post
if (empty($this->children)) {
$_dummy_post = get_default_post_to_edit($this->child_post_type, false);
$this->children = array($_dummy_post);
$this->_dummy_post = true;
}
$this->child_post_type_object = get_post_type_object($this->child_post_type);
// Collect params from request
foreach ($this->__params as $__param) {
if (isset($_GET[$__param])) {
$this->__urlParams[$__param] = $_GET[$__param];
}
}
}
示例3: __construct
/**
* Construct function.
*/
function __construct($parent_post, $child_post_type, $data)
{
WPCF_Loader::loadModel('relationship');
$this->parent = $parent_post;
$this->parent_post_type = $parent_post->post_type;
$this->child_post_type = $child_post_type;
$this->data = $data;
// Clean data
if (empty($this->data['fields_setting'])) {
$this->data['fields_setting'] = 'all_cf';
}
$this->cf = new WPCF_Field();
$this->cf->context = 'relationship';
$this->children = WPCF_Relationship_Model::getChildrenByPostType($this->parent, $this->child_post_type, $this->data, $_GET);
// If no children - use dummy post
if (empty($this->children)) {
$_dummy_post = get_default_post_to_edit($this->child_post_type, false);
$this->children = array($_dummy_post);
$this->_dummy_post = true;
}
$this->child_post_type_object = get_post_type_object($this->child_post_type);
if (!isset($this->child_post_type_object->slug) && isset($this->child_post_type_object->name)) {
$this->child_post_type_object->slug = $this->child_post_type_object->name;
}
// Collect params from request
foreach ($this->__params as $__param) {
if (isset($_GET[$__param])) {
$this->__urlParams[$__param] = $_GET[$__param];
}
}
/**
* build-in types
*/
if (in_array($child_post_type, array('page', 'post', 'attachment', 'revision', 'nav_menu_item'))) {
foreach (array_keys($this->child_supports) as $key) {
$this->child_supports[$key] = post_type_supports($child_post_type, $key);
}
return;
}
/**
* post types
*/
$post_types = get_option(WPCF_OPTION_NAME_CUSTOM_TYPES, array());
if (array_key_exists($child_post_type, $post_types) && array_key_exists('supports', $post_types[$child_post_type])) {
foreach ($post_types[$child_post_type]['supports'] as $key => $value) {
$this->child_supports[$key] = (bool) $value;
}
}
unset($post_types);
/**
* wp_enqueue_media allways
*/
add_action('admin_enqueue_scripts', array($this, 'wp_enqueue_media'), PHP_INT_MAX);
}
示例4: 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;
}
示例5: __construct
/**
* Construct.
*
* @return type
*/
private function __construct()
{
WPCF_Loader::loadClass('path');
WPCF_Loader::loadModel('image');
self::$__cache = new Types_Cache();
self::$errors = new Types_Error();
}