How to add support for presently missing registration parameters
While we strive to provide fields for as many post type and taxonomy parameters as we can, we admit we do not have 100% of all available parameters. We do try to provide the most useful fields to our users. On occasion, we run into parameters that just aren't supported yet. If you are in that position, do not fret. You are not out of luck.
Adding missing parameters to post types before registration.
Right before the registration of post types, we run the parameters through a filter for last-second modifications by others. Because of this, you are able to add support for the missing parameter just in time.
/** * Filters the arguments used for a post type right before registering. * * @since 1.0.0 * @since 1.3.0 Added original passed in values array * * @param array $args Array of arguments to use for registering post type. * @param string $value Post type slug to be registered. * @param array $post_type Original passed in values for post type. */ $args = apply_filters( 'cptui_pre_register_post_type', $args, $post_type['name'], $post_type ); return register_post_type( $post_type['name'], $args );
The cptui_pre_register_post_type passes in the $args variable, the current post type slug that is being registered, and the original array of post type data from the CPTUI settings.
As you can see from the last line, the $args variable is going to hold an array of data that matches the proper parameter for the register_post_type function. This array will have all the calculated values from the CPTUI settings ready to use. Refer to the register_post_type WordPress codex page for more information all of the parameters. With this variable, you should be able to add your own array index values and return the new array.
Unless you're wanting to have the custom setting applied to all of the post types you're registering, you are going to want to utilize the second filter parameter to conditionally add the setting.
Adding missing parameters to taxonomies before registration.
Just like with post types, we also run the determined taxonomy parameters through a filter for last-second modifications.
/** * Filters the arguments used for a taxonomy right before registering. * * @since 1.0.0 * @since 1.3.0 Added original passed in values array * * @param array $args Array of arguments to use for registering taxonomy. * @param string $value Taxonomy slug to be registered. * @param array $taxonomy Original passed in values for taxonomy. */ $args = apply_filters( 'cptui_pre_register_taxonomy', $args, $taxonomy['name'], $taxonomy ); return register_taxonomy( $taxonomy['name'], $object_type, $args );
Just like with the post type filter, the cptui_pre_register_taxonomy filter filters the $args variable used for the taxonomy being registered. It also passes in the current taxonomy slug being registered, and the original array of taxonomy data. Refer to the register_taxonomy WordPress Codex page for more information all of the parameters. Once again, you can add your own array index values and return the new array.
You will once again want to utilize the second parameter from the filter to conditionally add your custom parameter, unless you want it to apply to all taxonomies.