本文整理匯總了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();
}