F
F
fsgdoterr2021-10-25 21:37:25
WordPress
fsgdoterr, 2021-10-25 21:37:25

Where can I find proper documentation or guide on carbon fields?

For the last 4 hours ****** in order to display the fields in a separate menu in the admin panel, when I created a new container in functions, the plugin broke, although it did everything as in the documentation:

$id = Container::make( 'theme_options', 'Какое-то название' )
    ->add_fields( array( 
        Field::make('text', 'header_title', 'Заголовок')
     ) );

    Container::make( 'theme_options', 'Другое название' )
        ->set_page_parent( $id )
        ->add_fields( array( 
            Field::make('text', 'another_title', 'Второй Заголовок')
        ) );


as a result, this code displayed this:
6176f645adafb652355416.png
as you can see, in the 'Some name' menu there is no second sub-item 'Other name', but just the second container was glued to the first one, and crookedly, the buttons to save changes do not work and near the first block with this button you can see what then the title, but after 4 hours of studying the official documentation, wp-kama, and just trying to fix everything by typing, I still succeeded, the problem was that the second argument in the make method in the container, the transmitted title of the container must be in English, and as soon as I entered the English title there, everything looked like this:
6176f7af216dd439545033.png
a submenu of the second container appeared in the menu, the save changes button worked, and everything is generally in its place and the plugin works.
After that I have two questions:
1. Where can I find good documentation? after all, nothing was written in the official one about the need to write the title of the container in English letters (the second question is related to this), and there is nothing about it on the vp kama.
2. Although everything worked with English letters, BUT in the vids for this plugin in the Russian-speaking community, everyone puts the title in Russian and everything works fine for them, and from the box, that is, they don’t have any other plugins that expand this one, and actually why so, am I really so crooked, or special that my plug-in with Russian titles broke down?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artem Zolin, 2021-10-25
@artzolin

Carbon fields have super clear documentation

To change the location of your Theme Options page, you use set_page_parent($parent) , where $parent is either:
  • Title of a top level Theme Options page.
  • Identifier of a top level menu section in the admin menu sidebar. This corresponds to the $parent_slug parameter of add_submenu_page() . You can see all predefined page parents here.

Russian-language characters in the code are generally bad manners, if these people write shitty code, then it is not necessary to be equal to them. All Russian-language lines in the code should be written correctly using the __(), _e(), esc_html__()and functions esc_html_e()in English and translate the topic using loco translate or poedit

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question