/** * Revokes a certificate with Let's Encrypt. * * This method is called through one of the action callbacks. * * @since 1.0.0 * @access protected * * @param array $data The request data for the action. * @param bool $network_wide Whether this action should be performed network-wide. * @return string|WP_Error The success message or an error object. */ protected function revoke_certificate($data = array(), $network_wide = false) { $filesystem_check = $this->maybe_request_filesystem_credentials($network_wide); if (false === $filesystem_check) { return new WP_Error('invalid_filesystem_credentials', __('Invalid or missing filesystem credentials.', 'wp-encrypt'), 'error'); } $domain = $network_wide ? Util::get_network_domain() : Util::get_site_domain(); $manager = CertificateManager::get(); $response = $manager->revoke_certificate($domain); if (is_wp_error($response)) { return $response; } Util::delete_registration_info('certificate'); if (Util::get_option('autogenerate_certificate')) { Util::unschedule_autogenerate_event(); } return __('Certificate revoked.', 'wp-encrypt'); }
/** * Validates the plugin settings. * * Used as a callback for `register_setting()`. * * @since 1.0.0 * @access public * * @param array $options The options prior to being saved. * @return array The validated options. */ public function validate_settings($options = array()) { $options = array_map('strip_tags', array_map('trim', $options)); if (isset($options['country_code'])) { $options['country_code'] = strtoupper(substr($options['country_code'], 0, 2)); } if (isset($options['show_warning_days'])) { $options['show_warning_days'] = absint($options['show_warning_days']); } if (isset($options['autogenerate_certificate']) && $options['autogenerate_certificate']) { $certificate_registration_info = Util::get_registration_info('certificate'); if (isset($certificate_registration_info['_wp_time'])) { Util::schedule_autogenerate_event(strtotime($certificate_registration_info['_wp_time'])); } } else { Util::unschedule_autogenerate_event(); } return $options; }