本文整理汇总了PHP中WPCF_Loader::loadClass方法的典型用法代码示例。如果您正苦于以下问题:PHP WPCF_Loader::loadClass方法的具体用法?PHP WPCF_Loader::loadClass怎么用?PHP WPCF_Loader::loadClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WPCF_Loader
的用法示例。
在下文中一共展示了WPCF_Loader::loadClass方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wpcf_ajax_embedded
/**
* All AJAX calls go here.
*
* @todo auth
*/
function wpcf_ajax_embedded()
{
if (isset($_REQUEST['_typesnonce'])) {
if (!wp_verify_nonce($_REQUEST['_typesnonce'], '_typesnonce')) {
die('Verification failed (1)');
}
} else {
if (!isset($_REQUEST['_wpnonce']) || !wp_verify_nonce($_REQUEST['_wpnonce'], $_REQUEST['wpcf_action'])) {
die('Verification failed (2)');
}
}
global $wpcf;
switch ($_REQUEST['wpcf_action']) {
case 'insert_skype_button':
if (!current_user_can('edit_posts')) {
die('Authentication failed');
}
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields/skype.php';
wpcf_fields_skype_meta_box_ajax();
break;
case 'editor_callback':
if (!current_user_can('edit_posts')) {
die('Authentication failed');
}
// Determine Field type and context
$views_meta = false;
$field_id = sanitize_text_field($_GET['field_id']);
// todo this could be written in like four lines
if (isset($_GET['field_type']) && $_GET['field_type'] == 'usermeta') {
// Group filter
wp_enqueue_script('suggest');
$field = types_get_field($field_id, 'usermeta');
$meta_type = 'usermeta';
} elseif (isset($_GET['field_type']) && $_GET['field_type'] == 'views-usermeta') {
$field = types_get_field($field_id, 'usermeta');
$meta_type = 'usermeta';
$views_meta = true;
} elseif (isset($_GET['field_type']) && $_GET['field_type'] == 'termmeta') {
// Group filter
wp_enqueue_script('suggest');
$field = types_get_field($field_id, 'termmeta');
$meta_type = 'termmeta';
} elseif (isset($_GET['field_type']) && $_GET['field_type'] == 'views-termmeta') {
$field = types_get_field($field_id, 'termmeta');
$meta_type = 'termmeta';
$views_meta = true;
} else {
$field = types_get_field($field_id);
$meta_type = 'postmeta';
}
$parent_post_id = isset($_GET['post_id']) ? intval($_GET['post_id']) : null;
$shortcode = isset($_GET['shortcode']) ? urldecode($_GET['shortcode']) : null;
$callback = isset($_GET['callback']) ? sanitize_text_field($_GET['callback']) : false;
if (!empty($field)) {
// Editor
WPCF_Loader::loadClass('editor');
$editor = new WPCF_Editor();
$editor->frame($field, $meta_type, $parent_post_id, $shortcode, $callback, $views_meta);
}
break;
case 'dismiss_message':
if (!is_user_logged_in()) {
die('Authentication failed');
}
if (isset($_GET['id'])) {
$messages = get_option('wpcf_dismissed_messages', array());
$messages[] = sanitize_text_field($_GET['id']);
update_option('wpcf_dismissed_messages', $messages);
}
break;
case 'pr_add_child_post':
global $current_user;
$output = '<tr>' . __('Passed wrong parameters', 'wpcf') . '</tr>';
$id = 0;
$target_post_type = isset($_GET['post_type_child']) ? sanitize_text_field($_GET['post_type_child']) : '';
$has_permissions = current_user_can('publish_posts');
$has_permissions = apply_filters('toolset_access_api_get_post_type_permissions', $has_permissions, $target_post_type, 'publish');
if (!$has_permissions) {
$output = '<tr><td>' . __('You do not have rights to create new items', 'wpcf') . '</td></tr>';
} else {
if (isset($_GET['post_id']) && isset($_GET['post_type_child']) && isset($_GET['post_type_parent'])) {
$relationships = get_option('wpcf_post_relationship', array());
$parent_post_id = intval($_GET['post_id']);
$parent_post = get_post($parent_post_id);
if (!empty($parent_post->ID)) {
$post_type = sanitize_text_field($_GET['post_type_child']);
$parent_post_type = sanitize_text_field($_GET['post_type_parent']);
// @todo isset & error handling
$data = $relationships[$parent_post_type][$post_type];
/*
* Since Types 1.1.5
*
* We save new post
* CHECKPOINT
*/
//.........这里部分代码省略.........
示例2: types_validate
/**
* Validation wrapper.
*
* @param type $method
* @param type $args
* @return boolean
*/
function types_validate($method, $args)
{
WPCF_Loader::loadClass('validation-cakephp');
if (is_callable(array('Wpcf_Cake_Validation', $method))) {
if (!is_array($args)) {
$args = array($args);
}
return @call_user_func_array(array('Wpcf_Cake_Validation', $method), $args);
}
return false;
}
示例3: wpcf_ajax_embedded
/**
* All AJAX calls go here.
*
* @todo auth
*/
function wpcf_ajax_embedded()
{
if (isset($_REQUEST['_typesnonce'])) {
if (!wp_verify_nonce($_REQUEST['_typesnonce'], '_typesnonce')) {
die('Verification failed');
}
} else {
if (!isset($_REQUEST['_wpnonce']) || !wp_verify_nonce($_REQUEST['_wpnonce'], $_REQUEST['wpcf_action'])) {
die('Verification failed');
}
}
global $wpcf;
switch ($_REQUEST['wpcf_action']) {
case 'insert_skype_button':
if (!current_user_can('edit_posts')) {
die('Authentication failed');
}
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields/skype.php';
wpcf_fields_skype_meta_box_ajax();
break;
case 'editor_callback':
if (!current_user_can('edit_posts')) {
die('Authentication failed');
}
// Determine Field type and context
$views_usermeta = false;
$field_id = sanitize_text_field($_GET['field_id']);
// todo this could be written in like four lines
if (isset($_GET['field_type']) && $_GET['field_type'] == 'usermeta') {
// Group filter
wp_enqueue_script('suggest');
$field = types_get_field($field_id, 'usermeta');
$meta_type = 'usermeta';
} elseif (isset($_GET['field_type']) && $_GET['field_type'] == 'views-usermeta') {
$field = types_get_field($field_id, 'usermeta');
$meta_type = 'usermeta';
$views_usermeta = true;
} else {
$field = types_get_field($field_id);
$meta_type = 'postmeta';
}
$parent_post_id = isset($_GET['post_id']) ? intval($_GET['post_id']) : null;
$shortcode = isset($_GET['shortcode']) ? urldecode($_GET['shortcode']) : null;
$callback = isset($_GET['callback']) ? sanitize_text_field($_GET['callback']) : false;
if (!empty($field)) {
// Editor
WPCF_Loader::loadClass('editor');
$editor = new WPCF_Editor();
$editor->frame($field, $meta_type, $parent_post_id, $shortcode, $callback, $views_usermeta);
}
break;
case 'dismiss_message':
if (!is_user_logged_in()) {
die('Authentication failed');
}
if (isset($_GET['id'])) {
$messages = get_option('wpcf_dismissed_messages', array());
$messages[] = sanitize_text_field($_GET['id']);
update_option('wpcf_dismissed_messages', $messages);
}
break;
case 'pr_add_child_post':
$output = 'Passed wrong parameters';
if (current_user_can('edit_posts') && isset($_GET['post_id']) && isset($_GET['post_type_child']) && isset($_GET['post_type_parent'])) {
$relationships = get_option('wpcf_post_relationship', array());
$parent_post_id = intval($_GET['post_id']);
$parent_post = get_post($parent_post_id);
if (!empty($parent_post->ID)) {
$post_type = sanitize_text_field($_GET['post_type_child']);
$parent_post_type = sanitize_text_field($_GET['post_type_parent']);
// @todo isset & error handling
$data = $relationships[$parent_post_type][$post_type];
/*
* Since Types 1.1.5
*
* We save new post
* CHECKPOINT
*/
$id = $wpcf->relationship->add_new_child($parent_post->ID, $post_type);
if (is_wp_error($id)) {
$output = $id->get_error_message();
} else {
/*
* Here we set Relationship
* CHECKPOINT
*/
$parent = get_post($parent_post_id);
$child = get_post($id);
if (!empty($parent->ID) && !empty($child->ID)) {
// Set post
$wpcf->post = $child;
// Set relationship :)
$wpcf->relationship->_set($parent, $child, $data);
// Render new row
$output = $wpcf->relationship->child_row($parent_post->ID, $id, $data);
//.........这里部分代码省略.........
示例4: getImgObject
public static function getImgObject($img, $width, $height, $type, $mime)
{
if ($cached = self::$__cache->getCache("imgobj_{$img}")) {
return $cached;
}
if (self::inUploadAbsPath($img)) {
$url = self::normalizeAttachmentUrl($img);
} else {
WPCF_Loader::loadClass('path');
$url = WPCF_Path::getFileUrl($img, false) . '/' . basename($img);
}
$data = array('width' => $width, 'height' => $height, 'imagetype' => $type, 'mime' => $mime, 'url' => $url, 'path' => $img, 'pathinfo' => pathinfo($img));
$imgData = new Types_Image_Model((object) $data);
return self::$__cache->setCache("imgobj_{$img}", $imgData->getImg());
}
示例5: evaluate
/**
* Evaluates if check passed.
*
* @return type
*/
function evaluate()
{
WPCF_Loader::loadClass('evaluate');
$this->passed = WPCF_Evaluate::evaluate($this);
return $this->passed;
}
示例6: ajaxVerify
/**
* Processes AJAX call 'cd_verify'.
*
* @param type $data
* @return type
*/
function ajaxVerify($data)
{
WPCF_Loader::loadClass('helper.ajax');
return WPCF_Helper_Ajax::conditionalVerify($data);
}