本文整理汇总了PHP中PMXI_Import_Record::deletePostsAjax方法的典型用法代码示例。如果您正苦于以下问题:PHP PMXI_Import_Record::deletePostsAjax方法的具体用法?PHP PMXI_Import_Record::deletePostsAjax怎么用?PHP PMXI_Import_Record::deletePostsAjax使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PMXI_Import_Record
的用法示例。
在下文中一共展示了PMXI_Import_Record::deletePostsAjax方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pmxi_wp_ajax_delete_import
function pmxi_wp_ajax_delete_import()
{
if (!check_ajax_referer('wp_all_import_secure', 'security', false)) {
exit(json_encode(array('result' => false, 'msg' => __('Security check', 'wp_all_import_plugin'))));
}
if (!current_user_can('manage_options')) {
exit(json_encode(array('result' => false, 'msg' => __('Security check', 'wp_all_import_plugin'))));
}
$input = new PMXI_Input();
$post = $input->post(array('data' => ''));
$get = $input->get(array('iteration' => 1));
$params = array();
parse_str($post['data'], $params);
$response = array('result' => false, 'msg' => '', 'redirect' => add_query_arg('pmxi_nt', urlencode(__('Import deleted', 'wp_all_import_plugin')), $params['base_url']));
if (!empty($params['import_ids'])) {
foreach ($params['import_ids'] as $key => $id) {
$import = new PMXI_Import_Record();
$import->getById($id);
if (!$import->isEmpty()) {
if ((int) $get['iteration'] === 1) {
$import->set(array('deleted' => 0))->update();
}
$is_all_records_deleted = $import->deletePostsAjax(!$params['is_delete_posts'], $params['is_delete_images'], $params['is_delete_attachments']);
$response['result'] = empty($params['import_ids'][$key + 1]) ? $is_all_records_deleted : false;
$response['msg'] = sprintf(__('Import #%d - %d records deleted', 'wp_all_import_plugin'), $import->id, $import->deleted);
if ($is_all_records_deleted === true) {
$import->delete(!$params['is_delete_posts'], $params['is_delete_images'], $params['is_delete_attachments']);
}
}
}
}
exit(json_encode($response));
}