$args Array of arguments for registering a block type. * @return array Modified block type arguments. */ function wp_mark_auto_generate_control_attributes( array $args ): array { if ( empty( $args['attributes'] ) || ! is_array( $args['attributes'] ) ) { return $args; } $has_auto_register = ! empty( $args['supports']['autoRegister'] ); if ( ! $has_auto_register ) { return $args; } foreach ( $args['attributes'] as $attr_key => $attr_schema ) { // Skip HTML-derived attributes (edited inline, not via inspector). if ( ! empty( $attr_schema['source'] ) ) { continue; } // Skip internal attributes (not user-configurable). if ( isset( $attr_schema['role'] ) && 'local' === $attr_schema['role'] ) { continue; } // Skip unsupported types (only 'string', 'number', 'integer', 'boolean' are supported). $type = $attr_schema['type'] ?? null; if ( ! in_array( $type, array( 'string', 'number', 'integer', 'boolean' ), true ) ) { continue; } $args['attributes'][ $attr_key ]['autoGenerateControl'] = true; } return $args; } // Priority 5 to mark original attributes before other filters (priority 10+) might add their own. add_filter( 'register_block_type_args', 'wp_mark_auto_generate_control_attributes', 5 );