本文整理汇总了PHP中ITSEC_Modules::get_validator方法的典型用法代码示例。如果您正苦于以下问题:PHP ITSEC_Modules::get_validator方法的具体用法?PHP ITSEC_Modules::get_validator怎么用?PHP ITSEC_Modules::get_validator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITSEC_Modules
的用法示例。
在下文中一共展示了ITSEC_Modules::get_validator方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: set_all
public function set_all($settings)
{
$retval = array('old_settings' => $this->settings, 'new_settings' => $this->settings, 'errors' => array(), 'messages' => array(), 'saved' => false);
$validator = ITSEC_Modules::get_validator($this->get_id());
if (is_null($validator)) {
$retval['errors'][] = new WP_Error('itsec-settings-missing-validator-for-' . $this->get_id(), sprintf(__('The data validator for %1$s is missing. Data for the module cannot be saved without the validator. This error could indicate a bad install of iThemes Security. Please remove the plugin and reinstall it. If this message persists, please contact support and send them this error message.', 'better-wp-security'), $this->get_id()));
} else {
$validator->validate($settings);
$retval['errors'] = $validator->get_errors();
$retval['messages'] = $validator->get_messages();
if ($validator->can_save()) {
$this->settings = $validator->get_settings();
ITSEC_Storage::set($this->get_id(), $this->settings);
$this->after_save();
$this->handle_settings_changes($retval['old_settings']);
$retval['new_settings'] = $this->settings;
$retval['saved'] = true;
} else {
ITSEC_Response::set_success(false);
}
}
ITSEC_Response::add_errors($retval['errors']);
ITSEC_Response::add_messages($retval['messages']);
return $retval;
}
示例2: get_messages
/**
* Returns the messages array.
*
* This function should be left as-is in subclasses.
*
* @access public
*
* @return array Array of status or update messages.
*/
public function get_messages()
{
$validator = ITSEC_Modules::get_validator($this->id);
if (is_null($validator)) {
return array();
}
return $validator->get_messages();
}
示例3: render_settings
protected function render_settings($form)
{
global $wp_locale;
$settings = $form->get_options();
$validator = ITSEC_Modules::get_validator($this->id);
$types = $validator->get_valid_types();
if (1 === $settings['start']) {
$tomorrow = date('Y-m-d', current_time('timestamp') + DAY_IN_SECONDS);
$new_start = strtotime("{$tomorrow} 1:00 am") - ITSEC_Core::get_time_offset();
$form->set_option('start', $new_start);
}
if (1 === $settings['end']) {
$tomorrow = date('Y-m-d', current_time('timestamp') + DAY_IN_SECONDS);
$new_end = strtotime("{$tomorrow} 6:00 am") - ITSEC_Core::get_time_offset();
$form->set_option('end', $new_end);
}
$date_format = get_option('date_format');
$time_format = get_option('time_format');
if (false !== strpos($time_format, 'G')) {
for ($hour = 0; $hour < 24; $hour++) {
$hours[$hour] = $hour;
}
} else {
if (false !== strpos($time_format, 'H')) {
for ($hour = 0; $hour < 24; $hour++) {
$hours[$hour] = sprintf('%02d', $hour);
}
} else {
for ($hour = 1; $hour <= 12; $hour++) {
$hours[$hour] = $hour;
}
if (false !== strpos($time_format, 'A')) {
$am = $wp_locale->get_meridiem('AM');
$pm = $wp_locale->get_meridiem('PM');
} else {
$am = $wp_locale->get_meridiem('am');
$pm = $wp_locale->get_meridiem('pm');
}
$meridiems = array('am' => $am, 'pm' => $pm);
}
}
for ($minute = 0; $minute <= 59; $minute++) {
$minutes[$minute] = sprintf('%02d', $minute);
}
$this->set_datetime_options($form, 'start', isset($meridiems));
$this->set_datetime_options($form, 'end', isset($meridiems));
/* translators: 1: date, 2: time */
$datetime_format = _x('%1$s \\a\\t %2$s', 'Date and time format', 'better-wp-security');
$datetime_format = sprintf($datetime_format, $date_format, $time_format);
$current_datetime = date_i18n($datetime_format);
?>
<p><?php
printf(__('Please note that according to your <a href="%s">WordPress Timezone settings</a> your current time is:', 'better-wp-security'), admin_url('options-general.php#timezone_string'));
?>
</p>
<p class="current-date-time"><?php
echo $current_datetime;
?>
</p>
<p><?php
printf(__('If this is incorrect, please update it on the <a href="%s">WordPress General Settings page</a> by selecting the appropriate time zone. Failure to set the correct timezone may result in unintended lockouts.', 'better-wp-security'), admin_url('options-general.php#timezone_string'));
?>
</p>
<table class="form-table itsec-settings-section">
<tr>
<th scope="row"><label for="itsec-away-mode-type"><?php
_e('Type of Restriction', 'better-wp-security');
?>
</label></th>
<td>
<?php
$form->add_select('type', $types);
?>
<br />
<p class="description"><?php
_e('Select the type of restriction you would like to enable.', 'better-wp-security');
?>
</p>
</td>
</tr>
<tr>
<th scope="row"><label for="itsec-away-mode-start_date"><?php
_e('Start Date', 'better-wp-security');
?>
</label></th>
<td>
<?php
$form->add_text('start_date');
?>
<br />
<p class="description"><?php
_e('Date when the admin dashboard should become unavailable.', 'better-wp-security');
?>
</p>
</td>
</tr>
<tr>
<th scope="row"><label for="itsec-away-mode-start_hour"><?php
_e('Start Time', 'better-wp-security');
?>
//.........这里部分代码省略.........