/** * Stores the current settings errors in a transient and redirects. * * This method is used at the end of regular action requests so that the result * of the action is displayed on the actual settings page. * * @since 1.0.0 * @access protected * * @param boolean $network_wide Whether this is a network wide request. */ protected function store_and_redirect($network_wide = false) { $func = 'set_transient'; $query_arg = 'settings-updated'; if ($network_wide) { $func = 'set_site_transient'; $query_arg = 'updated'; } call_user_func($func, 'settings_errors', get_settings_errors(), 30); wp_redirect(add_query_arg($query_arg, 'true', App::get_admin_url($network_wide ? 'network' : 'site'))); exit; }
/** * Shows a warning in the admin if the current certificate is close to expiration. * * Whether a warning like this should be shown or not can be specified through a setting, * as well as how many days before expiration it should start to show. * * Let's Encrypt certificates are valid for 90 days. The plugin may autogenerate the * certificate prior to expiration, but it is recommended to have this message show to keep * that in mind. * * @since 1.0.0 * @access public */ public function maybe_show_expire_warning() { if (!Util::get_option('show_warning')) { return; } if (!current_user_can('manage_certificates')) { return; } $certificate_registration_info = Util::get_registration_info('certificate'); if (!isset($certificate_registration_info['_wp_time'])) { return; } $expire = strtotime($certificate_registration_info['_wp_time']) + 90 * DAY_IN_SECONDS; $now = current_time('timestamp'); $diff = absint(($expire - $now) / DAY_IN_SECONDS); $trigger = Util::get_option('show_warning_days'); if ($diff > $trigger) { return; } $url = App::get_admin_url($this->context); if (Util::get_option('autogenerate_certificate')) { $text = _n('The Let’s Encrypt certificate will expire in %1$s day. It will be automatically renewed prior to expiration, but you can also manually renew it <a href="%2$s">here</a>.', 'The Let’s Encrypt certificate will expire in %1$s days. It will be automatically renewed prior to expiration, but you can also manually renew it <a href="%2$s">here</a>.', $diff, 'wp-encrypt'); } else { $text = _n('The Let’s Encrypt certificate will expire in %1$s day. Please renew it soon <a href="%2$s">here</a>.', 'The Let’s Encrypt certificate will expire in %1$s days. Please renew it soon <a href="%2$s">here</a>.', $diff, 'wp-encrypt'); } ?> <div id="wp-encrypt-expire-warning" class="notice notice-warning"> <p><?php printf($text, number_format_i18n($diff), $url); ?> </p> </div> <?php }