diff --git a/includes/Options.php b/includes/Options.php index abb01b9..a1d7b10 100644 --- a/includes/Options.php +++ b/includes/Options.php @@ -23,6 +23,13 @@ class Options { */ private static $options = array(); + /** + * The blog ID the cached options belong to. + * + * @var int $cache_blog_id + */ + private static $cache_blog_id = 0; + /** * Get the options for Simple Comment Editing. * @@ -35,9 +42,21 @@ class Options { */ public static function get_options( $force = false, $key = '' ) { + // Per-site options are cached per blog, so switch_to_blog() cannot return stale values. + $blog_id = get_current_blog_id(); + if ( self::$cache_blog_id !== $blog_id ) { + self::$options = array(); + self::$cache_blog_id = $blog_id; + } + $options = self::$options; if ( ! is_array( $options ) || empty( $options ) || true === $force ) { - $options = get_site_option( 'sce_options', array() ); + // Read from the same place update_options() writes: network option only when network-activated. + if ( Functions::is_multisite() ) { + $options = get_site_option( 'sce_options', array() ); + } else { + $options = get_option( 'sce_options', array() ); + } self::$options = $options; } if ( false === $options || empty( $options ) || ! is_array( $options ) ) { diff --git a/readme.txt b/readme.txt index e0f21d6..9f8112e 100644 --- a/readme.txt +++ b/readme.txt @@ -154,6 +154,7 @@ You can report security bugs through the Patchstack Vulnerability Disclosure Pro == Changelog == = Unreleased = +* Fix: On multisite, read settings from the same place they are saved, so sub-sites that are not network-activated use and display their own settings instead of defaults. * Fix: Preserve WP ULike comment buttons, their vote state, and their top/bottom placement after inline comment saves. * New: Add a repeat-safe, root-scoped initializer for AJAX/lazy-loaded comment controls and an opt-in guest ownership hook for validated AJAX submissions. * New: Add moderator-only comment/subtree movement with a native admin preview, explicit confirmation, thread/count preservation, and recovery records.