This commit is contained in:
Javier Casares 2026-08-14 16:26:36 +00:00
commit 1f7343cd9d

View file

@ -97,6 +97,14 @@ class Frontend_Profile {
* @return string
*/
public function render_shortcode( $atts ): string {
// Content filters (including shortcodes) also run on REST requests,
// e.g. when the editor autosaves a post that mentions the shortcode
// in its text. Rendering there is useless and has side effects
// (such as generating an OTP secret), so bail out early.
if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) {
return '';
}
if ( ! is_user_logged_in() ) {
return '';
}
@ -123,6 +131,17 @@ class Frontend_Profile {
return '';
}
// settings_errors() and submit_button() are defined in wp-admin
// includes that are not loaded on frontend or REST requests (the
// shortcode also renders when content filters run on REST autosaves).
// Load them on demand.
if ( ! function_exists( 'settings_errors' ) ) {
require_once ABSPATH . 'wp-admin/includes/misc.php';
}
if ( ! function_exists( 'submit_button' ) ) {
require_once ABSPATH . 'wp-admin/includes/template.php';
}
ob_start();
/**