Skip to content
This repository has been archived by the owner on May 4, 2023. It is now read-only.

Commit

Permalink
Fix json
Browse files Browse the repository at this point in the history
  • Loading branch information
Lu Nguyen committed Mar 29, 2023
1 parent bc837fe commit 5cabe4e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 40 deletions.
31 changes: 12 additions & 19 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ module.exports = (env, argv) => {
if (env != undefined && env.deploy) {
process.env = {
wwwDir: wwwDir,
projectname: projectname,
};
}

Expand All @@ -39,9 +38,8 @@ module.exports = (env, argv) => {
}),
new HtmlWebpackPlugin({
inject: false,
filename:
pluginPath + '/wp-content/plugins/' + process.env.projectname + '/includes/settings.php',
template: './wp-content/plugins/' + process.env.projectname + '/includes/settings.php',
filename: pluginPath + '/wp-content/plugins/' + projectname + '/includes/settings.php',
template: './wp-content/plugins/' + projectname + '/includes/settings.php',
minify: false,
}),

Expand All @@ -52,29 +50,24 @@ module.exports = (env, argv) => {
{
source: path.resolve(
__dirname,
'./wp-content/plugins/' + process.env.projectname + '/aesirx-bi.php'
'./wp-content/plugins/' + projectname + '/aesirx-bi.php'
),
destination:
pluginPath + '/wp-content/plugins/' + process.env.projectname + '/aesirx-bi.php',
destination: pluginPath + '/wp-content/plugins/' + projectname + '/aesirx-bi.php',
},
{
source: path.resolve(
__dirname,
'./wp-content/plugins/' + process.env.projectname + '/includes/dashboard.php'
'./wp-content/plugins/' + projectname + '/includes/dashboard.php'
),
destination:
pluginPath +
'/wp-content/plugins/' +
process.env.projectname +
'/includes/dashboard.php',
pluginPath + '/wp-content/plugins/' + projectname + '/includes/dashboard.php',
},
{
source: path.resolve(
__dirname,
'./node_modules/aesirx-bi-app/public/assets/images/'
),
destination:
pluginPath + '/wp-content/plugins/' + process.env.projectname + '/assets/images',
destination: pluginPath + '/wp-content/plugins/' + projectname + '/assets/images',
},
],
},
Expand All @@ -83,12 +76,12 @@ module.exports = (env, argv) => {

new WebpackAssetsManifest({
entrypoints: true,
publicPath: '/wp-content/plugins/' + process.env.projectname + '/',
publicPath: '/wp-content/plugins/' + projectname + '/',
}),
],
output: {
path: pluginPath + '/wp-content/plugins/' + process.env.projectname + '/',
publicPath: '/wp-content/plugins/' + process.env.projectname + '/',
path: pluginPath + '/wp-content/plugins/' + projectname + '/',
publicPath: '/wp-content/plugins/' + projectname + '/',
clean: true,
},

Expand Down Expand Up @@ -154,8 +147,8 @@ module.exports = (env, argv) => {
onEnd: {
archive: [
{
source: './dist/wp-content/plugins/' + process.env.projectname + '/',
destination: './dist/' + process.env.projectname + '.zip',
source: './dist/wp-content/plugins/' + projectname + '/',
destination: './dist/' + projectname + '.zip',
},
],
},
Expand Down
28 changes: 7 additions & 21 deletions wp-content/plugins/aesirx-bi/includes/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,12 @@ function ($value) {
echo '<p>' . __('Here you can set all the options for using the AesirX BI', 'aesirx-bi') . '</p>';
}, 'aesirx_bi_plugin');

add_settings_field('aesirx_bi_domain_react_app_client_id', __('REACT_APP_CLIENT_ID', 'aesirx-bi'), function () {
$options = get_option('aesirx_bi_plugin_options', []);
echo "<input id='aesirx_bi_domain' name='aesirx_bi_plugin_options[aesirx_bi_domain_react_app_client_id]' type='text' value='" . esc_attr($options['aesirx_bi_domain_react_app_client_id'] ?? '') . "' />";
}, 'aesirx_bi_plugin', 'aesirx_bi_settings');

add_settings_field('aesirx_bi_domain_react_app_client_secret', __('REACT_APP_CLIENT_SECRET', 'aesirx-bi'), function () {
$options = get_option('aesirx_bi_plugin_options', []);
echo "<input id='aesirx_bi_domain' name='aesirx_bi_plugin_options[aesirx_bi_domain_react_app_client_secret]' type='text' value='" . esc_attr($options['aesirx_bi_domain_react_app_client_secret'] ?? '') . "' />";
}, 'aesirx_bi_plugin', 'aesirx_bi_settings');

add_settings_field('aesirx_bi_domain_react_app_endpoint_url', __('REACT_APP_ENDPOINT_URL', 'aesirx-bi'), function () {
$options = get_option('aesirx_bi_plugin_options', []);
echo "<input id='aesirx_bi_domain' name='aesirx_bi_plugin_options[aesirx_bi_domain_react_app_endpoint_url]' type='text' value='" . esc_attr($options['aesirx_bi_domain_react_app_endpoint_url'] ?? '') . "' />";
}, 'aesirx_bi_plugin', 'aesirx_bi_settings');

add_settings_field('aesirx_bi_domain_react_app_license', __('REACT_APP_LICENSE', 'aesirx-bi'), function () {
$options = get_option('aesirx_bi_plugin_options', []);
echo "<input id='aesirx_bi_domain' name='aesirx_bi_plugin_options[aesirx_bi_domain_react_app_license]' type='text' value='" . esc_attr($options['aesirx_bi_domain_react_app_license'] ?? '') . "' />";
}, 'aesirx_bi_plugin', 'aesirx_bi_settings');

add_settings_field('aesirx_bi_domain_react_app_data_stream', __('REACT_APP_DATA_STREAM', 'aesirx-bi'), function () {
$options = get_option('aesirx_bi_plugin_options', []);

Expand Down Expand Up @@ -129,21 +115,21 @@ function () {

if (!empty($options['aesirx_bi_domain_react_app_data_stream'])) {
foreach ($options['aesirx_bi_domain_react_app_data_stream'] as $key => $data) {
$stream = new stdClass();
$stream->name = $data['name'];
$stream->domain = $data['domain'];
$stream = [];
$stream['name'] = $data['name'];
$stream['domain'] = $data['domain'];

$streams[] = $stream;
}
}
?>
<script>
window.env = {};
window.env.REACT_APP_CLIENT_ID = "<?php echo $options['aesirx_bi_domain_react_app_client_id'] ?>";
window.env.REACT_APP_CLIENT_SECRET = "<?php echo $options['aesirx_bi_domain_react_app_client_secret'] ?>";
window.env.REACT_APP_CLIENT_ID = "app";
window.env.REACT_APP_CLIENT_SECRET = "secret";
window.env.REACT_APP_ENDPOINT_URL = "<?php echo $options['aesirx_bi_domain_react_app_endpoint_url'] ?>";
window.env.REACT_APP_LICENSE = "<?php echo $options['aesirx_bi_domain_react_app_license'] ?>";
window.env.REACT_APP_DATA_STREAM = <?php echo json_encode($streams) ?>;
window.env.REACT_APP_LICENSE = "LICENSE";
window.env.REACT_APP_DATA_STREAM = JSON.stringify(<?php echo json_encode($streams) ?>);
window.env.PUBLIC_URL="/wp-content/plugins/aesirx-bi";

function addNewAesirxBISettingRow(){
Expand Down

0 comments on commit 5cabe4e

Please sign in to comment.