I created blocks using carbon fields, everything was working fine initially. However for some reason now, every carbon fields block is showing the error:
“Your site doesn’t include support for the “carbon-fields/custom-tabs” block. You can leave this block intact or remove it entirely.”
I am not sure what this could be the issue, any solutions?
]]>It is possible to put a form in the frontoffice/public area?
]]>The plugin in the WordPress plugin repo is outdated, and you should NOT use it for new sites.
Instead, either install the plugin as a composer package(see here https://docs.carbonfields.net/#/quickstart), or read this page to get a recent build of the library as a plugin: https://docs.carbonfields.net/#/plugin-quickstart?id=without-composer
—
The reasons for this are quite technical and are described here: https://carbonfields.net/2017/07/31/carbon-fields-distribution-woes/
The TLDR is that Carbon Fields is not a plugin on it’s own, but rather a library that other plugins and themes use. That being said, it shouldn’t be updated by end users, but by developers.
]]>Hi! I need do a map in my site. link screenshot I see coordinate. I need a map. How its do? I dont see that in official documentation. I consequence like this <div class="map" id="map" style="height: 480px; width: 100%"><?php echo $map_data;?> </div>
Kindly refer to the image in the link to suggest the solution.
]]>When using post_template condition the custom field is shown in classic editor but it is not appearing in gutenberg. Fields and custom post types are working with gutenberg but obviously there is a problem with page templates.
Is that a known issue?
I want to show woocommerce category list in the plugin fields. But its not working for me. Here is my code so far
<?php
use Carbon_Fields\Container;
use Carbon_Fields\Field;
Class asd_plugin_Settings {
function __construct() {
add_action( ‘init’, array($this, ‘get_cats’) );
add_action( ‘carbon_fields_register_fields’, array($this,’crb_attach_theme_options’) );
add_action( ‘after_setup_theme’, array($this,’make_crb_load’) );
}
public function crb_attach_theme_options() {
Container::make( ‘theme_options’, __( ‘Theme Options’, ‘crb’ ) )
->add_fields( array(
Field::make( “multiselect”, “crb_available_cats”, “Category” )
->add_options( $this->get_product_cats() ),
) );
}
public function make_crb_load() {
require_once( ASD_PLUGIN_PATH . ‘/carbon-fields/vendor/autoload.php’ );
\Carbon_Fields\Carbon_Fields::boot();
}
public function get_cats() {
$categories = get_terms( ‘product_cat’, ‘orderby=name&hide_empty=0’ );
$cats = array();
if ( $categories )
foreach ( $categories as $cat )
$cats[$cat->term_id] = esc_html( $cat->name );
print_r($cats); //getting category properly
}
public function get_product_cats() {
$categories = get_terms( ‘product_cat’, ‘orderby=name&hide_empty=0’ );
$cats = array();
if ( $categories )
foreach ( $categories as $cat )
$cats[$cat->term_id] = esc_html( $cat->name );
return $cats; //not getting category. Showing error invalid taxonomy
}
}
]]>Hi,
I’m using CF in my plugin for admin and custom post options and it’s working beautifully so far.
However, how can I validate a field server-side? For instance, say I have a text field which I want to insure contains an e-mail address. Where would I create my validation code? Is there a callback?
I can’t find anything in the docs.
I realize there is front-end validation with React, but this doesn’t seem to be very secure, since a user could modify it and then add junk data.
Thanks,
DC
How can i do a few columns options?
]]>Hi! How can i add a custom fields to the posts from a specific category only? Thanks!
]]>Hi. Please, how to install Carbon Fields as a library (not plugin) without composer? Thanks!
]]>Подскажите как вывести количество дней, например: сайт работает Х дней? Дату в посте указываю через “Date (дата)”.
use Carbon_Fields\Container;
use Carbon_Fields\Field;
Container::make('post_meta', 'Свойства')
->show_on_post_type('resources')
->add_fields(array(
Field::make("date", "crb_my_date", "Дата")
Выводить надо в одиночной записи и в категории. В wp есть функция human_time_diff():
$human_time = human_time_diff( get_post_time( 'U', true ) );
echo "Сайт работает $human_time дней.";
но как сделать не знаю 8(
]]>Hello!
I’ve been using CF for a while on several projecs and it’s been great. I just updated to V2 so we could use the radio image field and make editing easier for our customers and the php output on my template files disapeared. I can still view / edit / add fields on the edit page, but nothing shows on the template pages since the update.
I’m using the following structure to create the fields:
$panel_labels = array('plural_name' => 'Panels', 'singular_name' => 'Panel',);
$section_labels = array('plural_name' => 'Sections', 'singular_name' => 'Section',);
$column_labels = array('plural_name' => 'Columns', 'singular_name' => 'Column',);
Container::make('post_meta', 'Panels')
->show_on_post_type('page')
->show_on_template('template_void.php')
->add_fields(array(
Field::make('complex', 'panel')->setup_labels($panel_labels)->add_fields(array(
Field::make("select", "panel-width", "Panel Width")->add_options(array('full-width' => 'Full Width','site-width' => 'Site Width',)) ,
Field::make("image", "panel-bg", "Background Image - Optional")->set_value_type('url'),
Field::make('complex', 'section')->setup_labels($section_labels)->add_fields(array(
Field::make('complex', 'column')->setup_labels($column_labels)->add_fields(array(
Field::make("select", "column-width", "Column Width")
->add_options(array(
'99' => 'Full',
'49' => '1/2',
'32' => '1/3',
))->set_width( 20 ),
Field::make("rich_text", "column-content", "Column Content")->set_width( 80 ),
)),
)),
)),
));
This is the code used to display the fields on the template pages:
<?php $panels = carbon_get_post_meta( get_the_ID(), 'panel', 'complex' ); ?>
<?php if ( ! empty( $panels ) ): ?><?php foreach ( $panels as $panel ): ?>
<div class="<?php echo $panel['panel-width']; ?>" style="background-image:url('<?php echo $panel['panel-bg']; ?>');background-size:cover;">
<?php if ( ! empty( $panel['section'] ) ): ?><?php foreach ( $panel['section'] as $row ): ?>
<div class="section">
<?php if ( ! empty( $row['column'] ) ): ?><?php foreach ( $row['column'] as $column ): ?>
<div class="column" style="width:<?php echo $column['column-width']; ?>%;">
<?php $shortcode = $column['column-content']; echo do_shortcode($shortcode); ?>
</div>
<?php endforeach ?><?php endif ?>
<div class="clear"></div>
</div>
<?php endforeach ?><?php endif ?>
</div>
<?php endforeach ?><?php endif ?>
Can you point me in the right direction on how to update my code to use with v2?
Thank you!
]]>hi,
I’m searching a solution for add metaboxe in the admin screen of menu wordpress
With the carbon field plugin, i can create this metaboxes? In your documentation, i can add another metaboxe in the item of menu. but for my project, i want to put a custom metaboxe in the manage location of menu wordpress
I want to use a custom taxonomy for my menu (each menu). With carbon field it’s possible ?
Thanks so lot
]]>Hello!
I’m wondering is there any way to load data as select field value through ajax or any other way. The idea is get all posts categories (already done) within select field and load all posts inside new select field according on selected category.
PS:
I’m using CF for a short time, but already amazed with this library!
Hi,
Since version 2 was introduced I am unable to access any of my meta data that was created from my complex field in version 1.
Using the example from the docs:
Container::make( ‘post_meta’, ‘Slider Data’ )
->where( ‘post_type’, ‘=’, ‘page’ )
->add_fields( array(
Field::make( ‘complex’, ‘slides’ )->add_fields( array(…..
I was able to just do something like:
$data = carbon_get_post_meta( get_the_ID(), ‘slides’, ‘complex’ );
print_r($data) or var_dump($data) to get the array of information and go from there. Now all my complex fields return false. Can someone tell me how to accurately grab all of the info from a complex field? Multiple group complex preferably.
Thanks
]]>Hi,
I’m working with your plugin for my project (big project for my society) but i can see that carbon fields is not compatible with the last version of wordpress (4.8)
I think that a lot of job for you in this project. When carbon fields will compatible with wordpress 4.8 ?
Thanks
]]>Hi,
I’m creating a complex custom fields in user profile of my wordpress. Now, i have got a awesome complex fields in my user profile for select the option for my user…greaat !!. Here is my code of my complex field :
// Add field in user profile_personal_options
Container::make('user_meta', 'Entité utilisateurs')
->add_fields(array(
field::make('complex', 'crb_entite_utilisateurs')
->add_fields(array(
Field::make('select', 'crb_select_users_entite', 'Entité assignée à l\'utilisateur')
->add_options( spm_list_entite() )
))
));
But i want to retrieve this datas for put in my custom columns in admin user screen. First i create my custom column :
function modify_columns_users($columns) {
return array_merge($columns, array(
'entite' => 'Entité'
));
}
add_filter('manage_users_columns', 'modify_columns_users');
then, i want to put this datas of complex fields in this custom columns. Here is my code :
function add_content_entite_users($value, $column_name, $user_id) {
$user = carbon_get_user_meta( $user_id, 'crb_entite_utilisateurs' );
if($column_name == 'entite') {
echo $user;
}
return $value;
}
add_filter('manage_users_custom_column', 'add_content_entite_users');
With this code i have got a error in my back office wordpress :
I don’t understand my mistake. Have you got an idea ?
thanks so lot
]]>Thank you for your attention these past couple days! I’ve encountered one more issue. I’ve released a plugin, Seasonal CSS, that includes the Carbon Fields library as available on Github. However, when I activate the plugin on a site that also contains this plugin (Carbon Fields v1.6.0), I receive the following fatal error…
Fatal error: Call to undefined method Carbon_Fields\Container\Container::init_containers() in /app/public/wp-content/plugins/carbon-fields/core/Helper/Helper.php on line 67.
Can you please advise on how to best remedy this? It seems like a conflict between the two versions of Carbon Fields, so I don’t know that there is much I can do to intervene. Thanks!
]]>I have successfully included Carbon Fields in a plugin I am developing for release to the WP plugin directory. (Thanks to @atanasangelovdev for the help here.)
However, now as I am attempting to the upload my plugin zip file for review, I receive the following error:
Error: The plugin already exists. There is already a plugin called carbon-fields by a different author. Please change the Plugin Name: line in your main plugin file and upload it again.
It appears that @meshsmith encountered a similar issue here.
At the moment, is my best course of action to remove the headers from my-plugin-dir/wp-content/plugins/carbon-fields/carbon-fields-plugin.php
? Or, is there a better way to approach inclusion of this framework in my plugin? Thanks for any advice you can offer.
Broke compatibility with l10n when I try make container. After translate container name, container behavior becomes unpredictable.
]]>I had successfully implemented Carbon Fields 1.6.0 in a plugin I’m developing. However, once I drop in 2.0.1 (in order to access new date methods), I receive the following Fatal Error:
Fatal error: Class 'Carbon_Fields\Carbon_Fields' not found in /app/public/wp-content/plugins/***/lib/carbon/carbon-fields-plugin.php on line 25.
Do you know of any good documentation on how to best implement 2.0.1 in a plugin? Thanks!
]]>Hello,
I recently learned about Carbon Fields and really interested in using in my current project. Since the V 2.0 is already available in GitHub, when could we expect it here please?
Thanking you,
Bage.
Hello -I’ve seen this post but if it does apply to what I’m trying to do I can’t figure it out.
I’m trying to add alt tags to my carbon fields images. There is no image alt tag field so I’ve been trying to add echo the image meta data.
This:
<?php foreach ($team_types as $type_index => $type):
$name = $type['title'];
$type_image = $type['team_type_icon'];
$active_class = '';
if ($type_index == 0) {
$active_class = ' class="active"';
}
?>
<li <?php echo $active_class; ?> style="background-color:tan;">
<a href="#<?php echo sanitize_title_with_dashes($name); ?>">
<?php echo crb_wp_get_attachment_image($type_image, 'crb_home_tab_icon','alt'); ?>
</a>
</li>
outputs alt=””
I’m also using this function:
function wp_get_attachment( $attachment_id ) {
$attachment = get_post( $attachment_id );
return array(
'alt' => get_post_meta( $attachment->ID, 'wp_attachment_image_alt', true )
);
}
But I’m not getting anywhere. I’m trying to output the image meta data -specifically the alt tag in the media library.
Any ideas?
]]>Hi,
I am working on a site that utilizes CF very heavily and I am running into some issues with search. It appears that any content in these CF meta boxes is noticed by WordPress Search but when it comes to displaying results it shows empty tags with no content. Is there something special I need to be adding to my theme or do I need a custom search template?
Here is a screenshot of my dev tools upon inspection of the search page:
https://ibb.co/fcAVA5
Thanks!
]]>My need: create an academic reference which is the result of multiple inputs which are all output on a single line with different styles per entry. Imagine that each of these words is a different field which are then output as follows:
FLOWER, 1978, George Orwell, Canada.
Is this something I can do with Carbon Fields?
Thanks
]]>Hi,
I come back in the support ?? !
I have got a question for the security of this plugin. Now, for my project i’m using this fantastic plugin. It’s a great plugin and very simple to use
But i have got some questions for the security with this plugins. How carbon fields is secured ? And how increase the security with this plugin (sanitize, nonce or other things)
thanks so lot for your job and your support
Bye
]]>Hi,
I use carbon fields for add a thumbnail for my custom taxonomy. With this plugin it’s so easy
But now, i want to retrieve this thumbnail for the admin area of my custom categories. In the columns, i want to put another column for featured image. With, the codex, i use this code :
function my_custom_taxonomy_columns_content($columns)
{
$columns['featured-img-dossier'] = __('Image Dossier');
return $columns;
}
add_filter('manage_edit-dossier_cat_columns', 'my_custom_taxonomy_columns_content');
function add_content_custom_taxo_column($content, $column_name, $term_id) {
if ( 'featured-img-dossier' == $column_name ) {
return $content;
}
if(has_term_thumbnail($term_id)) {
echo get_term_thumbnail( $term_id, $size = "category-thumb", $attr = "" );
} else {
echo 'pas d\'image';
}
}
add_action('manage_dossier_cat_custom_column','add_content_custom_taxo_column', 10, 3);
For retrieve the thumbnail of term meta (create with your plugin), i must to make a special things ?
I’m searching help in google, i’m not finding a solution. Have you got an ideas ?
Thanks so lot
Bye
]]>Hey there,
I’m trying to retrieve categories within a field (make method).
Basically I’m trying to achieve the following:
$argsCat = array(
'orderby' => 'ID',
'order' => 'ASC'
);
$categories = get_categories( $argsCat );
// My field
Container::make('post_meta', __( 'My field' ) )
->show_on_post_type('page')
->add_fields( array(
// gallery
Field::make( 'complex', 'h_hero_slider', __( 'Ajouter un slide' ) )
->add_fields( '', [
Field::make( 'select', 'cat', 'Catégorie slider' )
->set_width(50)
->add_options( array(
foreach ( $categories as $category ) :
'$category->cat_ID' => '$category->name'
endforeach;
) )
->set_required( true ),
]),
));
But it appears that looping within the add_options part doesn’t work at all.
Do you have an idea?
Thx for your precious help!
]]>Dear all,
I have created a complex carbon field ‘crb_subscription_elements’, adding user meta data to the user profile form into the back end, like this:
Container::make('user_meta', 'Subscription Type')
->add_fields(array(
Field::make('complex', 'crb_subscription_elements')
->add_fields('Subscription', array(
Field::make('radio', 'crb_subscription_type', 'Subscription Type')
->add_options(array(
'Paper' => 'Paper',
'Digital' => 'Digital',
'Paper_Digital' => 'Paper + Digital',
)),
Field::make('date_time', 'crb_request_subscription_date', 'Request date')
->set_timepicker_options(array(
'dateFormat' => 'dd-mm-yy',
'timeFormat' => 'HH:mm'
)),
Field::make('date_time', 'crb_subscription_activation_date', 'Activation date')
->set_timepicker_options(array(
'dateFormat' => 'dd-mm-yy',
'timeFormat' => 'HH:mm'
))
))
));
When a user check the ‘crb_subscription_type’ on the front-end, a carbon field is saved into wp_usermeta, but with empty ‘crb_subscription_activation_date’, and that is correct, since the admin has the capability to set the value of ‘crb_subscription_activation_date’ anytime. Moreover, the user can subscribe multiple subscriptions, one at year for instance, and the user-edit form will show multiple subscriptions.
When the admin opens the user form profile, he can set the ‘crb_subscription_activation_date’ of a subscription, and when he saves user profile, he should send and email to the user, telling the subscription has been activated in that date.
Here the problem: how it is possible to get $_POST[‘crb_subscription_activation_date’] from the user-edit form, in order to check if admin has set the activation date (and in case send the email to the user)?
I tried with the following code, but without success (I don’t get any $_POST[‘crb_subscription_activation_date’] value) :
$subscriptions = carbon_get_user_meta($user_id, ‘crb_subscription_elements’, ‘complex’);
foreach ($subscriptions as $subscription) {
foreach ($subscription as $key => $val) {
if ($key == 'crb_subscription_activation_date') {
$message = sprintf( __( 'Activation Date: %s ' ), $_POST['_crb_subscription_activation_date']) . "\r\n\r\n";
wp_mail( $admin_email, sprintf( __( '[From Admin] Subscription activated' ), get_option('blogname') ), $message );
// }
}
}
$_POST[‘_crb_subscription_activation_date’] does not return any value, I don’t have a clue… nether if the foreach loop is correct..
I hope I explained the problem crearly. Thanks in advance for any help.
]]>