PluginProbe
MxChat – AI Chatbot & Content Generation for WordPress / 2.4.6
MxChat – AI Chatbot & Content Generation for WordPress v2.4.6
3.2.21 3.2.20 3.2.19 3.2.18 3.2.17 3.2.16 3.2.15 3.2.14 3.2.12 3.2.13 3.2.11 3.2.10 3.2.9 3.2.8 3.2.7 3.2.6 3.2.5 3.2.4 3.2.3 3.2.2 3.2.1 2.0.3 2.0.4 2.0.5 2.0.6 All 152 releases
← All changes | js/meta-box.js +105 -118 3.2.132.4.6 View file →
@@ -1,118 +1,105 @@
1 -(function() {
2 - if (typeof wp !== 'undefined' && wp.editPost && wp.components && wp.element) {
3 - var PluginDocumentSettingPanel = wp.editPost.PluginDocumentSettingPanel;
4 - var RadioControl = wp.components.RadioControl;
5 - var SelectControl = wp.components.SelectControl;
6 - var PanelRow = wp.components.PanelRow;
7 - var Notice = wp.components.Notice;
8 - var useSelect = wp.data.useSelect;
9 - var useDispatch = wp.data.useDispatch;
10 -
11 - function MxChatSettingsPanel() {
12 - var meta = useSelect(function(select) {
13 - return select('core/editor').getEditedPostAttribute('meta') || {};
14 - });
15 -
16 - var editPost = useDispatch('core/editor').editPost;
17 -
18 - // Determine effective visibility with backward compat
19 - var visibility = meta._mxchat_page_visibility || '';
20 - if (!visibility && meta._mxchat_hide_chatbot === '1') {
21 - visibility = 'hide';
22 - }
23 -
24 - var selectedBot = meta._mxchat_selected_bot || '';
25 -
26 - var elements = [];
27 -
28 - // Visibility radio control
29 - elements.push(
30 - wp.element.createElement(
31 - PanelRow,
32 - null,
33 - wp.element.createElement(RadioControl, {
34 - label: mxchatMetaBox.strings.visibilityLabel,
35 - selected: visibility,
36 - options: [
37 - { label: mxchatMetaBox.strings.useGlobalSetting, value: '' },
38 - { label: mxchatMetaBox.strings.showChatbot, value: 'show' },
39 - { label: mxchatMetaBox.strings.hideChatbot, value: 'hide' }
40 - ],
41 - onChange: function(value) {
42 - var newMeta = Object.assign({}, meta, {
43 - _mxchat_page_visibility: value,
44 - // Sync legacy field
45 - _mxchat_hide_chatbot: value === 'hide' ? '1' : ''
46 - });
47 - editPost({ meta: newMeta });
48 - }
49 - })
50 - )
51 - );
52 -
53 - // Info notice about global setting
54 - elements.push(
55 - wp.element.createElement(
56 - Notice,
57 - {
58 - status: 'info',
59 - isDismissible: false,
60 - className: 'mxchat-info-notice'
61 - },
62 - mxchatMetaBox.globalAutoshow
63 - ? mxchatMetaBox.strings.globalAutoshowOn
64 - : mxchatMetaBox.strings.globalAutoshowOff
65 - )
66 - );
67 -
68 - // Bot selection if multi-bot is available
69 - if (mxchatMetaBox.hasMultibot && mxchatMetaBox.availableBots) {
70 - var botOptions = [
71 - { label: mxchatMetaBox.strings.useDefaultBot, value: '' }
72 - ];
73 -
74 - Object.keys(mxchatMetaBox.availableBots).forEach(function(botId) {
75 - botOptions.push({
76 - label: mxchatMetaBox.availableBots[botId],
77 - value: botId
78 - });
79 - });
80 -
81 - if (botOptions.length > 1) {
82 - elements.push(
83 - wp.element.createElement(
84 - PanelRow,
85 - null,
86 - wp.element.createElement(SelectControl, {
87 - label: mxchatMetaBox.strings.selectBot,
88 - value: selectedBot,
89 - options: botOptions,
90 - onChange: function(value) {
91 - editPost({
92 - meta: Object.assign({}, meta, {
93 - _mxchat_selected_bot: value
94 - })
95 - });
96 - }
97 - })
98 - )
99 - );
100 - }
101 - }
102 -
103 - return wp.element.createElement(
104 - PluginDocumentSettingPanel,
105 - {
106 - name: 'mxchat-settings',
107 - title: mxchatMetaBox.strings.panelTitle,
108 - className: 'mxchat-settings-panel'
109 - },
110 - elements
111 - );
112 - }
113 -
114 - wp.plugins.registerPlugin('mxchat-settings', {
115 - render: MxChatSettingsPanel
116 - });
117 - }
118 -})();
1 +(function() {
2 + if (typeof wp !== 'undefined' && wp.editPost && wp.components && wp.element) {
3 + var PluginDocumentSettingPanel = wp.editPost.PluginDocumentSettingPanel;
4 + var CheckboxControl = wp.components.CheckboxControl;
5 + var SelectControl = wp.components.SelectControl;
6 + var PanelRow = wp.components.PanelRow;
7 + var Notice = wp.components.Notice;
8 + var useSelect = wp.data.useSelect;
9 + var useDispatch = wp.data.useDispatch;
10 +
11 + function MxChatSettingsPanel() {
12 + var meta = useSelect(function(select) {
13 + return select('core/editor').getEditedPostAttribute('meta') || {};
14 + });
15 +
16 + var editPost = useDispatch('core/editor').editPost;
17 + var hideChatbot = meta._mxchat_hide_chatbot === '1';
18 + var selectedBot = meta._mxchat_selected_bot || '';
19 +
20 + // Bot options will be populated from localized data
21 + var botOptions = [
22 + { label: mxchatMetaBox.strings.useGlobalSetting, value: '' }
23 + ];
24 +
25 + if (mxchatMetaBox.hasMultibot && mxchatMetaBox.availableBots) {
26 + Object.keys(mxchatMetaBox.availableBots).forEach(function(botId) {
27 + botOptions.push({
28 + label: mxchatMetaBox.availableBots[botId],
29 + value: botId
30 + });
31 + });
32 + }
33 +
34 + var elements = [
35 + wp.element.createElement(
36 + PanelRow,
37 + null,
38 + wp.element.createElement(CheckboxControl, {
39 + label: mxchatMetaBox.strings.hideChatbot,
40 + help: mxchatMetaBox.strings.hideChatbotHelp,
41 + checked: hideChatbot,
42 + onChange: function(value) {
43 + editPost({
44 + meta: Object.assign({}, meta, {
45 + _mxchat_hide_chatbot: value ? '1' : ''
46 + })
47 + });
48 + }
49 + })
50 + )
51 + ];
52 +
53 + // Add bot selection if multi-bot is available
54 + if (mxchatMetaBox.hasMultibot && botOptions.length > 1) {
55 + elements.push(
56 + wp.element.createElement(
57 + PanelRow,
58 + null,
59 + wp.element.createElement(SelectControl, {
60 + label: mxchatMetaBox.strings.selectBot,
61 + value: selectedBot,
62 + options: botOptions,
63 + onChange: function(value) {
64 + editPost({
65 + meta: Object.assign({}, meta, {
66 + _mxchat_selected_bot: value
67 + })
68 + });
69 + }
70 + })
71 + )
72 + );
73 +
74 + // Add info notice
75 + elements.push(
76 + wp.element.createElement(
77 + Notice,
78 + {
79 + status: 'info',
80 + isDismissible: false,
81 + className: 'mxchat-info-notice'
82 + },
83 + mxchatMetaBox.globalAutoshow
84 + ? mxchatMetaBox.strings.globalAutoshowOn
85 + : mxchatMetaBox.strings.globalAutoshowOff
86 + )
87 + );
88 + }
89 +
90 + return wp.element.createElement(
91 + PluginDocumentSettingPanel,
92 + {
93 + name: 'mxchat-settings',
94 + title: mxchatMetaBox.strings.panelTitle,
95 + className: 'mxchat-settings-panel'
96 + },
97 + elements
98 + );
99 + }
100 +
101 + wp.plugins.registerPlugin('mxchat-settings', {
102 + render: MxChatSettingsPanel
103 + });
104 + }
105 +})();