{"id":8894,"date":"2022-12-28T13:01:57","date_gmt":"2022-12-28T13:01:57","guid":{"rendered":"https:\/\/i-wp-dev.com\/?p=8894"},"modified":"2022-12-28T19:09:45","modified_gmt":"2022-12-28T19:09:45","slug":"sozdanie-plugin-dlya-wordpress-chast-2-sozdanie-custom-post-type-i-carbone-fields-dlya-straniczy-avto","status":"publish","type":"post","link":"https:\/\/i-wp-dev.com\/ru\/sozdanie-plugin-dlya-wordpress-chast-2-sozdanie-custom-post-type-i-carbone-fields-dlya-straniczy-avto\/","title":{"rendered":"\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 Plugin \u0434\u043b\u044f WordPress \u0447\u0430\u0441\u0442\u044c 2. \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 Custom Post type \u0438 Carbone Fields \u0434\u043b\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0430\u0432\u0442\u043e."},"content":{"rendered":"\n
\u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u043d\u0430\u0448 \u043a\u043b\u0430\u0441\u0441 AddCPT.php<\/strong><\/p>\n\n\n\n \u041f\u0435\u0440\u0432\u043e\u0435 \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e init<\/p>\n\n\n\n \u041f\u0435\u0440\u0432\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0442\u043e, \u043a\u043e\u0433\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u043d\u0430 \u043d\u0430\u0448\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f. \u0414\u0430\u043b\u044c\u0448\u0435 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043f\u0435\u0440\u0432\u044b\u0439 \u0438\u0437 \u043d\u0438\u0445 $this<\/strong> \u044d\u0442\u043e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043d\u0430\u0448\u0435\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0433\u0434\u0435 \u0438\u0441\u043a\u0430\u0442\u044c \u043d\u0430\u0448\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u0434\u0430\u043b\u044c\u0448\u0435 \u0438\u0434\u0435\u0442 \u0438\u043c\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438. <\/p>\n\n\n\n \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448 \u043d\u043e\u0432\u044b\u0439 \u0442\u0438\u043f \u0437\u0430\u043f\u0438\u0441\u0438 \u0410\u0432\u0442\u043e. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e register_<\/strong>post_<\/strong>type <\/strong>\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0435\u043c\u0443 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b<\/p>\n\n\n\n \u0412\u043e\u0442 \u043a\u043e\u0434 \u043d\u0430\u0448\u0435\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/p>\n\n\n\n menu_position<\/em> \u2013 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043d\u0430\u043c \u043c\u0435\u043d\u044f\u0442\u044c \u043f\u043e\u0437\u0438\u0446\u0438\u044e \u0432 \u043c\u0435\u043d\u044e \u0432\u043e\u0440\u0434\u043f\u0440\u0435\u0441\u0441<\/p>\n\n\n\n menu_icon<\/em> \u2013 \u0412\u044b\u0432\u043e\u0434\u0438\u0442 \u0438\u043a\u043e\u043d\u043a\u0443<\/p>\n\n\n\n supports<\/em> — \u0422\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u044b [ ‘title’, ‘editor’, ‘thumbnail’, ‘excerpt’, ‘custom-fields’, ‘revisions’ ]<\/em><\/p>\n\n\n\n has_archive<\/em> \u2013 \u0411\u0443\u0434\u0435\u0442 \u043b\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0430\u0440\u0445\u0438\u0432 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 <\/p>\n\n\n\n \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0435\u0449\u0435 \u043e\u0434\u0438\u043d Action \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e init<\/em><\/p>\n\n\n\n \u0412\u0441\u0435 \u0442\u0430\u043a \u0436\u0435, \u043a\u0430\u043a \u0438 \u0441 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435\u043c \u043d\u043e\u0432\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0437\u0430\u043f\u0438\u0441\u0438 c\u043e\u0437\u0434\u0430\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u0432 \u043d\u0435\u0439 register_taxonomy <\/strong>\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0432 \u043d\u0435\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b<\/p>\n\n\n\n \u0422\u0430\u043a \u0436\u0435 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0435\u0449\u0435 \u043e\u0434\u043d\u0443 taxonomy<\/strong> \u0434\u043b\u044f \u043e\u0431\u044a\u0451\u043c\u0430 \u0434\u0432\u0438\u0433\u0430\u0442\u0435\u043b\u044f \u044f \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u044e \u0435\u0449\u0435 \u043e\u0434\u043d\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0442\u0430\u043a \u0431\u0443\u0434\u0435\u0442 \u043b\u0435\u0433\u0447\u0435 \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0438\u043b\u0438 \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u043a\u0441\u043e\u043d\u043e\u043c\u0438\u0438. \u0418 \u0442\u0430\u043a \u0434\u0435\u043b\u0430\u0435\u043c \u0432\u0441\u0435 \u043f\u043e \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0438<\/p>\n\n\n\n \u0412\u043e\u0442 \u043f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u043d\u0430\u0448\u0435\u0433\u043e \u0444\u0430\u0439\u043b\u0430: https:\/\/gitlab.com\/AlsconWeb\/ease-car-listing\/-\/blob\/25ed13774bf667a8cb553a947be13cda08a403c7\/src\/php\/CPT\/AddCPT.php<\/a><\/p>\n\n\n\n \u041c\u044b \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u0444\u0430\u0439\u043b\u0443 CarboneFields.php<\/strong><\/p>\n\n\n\n \u041f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043a\u043b\u0430\u0441\u0441 Carbone Fields \u0447\u0442\u043e \u0431\u044b \u043e\u043d \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u043b \u0432\u0441\u0435 \u0441\u0432\u043e\u0438 \u043a\u043b\u0430\u0441\u0441\u044b.<\/p>\n\n\n\n \u0412 \u0444\u0443\u043d\u043a\u0446\u0438\u044e init \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c action<\/p>\n\n\n\n \u041d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u044d\u0442\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043d\u0430 \u0445\u0443\u043a after_setup_theme<\/em> \u0438 \u0432\u0441\u0435 \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0432 \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u044d\u0442\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u0442\u0430\u0442\u0438\u0447\u043d\u044b\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u044e Boot<\/p>\n\n\n\n \u043a\u043e\u0434 \u043d\u0430\u0448\u0435\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n\n\n\n \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u0430\u043c\u0438 \u043f\u043e\u043b\u044f \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u0435\u043d action \u043e\u0442 carbon fields carbon_fields_register_fields<\/em> <\/p>\n\n\n\n \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u044f. \u0414\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u043e\u043b\u0435\u0439 \u0432 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0432\u043e\u0442 \u0442\u0430\u043a<\/p>\n\n\n\n \u041f\u0435\u0440\u0432\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0442\u0438\u043f \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u0432\u0442\u043e\u0440\u043e\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0435\u0433\u043e \u0438\u043c\u044f<\/p>\n\n\n\n \u0414\u0430\u043b\u044c\u0448\u0435 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c, \u0430 \u0433\u0434\u0435 \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c \u044d\u0442\u0438 \u043f\u043e\u043b\u044f, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e where<\/strong> \u0433\u0434\u0435 \u043f\u0435\u0440\u0432\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c post_format, post_id, post_level, post_parent_id, post_ancestor_id, post_template, post_term, post_type<\/em><\/p>\n\n\n\n \u0412\u0442\u043e\u0440\u043e\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0442\u043e \u043a\u0430\u043a \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0438 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c post_type<\/strong> \u0438 \u0443\u043a\u0430\u0436\u0435\u043c \u043d\u0430\u0448 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u043e\u0441\u0442 \u0437\u0430\u043f\u0438\u0441\u0438<\/p>\n\n\n\n \u042f \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u0431\u044b \u0447\u0442\u043e \u0431\u044b \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u0432\u0438\u0434\u044b \u043f\u043e\u043b\u0435\u0439 \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e add_tab<\/em> \u0443 \u043d\u0435\u0435 \u0435\u0441\u0442\u044c 2 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430. \u041f\u0435\u0440\u0432\u044b\u0439 \u044d\u0442\u043e \u0438\u043c\u044f \u0442\u0430\u0431\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0430 \u0444\u0440\u043e\u043d\u0442 \u0438 \u0432\u0442\u043e\u0440\u043e\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u2014 \u044d\u0442\u043e \u043c\u0430\u0441\u0441\u0438\u0432 \u043f\u043e\u043b\u0435\u0439 carbon fields. <\/p>\n\n\n\n \u0418\u0442\u0430\u043a, \u043f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u044d\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432\u044b\u0448\u0435\u043b \u0443 \u043c\u0435\u043d\u044f \u0442\u0430\u043a\u043e\u0439. \u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0438 \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u0432\u044b \u0432\u0441\u0435\u0433\u0434\u0430 \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u0434\u0430\u0442\u044c \u0432\u043e\u043f\u0440\u043e\u0441 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445 \u043f\u043e\u0434 \u0432\u0438\u0434\u0435\u043e.<\/p>\n\n\n\n \u041a\u043e\u0434 \u0432\u0441\u0435\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u0432\u044b \u0432\u0441\u0435\u0433\u0434\u0430 \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0439\u0442\u0438 \u0442\u0443\u0442: https:\/\/gitlab.com\/AlsconWeb\/ease-car-listing\/-\/commit\/ee77a1cb22d2135f5bbeccdf26f9d37fb934b7c0#9ef8bcfcbdaab0d19e056f80ce0cc3d3c362c61f<\/a><\/p>\n\n\n\nadd_action( 'init', [ $this, 'register_post_auto' ] );<\/code><\/pre>\n\n\n\n
\/**
\n * Register CPT Auto.
\n *
\n * @return <\/strong>void
\n *\/
\n<\/em>public function register_post_auto(): void {
\n register_post_type(
\n 'cars',
\n [
\n 'label' => null,
\n 'labels' => [
\n 'name' => __( 'Cars', 'ease-car-listing' ),
\n 'singular_name' => __( 'Car', 'ease-car-listing' ),
\n 'add_new' => __( 'Add car', 'ease-car-listing' ),
\n 'add_new_item' => __( 'Adding a car', 'ease-car-listing' ),
\n 'edit_item' => __( 'Car editing', 'ease-car-listing' ),
\n 'new_item' => __( 'New car', 'ease-car-listing' ),
\n 'view_item' => __( 'View car', 'ease-car-listing' ),
\n 'search_items' => __( 'Search car', 'ease-car-listing' ),
\n 'not_found' => __( 'Not found', 'ease-car-listing' ),
\n 'not_found_in_trash' => __( 'Not found in cart', 'ease-car-listing' ),
\n 'menu_name' => __( 'Cars', 'ease-car-listing' ),
\n ],
\n 'description' => '',
\n 'public' => true,
\n 'show_in_rest' => null,
\n 'rest_base' => null,
\n 'menu_position' => 30,
\n 'menu_icon' => 'dashicons-car',
\n 'hierarchical' => false,
\n 'supports' => [ 'title', 'editor', 'thumbnail', 'excerpt', 'custom-fields', 'revisions' ],
\n 'taxonomies' => [ 'cars' ],
\n 'has_archive' => true,
\n 'rewrite' => true,
\n 'query_var' => true,
\n ]
\n );
\n}<\/code><\/pre>\n\n\n\n\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 Custom Taxonomy<\/h3>\n\n\n\n
add_action( 'init', [ $this, 'register_tax_mark' ] );<\/code><\/pre>\n\n\n\n
\/**\n * Register taxonomy mark & models.\n *\n * @return void\n *\/\npublic function register_tax_mark(): void {\n register_taxonomy(\n 'mark',\n [ 'cars' ],\n [\n 'label' => '',\n 'labels' => [\n 'name' => __( 'Marks & Models', 'ease-car-listing' ),\n 'singular_name' => __( 'Marks & Models', 'ease-car-listing' ),\n 'search_items' => __( 'Search Mark', 'ease-car-listing' ),\n 'all_items' => __( 'All Marks & Models', 'ease-car-listing' ),\n 'view_item ' => __( 'View Marks', 'ease-car-listing' ),\n 'parent_item' => __( 'Marks', 'ease-car-listing' ),\n 'parent_item_colon' => __( 'Models', 'ease-car-listing' ),\n 'edit_item' => __( 'Edit Marks & Models', 'ease-car-listing' ),\n 'update_item' => __( 'Update Marks & Models', 'ease-car-listing' ),\n 'add_new_item' => __( 'Add New', 'ease-car-listing' ),\n 'new_item_name' => __( 'New Marks & Models', 'ease-car-listing' ),\n 'menu_name' => __( 'Marks & Models', 'ease-car-listing' ),\n 'back_to_items' => __( '\u2190 Back to Marks & Models', 'ease-car-listing' ),\n ],\n 'description' => __( 'The main category is the brand of the car, the child category will be the model.', 'ease-car-listing' ),\n 'public' => true,\n 'hierarchical' => true,\n 'rewrite' => true,\n 'capabilities' => [],\n 'show_admin_column' => true,\n ] );\n}\n<\/code><\/pre>\n\n\n\n
\/**\n * Register taxonomy engine.\n *\n * @return void\n *\/\npublic function register_tax_engine(): void {\n register_taxonomy(\n 'engine',\n [ 'cars' ],\n [\n 'label' => '',\n 'labels' => [\n 'name' => __( 'Engine', 'ease-car-listing' ),\n 'singular_name' => __( 'Engine', 'ease-car-listing' ),\n 'search_items' => __( 'Search Engine', 'ease-car-listing' ),\n 'all_items' => __( 'All Engine', 'ease-car-listing' ),\n 'view_item ' => __( 'View Engine', 'ease-car-listing' ),\n 'parent_item' => __( 'Parens Engine', 'ease-car-listing' ),\n 'parent_item_colon' => __( 'Parent', 'ease-car-listing' ),\n 'edit_item' => __( 'Edit Engine', 'ease-car-listing' ),\n 'update_item' => __( 'Update Engine', 'ease-car-listing' ),\n 'add_new_item' => __( 'Add New', 'ease-car-listing' ),\n 'new_item_name' => __( 'New Engine', 'ease-car-listing' ),\n 'menu_name' => __( 'Engine', 'ease-car-listing' ),\n 'back_to_items' => __( '\u2190 Back to Engine', 'ease-car-listing' ),\n ],\n 'description' => '',\n 'public' => true,\n 'hierarchical' => true,\n 'rewrite' => true,\n 'capabilities' => [],\n 'show_admin_column' => true,\n ] );\n}\n<\/code><\/pre>\n\n\n\n
\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u043e\u043b\u0435\u0439 \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u0442\u0438\u043f\u0430 \u0437\u0430\u043f\u0438\u0441\u0438 \u0430\u0432\u0442\u043e<\/h3>\n\n\n\n
add_action( 'after_setup_theme', [ $this, 'carbon_fields_init' ] ); <\/code><\/pre>\n\n\n\n
Carbon_Fields::boot<\/em>();<\/code><\/pre>\n\n\n\n
\/**\n * Carbone field init.\n *\n * @return void\n *\/\npublic function carbon_fields_init(): void {\n Carbon_Fields::boot();\n}\n<\/code><\/pre>\n\n\n\n
add_action( 'carbon_fields_register_fields', [ $this, 'add_carbone_fields_to_cars' ] );<\/code><\/pre>\n\n\n\n
Container::make( 'post_meta', __( 'Vehicle parameters', 'ease-car-listing' ) )<\/code><\/pre>\n\n\n\n
'='<\/code>,
'!='<\/code>,
'>'<\/code>,
'>='<\/code>,
'<'<\/code>,
'<='<\/code>,
'IN'<\/code>,
'NOT IN'<\/code>,
'CUSTOM'<\/code><\/em>
\u0411\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e \u044d\u0442\u0438\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u0445 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u043a CarboneFields.<\/code><\/p>\n\n\n\n
->where( 'post_type', '=', 'cars' )<\/code><\/pre>\n\n\n\n
\/**\n * Add Carbon fields to CPT cars\n *\n * @return void\n *\/\npublic function add_carbone_fields_to_cars(): void {\n Container::make( 'post_meta', __( 'Vehicle parameters', 'ease-car-listing' ) )\n ->where( 'post_type', '=', 'cars' )\n ->add_tab(\n __( 'General', 'ease-car-listing' ),\n [\n Field::make( 'text', 'ecl_vin', __( 'Vin number', 'ease-car-listing' ) )->set_width( 50 ),\n Field::make( 'text', 'ecl_stock_number', __( 'Stock number', 'ease-car-listing' ) )\n ->set_width( 50 ),\n Field::make( 'text', 'ecl_car_mileage', __( '\u0421ar mileage', 'ease-car-listing' ) )\n ->set_width( 50 ),\n Field::make( 'select', 'ecl_body_type', __( 'Body type', 'ease-car-listing' ) )\n ->add_options(\n [\n 'compact' => __( 'Compact', 'ease-car-listing' ),\n 'sedan' => __( 'Sedan', 'ease-car-listing' ),\n 'coupe' => __( 'Coupe', 'ease-car-listing' ),\n 'hatchback' => __( 'Hatchback', 'ease-car-listing' ),\n 'kombi' => __( 'Kombi', 'ease-car-listing' ),\n 'limousine' => __( 'Limousine', 'ease-car-listing' ),\n 'microvan' => __( 'Microvan', 'ease-car-listing' ),\n 'minivan' => __( 'Minivan', 'ease-car-listing' ),\n 'pickup' => __( 'Pickup', 'ease-car-listing' ),\n 'roadster' => __( 'Roadster', 'ease-car-listing' ),\n 'suv' => __( 'SUV', 'ease-car-listing' ),\n 'wagon' => __( 'Wagon', 'ease-car-listing' ),\n 'pickup_track' => __( 'Pickup track', 'ease-car-listing' ),\n 'van' => __( 'Van', 'ease-car-listing' ),\n ]\n )->set_width( 50 ),\n Field::make( 'select', 'ecl_fuel_type', __( 'Fuel type', 'ease-car-listing' ) )\n ->add_options(\n [\n 'gas' => __( 'Gas', 'ease-car-listing' ),\n 'diesel' => __( 'Diesel', 'ease-car-listing' ),\n 'electric' => __( 'Electric', 'ease-car-listing' ),\n ]\n )->set_width( 50 ),\n Field::make( 'text', 'ecl_car_year', __( 'Vehicle year', 'ease-car-listing' ) )\n ->set_width( 50 ),\n Field::make( 'text', 'ecl_horsepower', __( 'Vehicle Horsepower', 'ease-car-listing' ) )\n ->set_width( 50 )\n ->set_attribute( 'type', 'number' ),\n Field::make( 'text', 'ecl_body_color', __( 'Body color', 'ease-car-listing' ) )\n ->set_width( 50 ),\n Field::make( 'text', 'ecl_interior_color', __( 'Interior color', 'ease-car-listing' ) )\n ->set_width( 50 ),\n Field::make( 'text', 'ecl_number_of_airbags', __( 'Number of airbags', 'ease-car-listing' ) )\n ->set_width( 50 )\n ->set_attribute( 'type', 'number' ),\n Field::make( 'text', 'ecl_number_of_seats', __( 'Number of seats', 'ease-car-listing' ) )\n ->set_width( 50 )\n ->set_attribute( 'type', 'number' ),\n Field::make( 'text', 'ecl_number_of_doors', __( 'Number of doors', 'ease-car-listing' ) )\n ->set_width( 50 )\n ->set_attribute( 'type', 'number' ),\n ]\n )\n ->add_tab(\n __( 'Additional Information', 'ease-car-listing' ),\n [\n Field::make( 'rich_text', 'ecl_additional_info', __( 'Additional Information', 'ease-car-listing' ) ),\n ]\n )\n ->add_tab(\n __( 'Gallery', 'ease-car-listing' ),\n [\n Field::make( 'media_gallery', 'ecl_gallery', __( 'Gallery', 'ease-car-listing' ) )\n ->set_type(\n [\n 'image',\n 'video',\n ]\n ),\n ]\n )\n ->add_tab(\n __( 'Price', 'ease-car-listing' ),\n [\n Field::make( 'text', 'ecl_price', __( 'Price', 'ease-car-listing' ) )->set_width( 30 ),\n Field::make( 'text', 'ecl_sales_price', __( 'Sales price', 'ease-car-listing' ) )\n ->set_width( 30 ),\n Field::make( 'text', 'ecl_by_month', __( 'Price per month', 'ease-car-listing' ) )\n ->set_width( 30 ),\n ]\n );\n}\n<\/code><\/pre>\n\n\n\n