• Resolved modus

    (@modus)


    Hi,

    I’m using another meta-boxes plugin that has been abandoned and am not coder enough to get it to work with newer versions of WP myself. Fortunately it made use of the standard postmeta fields for data storage. In my post editors I only have text fields, and radio boxes, but the keys do not have a common prefix and some boxes are repeatable. So my questions are:

    – Can I replicate the metaboxes based on my old key/value pairs without using a prefix for the keys or is a prefix mandatory?

    – The old plugin used a numerical id, also stored in postmeta in order to determine, which set of meta-boxes had to be used with a post. Is this distinction in CMB2 based on a certain meta value, too, or does it rely on another method?

    – When I export the posts via WP, the values for repeatable forms are stored consecutively in the XML, like:

    <wp:postmeta>
    			<wp:meta_key>ext_url</wp:meta_key>
    			<wp:meta_value><![CDATA[https://external.1]]></wp:meta_value>
    		</wp:postmeta>
    		<wp:postmeta>
    			<wp:meta_key>ext_url</wp:meta_key>
    			<wp:meta_value><![CDATA[https://external.2]]></wp:meta_value>
    		</wp:postmeta>
    		<wp:postmeta>
    			<wp:meta_key>ext_link_text</wp:meta_key>
    			<wp:meta_value><![CDATA[text.1]]></wp:meta_value>
    		</wp:postmeta>
    		<wp:postmeta>
    			<wp:meta_key>ext_link_text</wp:meta_key>
    			<wp:meta_value><![CDATA[text.2]]></wp:meta_value>
    		</wp:postmeta>

    Does this match the way CMB2 stores values, too?

    Sorry to bug, but could you please enlighten me a bit?

    https://www.ads-software.com/plugins/cmb2/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    “Can I replicate the metaboxes based on my old key/value pairs without using a prefix for the keys or is a prefix mandatory?”

    The prefix that we have in our examples is not mandatory, it’s just something intended to help with organization and grouping. You can use the ID parameters for the fields without so that you can match up to what you already have.

    “The old plugin used a numerical id, also stored in postmeta in order to determine, which set of meta-boxes had to be used with a post. Is this distinction in CMB2 based on a certain meta value, too, or does it rely on another method?”

    By default, ours would show up on all editors of the specified post type, but they can be set to show only on certain ones. However, that setting value is not one that we store in the database or postmeta table. It’s set only in the filter callback used for the metabox addition.

    “Does this match the way CMB2 stores values, too?”

    Not that I recall, we tend to do more serialized data than multiple values for the same key. May not hurt to set up a repeatable field to test with and check the resulting value in the database.

    No bugging done. It’s what we’re here for.

    Thread Starter modus

    (@modus)

    Thanks a lot, I’d have one more question, you said:

    It’s set only in the filter callback used for the metabox addition.

    Looking around in the wiki I found a code snippet that seems to do what I need, but just to be sure: can you tell me, if this will still work the same way in CMB2?

    'show_on' => array(
    			'key' => 'taxonomy',
    			'value' => array(
    				'category' => 'cat-2',
    				'rotator-location' => …
    			)
    		),

    (found in https://gist.github.com/billerickson/070476e584b04a20c770)

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Not sure to be honest, though it wouldn’t take long to test it out either.

    I know Justin has tried to maintain backwards compatibility where possible, but it’s not always going to be the case.

    mac2net

    (@mac2net)

    Hi
    Congrats and thanks for the update.
    As I don’t think I am implementing any edgy/outlier cases, should I just follow the Notable Changes guidelines for upgrading?

    I am also going to retire another plugin but I am confident this won’t be problematic.

    Thanks
    Mike

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    That should be fine Mike,

    I can’t foresee any issues with doing those steps, but let us know if something does go wrong so we can investigate.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Migration, general question’ is closed to new replies.