[Plugin: More Fields] Patch to allow exported types
-
I also had a problem where the admin section was blocking me from using an exported More-Types type. Created a patch to only prevent “other” types from not being allowed.
--- ../tags/2.1/more-fields-settings.php 2012-03-07 15:51:01.000000000 -0700 +++ more-fields-settings.php 2012-03-07 16:54:07.000000000 -0700 @@ -158,8 +158,18 @@ if (is_object($more_types) && !empty($more_types)) { $box_key = $this->keys[1]; $link = (method_exists($more_types, 'options_url')) ? $more_types->options_url : ''; - $mfts = $more_types->get_objects(array('_plugin_saved', '_other')); + + // Other types: We are going to disable these. + $mfts_other = (array) $more_types->get_objects(array('_other')); + + // Plugin Saved types: We can use these, but the are not editable without an override. + $mfts_saved = (array) $more_types->get_objects(array('_plugin_saved')); + + // Plugin types: These were created in the admin section and exist in the DB. + $mfts_plugin = (array) $more_types->get_objects(array('_plugin')); + $mftss = $more_types->get_objects(array('_plugin_saved', '_other', '_plugin')); + foreach ($mftss as $key => $mft) { $options[$key] = array(); @@ -168,9 +178,14 @@ if (in_array($box_key, (array) $mftb)) $options[$key] = array_merge($options[$key], array('value' => 'on')); - // If this is created by file or elsewhere there's nothing we can do. - if (array_key_exists($key, (array) $mfts)) + // If this comes from some non-more-types area, disable it. + if (array_key_exists($key, $mfts_other)) $options[$key] = array_merge($options[$key], array('disabled' => true, 'text' => __("If you want to use your box for this post type you need to import it using <a href='$link'>More Types</a>.", 'more-types'))); + + // This type is from a file. No need to freak out, just let people know + if (array_key_exists($key, $mfts_saved) && !array_key_exists($key, $mfts_plugin)) + $options[$key] = array_merge($options[$key], array('text' => __("This type came from a saved file. To edit the type, go to <a href='$link'>More Types</a>.", 'more-types'))); + } }
- The topic ‘[Plugin: More Fields] Patch to allow exported types’ is closed to new replies.