本文整理匯總了PHP中test::read方法的典型用法代碼示例。如果您正苦於以下問題:PHP test::read方法的具體用法?PHP test::read怎麽用?PHP test::read使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類test
的用法示例。
在下文中一共展示了test::read方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: validate_config
/**
* Validate item config
*
* @since 0.3.0
*
* @access protected
*
* @param array $data Item config
*
* @return bool|array Item config array if valid, false if not.
*/
protected static function validate_config($data)
{
if (!isset($data['created'])) {
$data['created'] = current_time('mysql');
}
if (!isset($data['IP'])) {
$data['IP'] = ingot_get_ip();
}
if (!isset($data['uID'])) {
$data['uID'] = get_current_user_id();
}
if (!isset($data['slug'])) {
$data['slug'] = self::get_slug();
}
if (!isset($data['used'])) {
$data['used'] = 0;
}
if (isset($data['click_test_ID'])) {
$data['click_test_ID'] = absint($data['click_test_ID']);
} else {
$data['click_test_ID'] = 0;
}
if ($data['click_test_ID']) {
$test = test::read($data['click_test_ID']);
if (!is_array($test)) {
$data['click_test_ID'] = 0;
}
}
if (isset($data['click_url'])) {
$data['click_url'] = esc_url_raw($data['click_url']);
} else {
$data['click_url'] = '';
}
if (!isset($data['ingot_ID'])) {
$data['ingot_ID'] = self::find_ingot_id($data['uID'], $data['IP']);
}
$data['used'] = (bool) $data['used'];
$data['used'] = (int) $data['used'];
foreach (self::required() as $key) {
if (!isset($data[$key])) {
return new \WP_Error('ingot-session-crud-validation-fail', '', array('fail-key' => $key, 'data' => $data));
}
}
$allowed = array_merge(self::required(), self::needed());
foreach ($data as $key => $datum) {
if (!in_array($key, $allowed)) {
unset($data[$key]);
} elseif (is_numeric($datum)) {
$data[$key] = (string) $datum;
}
}
return $data;
}