Wednesday, February 3, 2016

Proposal to store widgets in a custom post type instead of options

Widget instances are stored in options. For a multi-widget (WP_Widget) the widget instances of a given type (id_base) are stored in a serialized array of instance arrays. A widget ID is comprised of a widget's id_base followed by a number which is the array index for that widget instance. For example, the third-created Text widget would have the ID text-4 (note that multi-widget numbering starts at 2). Old single widgets do not include the numeric index after the id_base, and technically they could be stored anywhere (see #35656 for suggestion to deprecate old single widgets). Issues There are several problems with how widgets are currently stored as options. Scalability: For sites with a large number of widget instances, the entire collection of widgets must be unserialized with each request to access only one widget of a given type. (Note #23909 for how all widget instances get registered with every request.) For sites that use Memcached as an external object cache where cache buckets have a 1MB limit, since all widget instances of a given type are stored in a single option, sites with a huge number of widgets will overrun this limit. What's more is that widget options get registered #wordpress #smallbusiness #entrepreneur
https://managewp.org/articles/11646/proposal-to-store-widgets-in-a-custom-post-type-instead-of-options


No comments:

Post a Comment