privacy_mode_bridged = false; if ( $value !== null ) { return $value; } /** * Filters the active privacy mode. * * Return one of `strict`, `balanced`, or `off` to override the stored * option. Return null (the default) to defer to the option/default. A * value outside that vocabulary is ignored, and resolution continues to * the stored value. * * @since 1.3.0 * * @param string|null $mode The overriding mode value, or null to defer. */ $legacy = apply_filters( 'albert/privacy/mode', null ); if ( ! is_string( $legacy ) || $legacy === '' ) { return null; } $this->privacy_mode_bridged = true; return $legacy; } /** * Bridge `albert/media/upload_link_max_bytes` onto the generic chain. * * That filter speaks bytes; the option it overrides stores megabytes, so * the two are not interchangeable and this converts. Rounding is **up**, and * never to zero: the field's own minimum is 1, and rendering `value="0"` * against it would be invalid. The exact size is not lost — the field's hint * carries it, which is why that one callback survives while the rest went. * * {@see UploadLinkService::default_max_bytes()} does not read this value. It * reads the byte filter directly, so the limit actually enforced is exact * rather than rounded to a megabyte. * * @since 1.4.0 * * @param mixed $value Value resolved so far, null when nothing has claimed it. * * @return mixed Megabytes, or the untouched input. */ public function upload_max_mb( $value ) { if ( $value !== null ) { return $value; } $state = UploadLinkService::get_default_max_bytes_filter_state(); if ( $state['state'] !== 'active' ) { return null; } return max( 1, (int) ceil( $state['value'] / UploadLinkService::BYTES_PER_MB ) ); } /** * Name `albert/privacy/mode` as the source, but only when it is genuinely * what answered. * * Decided by {@see self::$privacy_mode_bridged}, set a moment earlier in * the same resolution, rather than by asking whether anything is attached * to the legacy hook. See that property for what the difference cost. * * @since 1.4.0 * * @param mixed $name Source name resolved so far. * * @return mixed */ public function privacy_mode_source( $name ) { if ( is_string( $name ) && $name !== '' ) { return $name; } return $this->privacy_mode_bridged ? 'albert/privacy/mode' : $name; } }