id = 'away-mode'; $this->title = __( 'Away Mode', 'better-wp-security' ); $this->description = __( 'Disable access to the WordPress Dashboard on a schedule.', 'better-wp-security' ); $this->type = 'recommended'; parent::__construct(); } public function enqueue_scripts_and_styles() { wp_enqueue_script( 'itsec-away-mode-settings-page-script', plugins_url( 'js/settings-page.js', __FILE__ ), array( 'jquery-ui-datepicker' ), $this->version, true ); wp_enqueue_style( 'itsec-jquery-ui', plugins_url( 'css/jquery-ui.min.css', __FILE__ ), array(), '1.11.4' ); wp_enqueue_style( 'itsec-jquery-ui-datepicker', plugins_url( 'css/jquery.datepicker.css', __FILE__ ), array( 'itsec-jquery-ui' ), '2014.03.27' ); } protected function render_description( $form ) { ?>
get_option( $prefix ); $timestamp += ITSEC_Core::get_time_offset(); $form->set_option( "{$prefix}_date", date( 'Y-m-d', $timestamp ) ); if ( $has_meridiems ) { $form->set_option( "{$prefix}_hour", intval( date( 'g', $timestamp ) ) ); $form->set_option( "{$prefix}_meridiem", date( 'a', $timestamp ) ); } else { $form->set_option( "{$prefix}_hour", intval( date( 'G', $timestamp ) ) ); } $form->set_option( "{$prefix}_minute", intval( date( 'i', $timestamp ) ) ); } 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 ); ?>WordPress Timezone settings your current time is:', 'better-wp-security' ), admin_url( 'options-general.php#timezone_string' ) ); ?>
WordPress General Settings page 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' ) ); ?>
add_select( 'type', $types ); ?>
|
|
add_text( 'start_date' ); ?>
|
|
add_select( 'start_hour', $hours ); ?>
add_select( 'start_minute', $minutes ); ?>
add_select( 'start_meridiem', $meridiems ); ?>
|
|
add_text( 'end_date' ); ?>
|
|
add_select( 'end_hour', $hours ); ?> add_select( 'end_minute', $minutes ); ?> add_select( 'end_meridiem', $meridiems ); ?> |