WP Elementor Choose Control Prefix Class Prefixed %s String Format - wordpress

I am having trouble with elementor prefix class using with CHOOSE control
Here is code snippet
$this->add_responsive_control(
'course_author_layout',
[
'label' => __('Layout', 'text-domain'),
'type' => Controls_Manager::CHOOSE,
'options' => [
'left' => [
'title' => __('Left', 'text-domain'),
'icon' => 'fa fa-long-arrow-left',
],
'up' => [
'title' => __('Center', 'text-domain'),
'icon' => 'fa fa-long-arrow-up',
],
],
'prefix_class' => 'etlms-author-layout-%s',
'default' => 'left',
]
);
Problem is here in prefix_class. In the HTML Markup prefix class is showing with %s but there should only show value.
Current scenario of class : etlms-author-layout-%sleft
Expected result of class : etlms-author-layout-left

Just remove the %s, then you will get the expected result.

Related

How to customize the title and tooltip in ux-chartjs?

I made a chart with Symfony UX and chartJs. Everything works but when I want to customize it, it become a problem and I can't find a good docs for that.
My chart is done and now I want to customize the tooltip and the title, I did like that :
$chart->setOptions([
'responsive' => true,
'title' => [
'display' => true,
'text' => 'test',
'color' => '#ce1111',
],
'tooltips' => [
'backgroundColor' => '#ce1111',
'titleColor' => '#000'
]
]);
For the title, it displays 'test' but the color doesn't work even if I replace it with titleColor.
For tooltips the backgroundColor works but not the titleColor.
Anyone has already solved this problem ?
I found it, sorry for the question but the docs is different. I post here how I dit it :
$chart->setOptions([
'responsive' => true,
'title' => [
'display' => true,
'text' => strtoupper('test'),
'fontColor' => '#ce1111',
'fontSize' => 16
//'padding' => 50
],
'tooltips' => [
'backgroundColor' => '#fff',
'bodyFontColor' => '#000',
'bodyFontSize' => 16,
],
'legend' => [
'labels' => [
'fontColor' => "#ce1111",
'fontSize' => 16
]
]
]);

Translations are not saved correctly using A2lix Translation + KnpLabs DoctrineBehaviors

In my Symfony project I use SonataAdminBundle and A2lixTranslationForm + KnpLabsDoctrineBehaviors bundles for multi-language support.
I have Serial and Episode entities which use standard OneToMany and ManyToOne relationship. I display episodes using sonata_type_collection:
->add('episodes', 'sonata_type_collection', [
'by_reference' => false,
],
[
'edit' => 'inline',
'inline' => 'table',
]
)
By default A2lixTranslation bundle displays translatable fields under each other. However, I need to display each translation field of the episode in its own column. In order to achieve this, I created three virtual fields with the same property_path:
->add('episode_title', 'a2lix_translations', [
'property_path' => 'translations',
'fields' => [
'title' => [
'attr' => [
'pattern' => false,
],
'label' => false,
],
],
'exclude_fields' => ['subTitle', 'description'],
'label' => 'Title',
])
->add('episode_subtitle', 'a2lix_translations', [
'property_path' => 'translations',
'fields' => [
'subTitle' => [
'label' => false,
],
],
'exclude_fields' => ['title', 'description'],
'label' => 'Subtitle',
'required' => false,
])
->add('episode_description', 'a2lix_translations', [
'property_path' => 'translations',
'fields' => [
'description' => [
'field_type' => 'textarea',
'label' => false,
],
],
'exclude_fields' => ['title', 'subTitle'],
'label' => 'Description',
'required' => false,
])
As you can see, I display only one field in each a2lix_translations form.
But I faced the following problem: only the last field value (description in this case) is saved when I add new episode using Add new button of the collection form and then clicking Update button of the parent (Serial) form. Wherein already existing episodes are saved correctly if edited.
Could you please point me why is this happening and how to fix the issue. I suppose each translations form values rewrite the previous ones, but why do this work normally when saving existing records?
Or maybe there is another way to display each field in the own column in sonata collection form, this also will be helpful.
Thank you.

TYPO3: tx-news - localize tag, render tags multilingual, missing step

