本文整理匯總了PHP中Variable::super方法的典型用法代碼示例。如果您正苦於以下問題:PHP Variable::super方法的具體用法?PHP Variable::super怎麽用?PHP Variable::super使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Variable
的用法示例。
在下文中一共展示了Variable::super方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: module_generate
public static function module_generate($request = null)
{
$response = (object) array('status' => false, 'message' => __('Your request has failed', 'fakerpress'));
if (!Admin::$is_ajax && is_null($request) || !is_user_logged_in()) {
return Admin::$is_ajax ? exit(json_encode($response)) : $response;
}
$view = Variable::super(INPUT_POST, array(Plugin::$slug, 'view'), FILTER_SANITIZE_STRING);
$nonce_slug = Plugin::$slug . '.request.' . $view;
if (!check_admin_referer($nonce_slug)) {
$response->message = __('Security fail, refresh the page and try again!', 'fakerpress');
return Admin::$is_ajax ? exit(json_encode($response)) : $response;
}
// Here we have a Secure Call
$module_class_name = '\\FakerPress\\Module\\' . rtrim(ucfirst($view), 's');
$module = call_user_func_array(array($module_class_name, 'instance'), array());
$response->allowed = $module->get_amount_allowed();
$response->offset = absint(Variable::super(INPUT_POST, array('offset'), FILTER_UNSAFE_RAW));
$qty = $response->total = absint(Variable::super(INPUT_POST, array('total'), FILTER_UNSAFE_RAW));
if (!$response->total) {
$qty = Variable::super(INPUT_POST, array(Plugin::$slug, 'qty'), FILTER_UNSAFE_RAW);
if (is_array($qty)) {
$min = absint($qty['min']);
$max = max(absint(isset($qty['max']) ? $qty['max'] : 0), $min);
$qty = $module->faker->numberBetween($min, $max);
}
$response->total = $qty;
}
if ($qty > $response->allowed) {
$response->is_capped = true;
$qty = $response->allowed;
if ($response->total < $response->offset + $response->allowed) {
$qty += $response->total - ($response->offset + $response->allowed);
$response->is_capped = false;
}
} else {
$response->is_capped = false;
}
$results = $module->parse_request($qty, Variable::super(INPUT_POST, array(Plugin::$slug), FILTER_UNSAFE_RAW));
$response->offset += $qty;
if (is_string($results)) {
$response->message = $results;
} else {
$response->status = true;
$response->message = implode(', ', array_map(array($module, 'format_link'), $results));
$response->results = $results;
}
return Admin::$is_ajax ? exit(json_encode($response)) : $response;
}
示例2: parse_request
public function parse_request($qty, $request = array())
{
if (is_null($qty)) {
$qty = Variable::super(INPUT_POST, array(Plugin::$slug, 'qty'), FILTER_UNSAFE_RAW);
$min = absint($qty['min']);
$max = max(absint(isset($qty['max']) ? $qty['max'] : 0), $min);
$qty = $this->faker->numberBetween($min, $max);
}
$taxonomies = array_intersect(get_taxonomies(array('public' => true)), array_map('trim', explode(',', Variable::super($request, array('taxonomies'), FILTER_SANITIZE_STRING))));
if (0 === $qty) {
return sprintf(__('Zero is not a good number of %s to fake...', 'fakerpress'), 'posts');
}
for ($i = 0; $i < $qty; $i++) {
$this->param('taxonomy', $taxonomies);
$this->generate();
$results[] = $this->save();
}
$results = array_filter((array) $results, 'absint');
return $results;
}
示例3: _action_setup_settings_page
public function _action_setup_settings_page($view)
{
if ('post' !== self::$request_method || empty($_POST)) {
return false;
}
$nonce_slug = Plugin::$slug . '.request.' . self::$view->slug . (isset(self::$view->action) ? '.' . self::$view->action : '');
if (!check_admin_referer($nonce_slug)) {
return false;
}
$save_500px = is_string(Variable::super(INPUT_POST, array('fakerpress', 'actions', 'save_500px'), FILTER_UNSAFE_RAW));
if ($save_500px) {
$opts = array('key' => Variable::super(INPUT_POST, array('fakerpress', '500px-key'), FILTER_SANITIZE_STRING));
Plugin::update(array('500px'), $opts);
return self::add_message(__('Updated 500px Customer Application settings', 'fakerpress'), 'success');
}
// After this point we are safe to say that we have a good POST request
$erase_intention = is_string(Variable::super(INPUT_POST, array('fakerpress', 'actions', 'delete'), FILTER_UNSAFE_RAW));
$erase_check = in_array(strtolower(Variable::super(INPUT_POST, array('fakerpress', 'erase_phrase'), FILTER_SANITIZE_STRING)), array('let it go', 'let it go!'));
if (!$erase_intention) {
return false;
}
if (!$erase_check) {
return self::add_message(__('The verification to erase the data has failed, you have to let it go...', 'fakerpress'), 'error');
}
$refs = (object) array('post' => array(), 'term' => get_option('fakerpress.module_flag.term', array()), 'comment' => array(), 'user' => array());
$query_posts = new \WP_Query(array('post_type' => 'any', 'post_status' => 'any', 'nopaging' => true, 'posts_per_page' => -1, 'fields' => 'ids', 'meta_query' => array(array('key' => apply_filters('fakerpress.modules_flag', 'fakerpress_flag'), 'value' => true, 'type' => 'BINARY'))));
$refs->post = array_map('absint', $query_posts->posts);
$query_comments = new \WP_Comment_Query();
$query_comments = $query_comments->query(array('meta_query' => array(array('key' => apply_filters('fakerpress.modules_flag', 'fakerpress_flag'), 'value' => true, 'type' => 'BINARY'))));
foreach ($query_comments as $comment) {
$refs->comment[] = absint($comment->comment_ID);
}
$query_users = new \WP_User_Query(array('fields' => 'ID', 'meta_query' => array(array('key' => apply_filters('fakerpress.modules_flag', 'fakerpress_flag'), 'value' => true, 'type' => 'BINARY'))));
$refs->user = array_map('absint', $query_users->results);
foreach ($refs as $module => $ref) {
switch ($module) {
case 'post':
foreach ($ref as $post_id) {
wp_delete_post($post_id, true);
}
break;
case 'comment':
foreach ($ref as $comment_id) {
wp_delete_comment($comment_id, true);
}
break;
case 'term':
foreach ($ref as $taxonomy => $terms) {
foreach ($terms as $term) {
wp_delete_term($term, $taxonomy);
}
}
delete_option('fakerpress.module_flag.term');
break;
case 'user':
foreach ($ref as $user_id) {
wp_delete_user($user_id);
}
break;
}
}
return self::add_message(__('All data is gone for good.', 'fakerpress'), 'success');
}
示例4: _action_setup_settings_page
public function _action_setup_settings_page($view)
{
if ('post' !== self::$request_method || empty($_POST)) {
return false;
}
$nonce_slug = Plugin::$slug . '.request.' . self::$view->slug . (isset(self::$view->action) ? '.' . self::$view->action : '');
if (!check_admin_referer($nonce_slug)) {
return false;
}
$save_500px = is_string(Variable::super(INPUT_POST, array('fakerpress', 'actions', 'save_500px'), FILTER_UNSAFE_RAW));
if ($save_500px) {
$opts = array('key' => Variable::super(INPUT_POST, array('fakerpress', '500px-key'), FILTER_SANITIZE_STRING));
Plugin::update(array('500px'), $opts);
return self::add_message(__('Updated 500px Customer Application settings', 'fakerpress'), 'success');
}
// After this point we are safe to say that we have a good POST request
$erase_intention = is_string(Variable::super(INPUT_POST, array('fakerpress', 'actions', 'delete'), FILTER_UNSAFE_RAW));
$erase_check = in_array(strtolower(Variable::super(INPUT_POST, array('fakerpress', 'erase_phrase'), FILTER_SANITIZE_STRING)), array('let it go', 'let it go!'));
if (!$erase_intention) {
return false;
}
if (!$erase_check) {
return self::add_message(__('The verification to erase the data has failed, you have to let it go...', 'fakerpress'), 'error');
}
$modules = array('post', 'term', 'comment', 'user');
foreach ($modules as $module) {
$class_name = '\\FakerPress\\Module\\' . ucfirst($module);
if (!class_exists($class_name)) {
continue;
}
$items = call_user_func_array($class_name . '::fetch', array());
$deleted = call_user_func_array($class_name . '::delete', array($items));
}
return self::add_message(__('All data is gone for good.', 'fakerpress'), 'success');
}