本文整理汇总了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;
}