I use tx-news in a multilingual site and need to have the tags localized, (scripted from a custom extension):
1) first step: add the fields to the table:
ext_tables.sql :
#
# Extend table structure of table 'tx_news_domain_model_tag'
#
CREATE TABLE tx_news_domain_model_tag (
sys_language_uid int(11) DEFAULT '0' NOT NULL,
l10n_parent int(11) DEFAULT '0' NOT NULL,
l10n_diffsource mediumblob
);
2) second step: TCA override tag (now fully working, added 'allLanguages' selection as suggested by ralph)
Configuration/TCA/Overrides/tx_news_domain_model_tag.php
<?php
defined('TYPO3_MODE') or die();
/**
* Add multilingual to tx_news_domain_model_tag
*/
$temporaryColumns = [
'sys_language_uid' => [
'exclude' => 1,
'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.language',
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'special' => 'languages',
'items' => [
[
'LLL:EXT:lang/locallang_general.xlf:LGL.allLanguages',
-1,
'flags-multiple'
],
],
'default' => 0,
],
],
'l10n_parent' => [
'displayCond' => 'FIELD:sys_language_uid:>:0',
'exclude' => 1,
'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.l18n_parent',
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'items' => [
['', 0],
],
'foreign_table' => 'tx_news_domain_model_tag',
'foreign_table_where' => 'AND tx_news_domain_model_tag.pid=###CURRENT_PID### AND tx_news_domain_model_tag.sys_language_uid IN (-1,0)',
],
],
'l10n_diffsource' => [
'config' => [
'type' => 'passthrough',
],
],
];
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns(
'tx_news_domain_model_tag',
$temporaryColumns
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addFieldsToPalette(
'tx_news_domain_model_tag',
'paletteCore',
'sys_language_uid, l10n_parent, l10n_diffsource',
'before:hidden'
);
/* ADDED MISSING SYNTAX AFTER PAUL'S ANSWER */
$GLOBALS['TCA']['tx_news_domain_model_tag']['ctrl']['languageField'] = 'sys_language_uid';
$GLOBALS['TCA']['tx_news_domain_model_tag']['ctrl']['transOrigPointerField'] = 'l10n_parent';
$GLOBALS['TCA']['tx_news_domain_model_tag']['ctrl']['transOrigDiffSourceField'] = 'l10n_diffsource';
3) third step: TCA override news to limit tags to the language
Configuration/TCA/Overrides/tx_news_domain_model_news.php
/**
* Add This to the original **`tags`** column
*/
...
'foreign_table_where' => ' AND tx_news_domain_model_tag.sys_language_uid IN (-1, 0) ORDER BY tx_news_domain_model_tag.title',
...
4) fourth step: add the localization to the TCA of tx_news_domain_model_tag (added paul's answer to step 2, this is NOT missing anymore)
the following should be added but I don't know how ... (from a custom extension, I obviously can add it directly within 'news')
'ctrl' => [
'languageField' => 'sys_language_uid',
'transOrigPointerField' => 'l10n_parent',
'transOrigDiffSourceField' => 'l10n_diffsource'
],
Did you try just to override it in the TCA array inside your Overrides/tx_news_domain_model_tag.php like this?
$GLOBALS['TCA']['tx_news_domain_model_tag']['ctrl']['languageField'] = 'sys_language_uid';
$GLOBALS['TCA']['tx_news_domain_model_tag']['ctrl']['transOrigPointerField'] = 'l10n_parent';
$GLOBALS['TCA']['tx_news_domain_model_tag']['ctrl']['transOrigDiffSourceField'] = 'l10n_diffsource';
... just one small addition. To get the option "All" in the language selector you have to change the array sys_language_uid in Configuration/TCA/Overrides/tx_news_domain_model_tag.php like this
...
'sys_language_uid' => [
'exclude' => 1,
'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.language',
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'special' => 'languages',
'items' => [
[
'LLL:EXT:lang/locallang_general.xlf:LGL.allLanguages',
-1,
'flags-multiple'
],
],
'default' => 0,
],
],
...

Woocommerce REST API how send custom meta?

Woocommerce not send meta with custom plug-ins in format .json.
What should I add to the file functions.php?
How to forcibly compel him to send some meta?
Sorry for such a simple question, but I have not found a solution for spaces google
Send the following payload to the API:
$data = [
'name' => 'Product Name',
'type' => 'simple',
'regular_price' => '19.95',
'description' => 'Simple Product,
'categories' => [
['id' => 1]
],
'virtual' => true,
'reviews_allowed' => false,
'meta_data' => [
[
'key' => '_custom_meta_1',
'value' => 'value1'
],
[
'key' => '_custom_meta_2',
'value' => 'value2'
]
]
];
the "meta_data" field, should be an array, containing arrays with "key" and "value" attributes.

Display data attributes in collection field Symfony 2

I have 2 fields in my form. First Name and Email.
$builder->add('firstName', 'text', [
'label' => 'First Name',
'required' => true,
'attr' => [
'data-msg-required' => 'First name is required'
],
'trim' => true])
->add('emails', 'collection', [
'type' => new RegisterEmail,
'required' => true,
'by_reference' => false,
'label' => false,
'options' => [
'attr' => [
'data-msg-required' => 'Email is required'
]
],
]);
However data-msg required is only displayed for first field but not for second one. I know I can add that directly in twig template but is there anyway I can achieve that through form class only.
You should add it to the default value of the RegisterEmail type, with setDefaults()

Resources