本文整理汇总了PHP中Essential_Grid_Base::getPostVar方法的典型用法代码示例。如果您正苦于以下问题:PHP Essential_Grid_Base::getPostVar方法的具体用法?PHP Essential_Grid_Base::getPostVar怎么用?PHP Essential_Grid_Base::getPostVar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Essential_Grid_Base
的用法示例。
在下文中一共展示了Essential_Grid_Base::getPostVar方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: on_front_ajax_action
/**
* Handle Ajax Requests
*/
public static function on_front_ajax_action()
{
$base = new Essential_Grid_Base();
$token = $base->getPostVar("token", false);
//verify the token
$isVerified = wp_verify_nonce($token, 'Essential_Grid_Front');
$error = false;
if ($isVerified) {
$data = $base->getPostVar('data', false);
//client_action: load_more_items
switch ($base->getPostVar('client_action', false)) {
case 'load_more_items':
$gridid = $base->getPostVar('gridid', 0, 'i');
if (!empty($data) && $gridid > 0) {
$grid = new Essential_Grid();
$result = $grid->init_by_id($gridid);
if (!$result) {
$error = __('Grid not found', EG_TEXTDOMAIN);
} else {
$grid->set_loading_ids($data);
//set to only load choosen items
$html = false;
//check if we are custom grid
if ($grid->is_custom_grid()) {
$html = $grid->output_by_specific_ids();
} else {
$html = $grid->output_by_specific_posts();
}
if ($html !== false) {
self::ajaxResponseData($html);
} else {
$error = __('Items Not Found', EG_TEXTDOMAIN);
}
}
} else {
$error = __('No Data Received', EG_TEXTDOMAIN);
}
break;
case 'load_more_content':
$postid = $base->getPostVar('postid', 0, 'i');
if ($postid > 0) {
$raw_content = get_post_field('post_content', $postid);
if (!is_wp_error($raw_content)) {
$content = apply_filters('the_content', $raw_content);
//filter apply for qTranslate and other
self::ajaxResponseData($content);
}
}
$error = __('Post Not Found', EG_TEXTDOMAIN);
break;
case 'get_search_results':
$search_string = $base->getVar($data, 'search', '');
$search_skin = $base->getVar($data, 'skin', 0, 'i');
if ($search_string !== '' && $search_skin > 0) {
$search = new Essential_Grid_Search();
$return = $search->output_search_result($search_string, $search_skin);
self::ajaxResponseData($return);
}
$error = __('Not found', EG_TEXTDOMAIN);
break;
case 'get_grid_search_ids':
$search_string = $base->getVar($data, 'search', '');
$grid_id = $base->getVar($data, 'id', 0, 'i');
if ($search_string !== '' && $grid_id > 0) {
$return = Essential_Grid_Search::output_search_result_ids($search_string, $grid_id);
if (!is_array($return)) {
$error = $return;
} else {
self::ajaxResponseSuccess('', $return);
}
}
$error = __('Not found', EG_TEXTDOMAIN);
break;
}
} else {
$error = true;
}
if ($error !== false) {
$showError = __('Loading Error', EG_TEXTDOMAIN);
if ($error !== true) {
$showError = $error;
}
self::ajaxResponseError($showError, false);
}
exit;
}