$meta Column/key → value map from the caller. * @return array{write: array, dropped: array} */ public static function partition( array $meta ): array { /** * Keys that may be written even though they are `_`-prefixed internal meta. * * Published since Feature 065 and shared with `content/get-post`'s read filter. A site that * deliberately manages a `_`-prefixed key through these abilities adds it here. * * @since 0.0.42 (behaviour since Feature 065) * @param string[] $allowed Allow-listed protected keys. */ $allowed = (array) apply_filters( 'acrossai_allowed_protected_meta', array() ); $write = array(); $dropped = array(); foreach ( $meta as $key => $value ) { $key_str = (string) $key; if ( str_starts_with( $key_str, '_' ) && ! in_array( $key_str, $allowed, true ) ) { $dropped[] = $key_str; continue; } $write[ $key_str ] = $value; } return array( 'write' => $write, 'dropped' => $dropped, ); } /** * A per-key warning explaining why a key was refused and where to write it instead. * * The honest-reporting half of #274: a caller that only checks `success` must still have a * reason in `warnings`, not an empty array beside a populated `dropped_meta_keys`. * * @since 0.0.42 * @param string $key The refused meta key. * @return string */ public static function drop_warning( string $key ): string { return sprintf( /* translators: %s: the refused meta key. */ __( 'Meta key "%s" was not written: it is an internal (underscore-prefixed) key this bulk update refuses. Use content/update-post-meta to set it deliberately, or allow it site-wide via the acrossai_allowed_protected_meta filter.', 'acrossai-abilities-manager' ), $key ); } }