Forum Replies Created
-
AuthorPosts
-
May 5, 2023 at 10:54 PM in reply to: 'A post type mismatch has been detected.' error when saving custom post type #41727
James Cooper
ParticipantI debugged the issue (on a fresh WP install, default theme, only MB installed) and narrowed it down to a single Meta Box custom field. I have a custom field that has an id of 'post_type' and that seems to cause the error. When I change the field id to any other name, then the post saves fine. Seems like a possible bug. You can try to replicate it on your end.
Here is the code for the custom field:
'name' => __('Post Type', 'api-manager'), 'id' => $prefix . 'post_type', 'type' => 'select_advanced', 'desc' => __('Select the post type associated with the custom field you are mapping the data to.', 'api-manager'), 'options' => [ 'Populate with the available post types' => __('Populate with the available post types', 'api-manager'), ], 'placeholder' => __('Select a post type.', 'api-manager'), 'tooltip' => [ 'icon' => '', 'position' => 'top', 'content' => 'Post types in WordPress distinguish between various kinds of posts. To correctly associate the custom field, select the post type it corresponds to.', ], 'visible' => [ 'when' => [['object_type', '=', 'post']], 'relation' => 'or', ], 'tab' => 'data_storage_tab',April 30, 2023 at 10:55 PM in reply to: Meta Box License Warning On Plugin Activation with MB Bundled #41666James Cooper
ParticipantYes, there needs to be a solution because otherwise, it's a bad user experience to require users that use the plugin I develop to have to purchase a Meta Box license and enter the license key in order to use the plugin.
I've seen plugins that bundle ACF that do not have this issue, so there should be a solution that can be added.
April 28, 2023 at 9:32 PM in reply to: Meta Box License Warning On Plugin Activation with MB Bundled #41656James Cooper
ParticipantJust to note: The encoded license key above is not my actual license key.
April 28, 2023 at 9:31 PM in reply to: Meta Box License Warning On Plugin Activation with MB Bundled #41655James Cooper
ParticipantActually, the base64 encoding is no better because Chat GPT is able to decode it immediately. Just tested it and it returned my license key from the encoded license key.
Any other options?
April 28, 2023 at 9:24 PM in reply to: Meta Box License Warning On Plugin Activation with MB Bundled #41654James Cooper
ParticipantI am bundling Meta Box in a plugin. Forcing the end-user to have to access the wp-config.php to enter the license key would be a terrible user experience. I just want them to activate the plugin and not have to require any further action.
So I defined the constant in my plugin's main file like so:
if ( !defined( 'META_BOX_KEY' ) ) { define( 'META_BOX_KEY', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ123456' ); // Your Meta Box license key. }But that doesn't seem secure. I can obfuscate the key like so:
if ( ! defined( 'META_BOX_KEY' ) ) { $encoded_key = 'QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVoxMjM0NTY='; // Your base64-encoded Meta Box license key. $decoded_key = base64_decode( $encoded_key ); define( 'META_BOX_KEY', $decoded_key ); }But that's still not foolproof. Are there any other options?
James Cooper
ParticipantPerfect! Works great now!
Here is the updated code:
/** * Modify the output of the 'title' column for the 'import' custom model to include the 'edit' link. * * @param mixed $output Column output. * @param string $column_name Column name. * @param array $item Item data. * @param object $model Model instance. * * @return mixed Modified column output. */ add_filter('mbct_import_column_output', 'bcc_modify_title_column_output', 99, 4); function bcc_modify_title_column_output($output, $column_name, $item, $model) { if ($column_name === 'title') { $base_url = admin_url('admin.php?page=model-import'); $edit_url = add_query_arg( [ 'model-action' => 'edit', 'model-id' => $item['ID'], ], $base_url ); // Make the title a link to the 'edit' page. $output = '<a href="' . esc_url($edit_url) . '">' . $output . '</a>'; } return $output; }Thank you Peter!
James Cooper
ParticipantIs this on the roadmap? If so, when do you expect it to release? If not, are there any plans to get it on the roadmap?
Connecting Custom Models using MB Relationships should improve performance over using MB Relationships to connect CPT Posts in the "wp_posts" table that are separate from their CPT Meta Data in a Custom Table. It would also help keep the size of "wp_posts" down for large sites. I would love to see this capability integrated into MB Relationships. Any news on this would be greatly appreciated. Thank you!
Best Regards,
Ryan
March 4, 2023 at 12:17 AM in reply to: ✅Make A Field Required Based on Value of Another Field #40822James Cooper
ParticipantNever mind, I realized that using conditional logic to hide the field unless the options that make it required are chosen works how I want it to.
For future reference, given my example above:
Making the 'Character' field required and setting the conditional logic to display the 'Character' field only when 'Actor' or 'Actress' is chosen in the select field makes the 'Character' field required only when 'Actor' or 'Actress' is chosen.
This allows the post to be successfully saved when 'Director' or 'Writer' is chosen, but no 'Character' has been set (because even though the field is set to required the field is hidden and, therefore, not required in this instance).
If 'Actor' or 'Actress' is chosen, then the 'Character' field is displayed and requires a value for the post to be successfully saved.
Hope this helps anyone searching for this functionality in the future.
March 3, 2023 at 12:41 AM in reply to: ✅Conditional Logic Based On Taxonomy Term Slug Or Name #40796James Cooper
ParticipantDoes the MB Builder not support adding tax_input[taxonomy_slug] as the first parameter of the conditional logic fields? I try to add it, and it does not work.
This works as expected using the builder:
'visible' => [ 'when' => [['profession', 'in', ['31', '32']]], 'relation' => 'or', ],This does not work using the builder (where taxonomy_slug = 'profession'):
'visible' => [ 'when' => [['tax_input[profession]', 'in', ['31', '32']]], 'relation' => 'or', ],February 28, 2023 at 7:05 AM in reply to: Bug: Conditional Logic Set On Value Of Taxonomy Custom Field Prevents Post Save #40752James Cooper
ParticipantHi Peter,
I see that there was an update to Meta Box released today. However, the fix for this issue did not make it into this release. The issue is still present. Any news on when it will be fixed?
Thanks!
February 21, 2023 at 11:02 PM in reply to: Bug: Conditional Logic Set On Value Of Taxonomy Custom Field Prevents Post Save #40653James Cooper
ParticipantGreat! Thank you Peter!
February 21, 2023 at 11:00 PM in reply to: ✅Conditional Logic Based On Taxonomy Term Slug Or Name #40652James Cooper
ParticipantGreat! Thanks for pointing me in the right direction!
February 21, 2023 at 10:58 PM in reply to: ✅Bug: Nested Group Not Display Extra Options When Set To Cloneable #40651James Cooper
ParticipantYes, I'm not sure what caused it. It happened while I was following this tutorial: https://metabox.io/display-restaurant-opening-hours-p1-meta-box-gutenberg/
I believe it happened while duplicating some of the fields. It may have something to do with the duplication feature. Or, one of the fields got corrupted somehow and I duplicated it. Not completely sure.
I just deleted the fields that were giving me issues and rebuilt them. The new fields are working as expected now.
Thank you.
February 21, 2023 at 12:07 AM in reply to: Bug: Conditional Logic Set On Value Of Taxonomy Custom Field Prevents Post Save #40627James Cooper
ParticipantI can't seem to reproduce the 'Post Save' issue currently. So, maybe it has resolved itself somehow.
However, I have recorded a video of the second issue I mentioned (duplicate values in the conditional logic select box).
Duplicate Values In Conditional Logic Select Box
Here is the generated PHP code as well:
<?php add_filter( 'rwmb_meta_boxes', 'product_custom_fields' ); function product_custom_fields( $meta_boxes ) { $prefix = ''; $meta_boxes[] = [ 'title' => __( 'Product', 'product' ), 'id' => 'product', 'post_types' => ['product'], 'fields' => [ [ 'type' => 'heading', 'name' => __( 'Product Details', 'product' ), ], [ 'name' => __( 'Product Description', 'product' ), 'id' => $prefix . 'product_description', 'type' => 'wysiwyg', ], [ 'name' => __( 'Product Categories', 'product' ), 'id' => $prefix . 'product_categories', 'type' => 'taxonomy', 'taxonomy' => ['product-category'], 'field_type' => 'select_advanced', 'placeholder' => __( 'Select categories', 'product' ), 'add_new' => true, 'remove_default' => true, 'multiple' => true, ], [ 'name' => __( 'Product Type', 'product' ), 'id' => $prefix . 'product_type', 'type' => 'taxonomy', 'taxonomy' => ['product-type'], 'field_type' => 'select_advanced', 'placeholder' => __( 'Select a product type', 'product' ), 'add_new' => true, 'remove_default' => true, ], [ 'name' => __( 'Merchant', 'product' ), 'id' => $prefix . 'product_merchant', 'type' => 'taxonomy', 'taxonomy' => ['merchant'], 'field_type' => 'select_advanced', 'placeholder' => __( 'Select a merchant', 'product' ), 'add_new' => true, 'remove_default' => true, ], [ 'name' => __( 'Brand', 'product' ), 'id' => $prefix . 'product_brand', 'type' => 'taxonomy', 'taxonomy' => ['brand'], 'field_type' => 'select_advanced', 'placeholder' => __( 'Select a brand', 'product' ), 'add_new' => true, 'remove_default' => true, ], [ 'name' => __( 'Intended Use', 'product' ), 'id' => $prefix . 'product_intended_use', 'type' => 'text', ], [ 'name' => __( 'Schema Categorization', 'product' ), 'id' => $prefix . 'product_schema_categorization', 'type' => 'button_group', 'options' => [ 'uncategorized' => __( 'Uncategorized', 'product' ), 'tool' => __( 'Tool', 'product' ), 'supply' => __( 'Supply', 'product' ), ], 'std' => 'uncategorized', 'tooltip' => [ 'icon' => '', 'position' => 'top', 'content' => 'Supplies and tools are used to complete the how-to instructions.', ], ], [ 'name' => __( ' ', 'product' ), 'id' => $prefix . 'product_schema_categorization_tool_message', 'type' => 'custom_html', 'std' => '<span>A tool is used (but not consumed) when performing instructions for how to achieve a result.</span>', 'visible' => [ 'when' => [['product_schema_categorization', '=', 'tool']], 'relation' => 'or', ], ], [ 'name' => __( ' ', 'product' ), 'id' => $prefix . 'product_schema_categorization_supply_message', 'type' => 'custom_html', 'std' => '<span>A supply is consumed when performing the instructions for how to achieve a result.</span>', 'visible' => [ 'when' => [['product_schema_categorization', '=', 'supply']], 'relation' => 'or', ], ], [ 'type' => 'heading', 'name' => __( 'Pricing', 'product' ), ], [ 'name' => __( ' ', 'product' ), 'id' => $prefix . 'product_pricing_group', 'type' => 'group', 'clone' => true, 'sort_clone' => true, 'fields' => [ [ 'name' => __( 'Pricing Label', 'product' ), 'id' => $prefix . 'product_pricing_label', 'type' => 'text', 'columns' => 6, ], [ 'name' => __( 'Price', 'product' ), 'id' => $prefix . 'product_price', 'type' => 'number', 'columns' => 6, ], ], ], [ 'type' => 'heading', 'name' => __( 'Core Features & Benefits', 'product' ), ], [ 'name' => __( ' ', 'product' ), 'id' => $prefix . 'product_core_features', 'type' => 'group', 'clone' => true, 'sort_clone' => true, 'tooltip' => [ 'icon' => '', 'position' => 'top', 'content' => 'These are the features that readers care about most.', ], 'fields' => [ [ 'name' => __( 'Feature', 'product' ), 'id' => $prefix . 'product_feature', 'type' => 'text', ], [ 'name' => __( 'Feature Icon', 'product' ), 'id' => $prefix . 'product_feature_icon', 'type' => 'single_image', ], [ 'name' => __( 'Feature Rating', 'product' ), 'id' => $prefix . 'product_feature_rating', 'type' => 'star_rating', ], [ 'name' => __( 'Feature Details', 'product' ), 'id' => $prefix . 'product_feature_details', 'type' => 'wysiwyg', ], [ 'name' => __( 'Feature Benefit', 'product' ), 'id' => $prefix . 'product_feature_benefit', 'type' => 'text', 'tooltip' => [ 'icon' => '', 'position' => 'top', 'content' => 'How does this feature benefit the reader?', ], ], ], ], [ 'type' => 'heading', 'name' => __( 'Recommended For', 'product' ), ], [ 'name' => __( 'Recommended For', 'product' ), 'id' => $prefix . 'product_recommended_for', 'type' => 'text', 'clone' => true, 'sort_clone' => true, 'tooltip' => [ 'icon' => '', 'position' => 'top', 'content' => 'Who is this product recommended for?', ], ], [ 'type' => 'heading', 'name' => __( 'Pros & Cons', 'product' ), ], [ 'name' => __( 'Pros', 'product' ), 'id' => $prefix . 'product_pros', 'type' => 'text', 'clone' => true, 'sort_clone' => true, ], [ 'name' => __( 'Cons', 'product' ), 'id' => $prefix . 'product_cons', 'type' => 'text', 'clone' => true, 'sort_clone' => true, ], [ 'type' => 'heading', 'name' => __( 'Alternatives', 'product' ), ], [ 'name' => __( 'Alternatives Label', 'product' ), 'id' => $prefix . 'product_alternatives_label', 'type' => 'text', 'std' => 'Alternatives', 'columns' => 6, 'datalist' => [ 'id' => '63f3a88019885', 'options' => [ 'Alternatives ', 'Competitors ', 'Replacements', ], ], ], [ 'name' => __( 'Alternative (#)', 'product' ), 'id' => $prefix . 'product_alternative', 'type' => 'post', 'post_type' => ['product'], 'field_type' => 'select_advanced', 'clone' => true, 'sort_clone' => true, ], [ 'name' => __( 'Product Alternatives', 'product' ), 'id' => $prefix . 'product_alternatives_group', 'type' => 'group', 'clone' => true, 'sort_clone' => true, 'fields' => [ [ 'name' => __( 'Alternative Name', 'product' ), 'id' => $prefix . 'product_alternative_name', 'type' => 'text', 'columns' => 6, ], [ 'name' => __( 'Alternative URL', 'product' ), 'id' => $prefix . 'product_alternative_url', 'type' => 'url', 'placeholder' => __( 'http://www.alternative-url.com', 'product' ), 'columns' => 6, ], [ 'name' => __( 'Best For', 'product' ), 'id' => $prefix . 'product_alternative_best_for', 'type' => 'text', ], [ 'name' => __( 'Price', 'product' ), 'id' => $prefix . 'product_alternative_price', 'type' => 'text', ], ], ], [ 'type' => 'heading', 'name' => __( 'Media', 'product' ), ], [ 'name' => __( 'Product Image', 'product' ), 'id' => $prefix . 'product_image', 'type' => 'single_image', 'image_size' => 'image-1000', ], [ 'name' => __( 'Product Gallery', 'product' ), 'id' => $prefix . 'product_image_gallery', 'type' => 'image_advanced', 'image_size' => 'image-1000', ], [ 'type' => 'heading', 'name' => __( 'Link Details', 'product' ), ], [ 'name' => __( 'Product Link', 'product' ), 'id' => $prefix . 'product_link', 'type' => 'url', 'placeholder' => __( 'http://www.link-to-product.com', 'product' ), ], [ 'name' => __( 'Product link is an affiliate link?', 'product' ), 'id' => $prefix . 'product_link_is_affiliate_link', 'type' => 'checkbox', ], [ 'name' => __( 'Link Text', 'product' ), 'id' => $prefix . 'product_link_text', 'type' => 'text', 'tooltip' => [ 'icon' => '', 'position' => 'top', 'content' => 'If the product link is added to content as text, this is the text that is used for the link.', ], ], [ 'type' => 'heading', 'name' => __( 'Card Details', 'product' ), 'desc' => __( 'Add information for elements the are displayed on product cards.', 'product' ), ], [ 'name' => __( 'Card Heading', 'product' ), 'id' => $prefix . 'product_card_heading_choice', 'type' => 'button_group', 'options' => [ 'linktext' => __( 'Use Link Text For Card Heading', 'product' ), 'custom' => __( 'Add Custom Card Heading', 'product' ), ], 'std' => 'linktext', ], [ 'name' => __( 'Custom Heading', 'product' ), 'id' => $prefix . 'product_card_heading', 'type' => 'text', 'visible' => [ 'when' => [['product_card_heading_choice', '=', 'custom']], 'relation' => 'or', ], ], [ 'name' => __( 'Sub Heading', 'product' ), 'id' => $prefix . 'product_card_sub_heading', 'type' => 'text', ], [ 'name' => __( 'CTA Text', 'product' ), 'id' => $prefix . 'product_CTA_text', 'type' => 'text', 'tooltip' => [ 'icon' => '', 'position' => 'top', 'content' => 'Use actionable text to be displayed on buttons.', ], ], [ 'name' => __( 'Do you own this product?', 'product' ), 'id' => $prefix . 'product_own_it', 'type' => 'checkbox', 'tooltip' => [ 'icon' => '', 'position' => 'top', 'content' => 'When selected, an "Own It" ribbon is displayed on the product card.', ], ], [ 'type' => 'heading', 'name' => __( 'Product Amazon Codes', 'product' ), ], [ 'id' => $prefix . 'product_amazon_codes', 'type' => 'group', 'fields' => [ [ 'name' => __( 'Amazon Image Code', 'product' ), 'id' => $prefix . 'product_amazon_image_code', 'type' => 'textarea', 'rows' => 10, ], [ 'name' => __( 'Amazon Native Ads Code', 'product' ), 'id' => $prefix . 'product_amazon_native_ads_code', 'type' => 'textarea', 'rows' => 11, ], ], 'visible' => [ 'when' => [['product_mercant', '=', 'amazon']], 'relation' => 'or', ], ], [ 'name' => __( ' ', 'product' ), 'id' => $prefix . 'product_add_brand_link', 'type' => 'custom_html', 'std' => '<a href="/wp-admin/post-new.php?post_type=review" target="_blank" class="button">+ Add Review</a>', ], ], ]; return $meta_boxes; }February 15, 2023 at 12:26 AM in reply to: ✅Setting Default Values For MB Builder Custom Field Types #40525James Cooper
ParticipantI figured it out. I just added 'std' to the list of controls for the 'star_rating' field type (which activated the Default Value field in the MB Builder for the 'star_rating' field. I then set the Default Value to 5. Now, when I create a new review post, the rating is automatically set to 5 stars.
// Add star rating field type to Meta-Box Builder $field_types['star_rating'] = [ 'title' => __( 'Star Rating', 'blogcraftco-theme' ), 'category' => 'advanced', 'controls' => [ 'name', 'id', 'type', 'label_description', 'desc', 'std', 'clone', 'sort_clone', 'clone_default', 'clone_as_multiple', 'max_clone', 'add_button', 'before', 'after', 'class', 'save_field', 'sanitize_callback', 'attributes', 'custom_settings', ], ]; -
AuthorPosts