Skip to content

Commit

Permalink
release: fixes
Browse files Browse the repository at this point in the history
- Updated dependencies
- Enhanced security
  • Loading branch information
vytisbulkevicius authored Nov 7, 2024
2 parents b1c71ac + 8609f98 commit 81f0299
Show file tree
Hide file tree
Showing 19 changed files with 6,488 additions and 13,834 deletions.
5 changes: 3 additions & 2 deletions .distignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ artifact
composer.json
composer.lock
package-lock.json
vendor/phpoffice/phpspreadsheet/samples
vendor/phpoffice/phpspreadsheet/docs
vendor/openspout/openspout/LICENSE-for-*
vendor/openspout/openspout/UPGRADE-3.0.md
vendor/openspout/openspout/README.md
cypress
cypress.json
.github
Expand Down
3 changes: 1 addition & 2 deletions classes/Visualizer/Gutenberg/build/block.css

Large diffs are not rendered by default.

260 changes: 1 addition & 259 deletions classes/Visualizer/Gutenberg/build/block.js

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions classes/Visualizer/Gutenberg/build/handsontable.css

Large diffs are not rendered by default.

44 changes: 1 addition & 43 deletions classes/Visualizer/Gutenberg/build/handsontable.js

Large diffs are not rendered by default.

18,741 changes: 6,063 additions & 12,678 deletions classes/Visualizer/Gutenberg/package-lock.json

Large diffs are not rendered by default.

36 changes: 19 additions & 17 deletions classes/Visualizer/Gutenberg/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,34 @@
"handsontable": "^5.0.2",
"is-plain-object": "^2.0.4",
"merge": "^1.2.1",
"react": "16.4.1",
"react": "18.3.1",
"react-dom": "^18.3.1",
"react-google-charts": "^3.0.8",
"react-json-editor-ajrm": "^2.5.8",
"sprintf-js": "^1.1.2",
"uuid": "^3.3.3"
"uuid": "^8.3.2"
},
"devDependencies": {
"@babel/core": "^7.1.6",
"@babel/core": "^7.21.0",
"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
"@babel/plugin-transform-async-to-generator": "^7.1.0",
"@babel/plugin-transform-react-jsx": "^7.1.6",
"@babel/preset-env": "^7.1.6",
"autoprefixer": "^9.3.1",
"babel-loader": "^8.0.4",
"cross-env": "3.2.4",
"css-loader": "^1.0.1",
"eslint": "^5.7.0",
"autoprefixer": "^10.4.0",
"babel-loader": "^9.1.0",
"cross-env": "7.0.3",
"css-loader": "^6.5.0",
"eslint": "^6.0.0",
"eslint-config-wordpress": "^2.0.0",
"eslint-loader": "^2.1.1",
"eslint-plugin-react": "^7.11.1",
"file-loader": "^4.0.0",
"mini-css-extract-plugin": "^0.4.4",
"node-sass": "^4.10.0",
"postcss-loader": "^3.0.0",
"sass-loader": "^7.1.0",
"webpack": "^4.25.1",
"webpack-cli": "^3.1.2"
"eslint-loader": "^4.0.0",
"eslint-plugin-react": "^7.30.0",
"file-loader": "^6.0.0",
"mini-css-extract-plugin": "^2.4.5",
"node-sass": "^7.0.0",
"postcss-loader": "^6.2.1",
"sass-loader": "^12.0.0",
"webpack": "^5.74.0",
"webpack-cli": "^4.10.0",
"terser-webpack-plugin": "^5.3.10"
}
}
2 changes: 1 addition & 1 deletion classes/Visualizer/Gutenberg/src/Components/DataTable.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
import uuidv4 from 'uuid';
import { v4 as uuidv4 } from 'uuid';

/**
* WordPress dependencies
Expand Down
171 changes: 93 additions & 78 deletions classes/Visualizer/Gutenberg/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,93 +1,108 @@
const webpack = require( 'webpack' );
const webpack = require('webpack');
const NODE_ENV = process.env.NODE_ENV || 'development';
const MiniCssExtractPlugin = require( 'mini-css-extract-plugin' );
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const TerserPlugin = require('terser-webpack-plugin');

module.exports = {
externals: {
externals: {
'lodash': 'lodash'
},
mode: NODE_ENV,
entry: './src/index.js',
output: {
path: __dirname,
filename: './build/block.js',
chunkFilename: './build/[name].js'
},
module: {
rules: [
{
test: /.js?$/,
use: [ {
loader: 'babel-loader',
options: {
presets: [ '@babel/preset-env' ],
plugins: [
'@babel/plugin-transform-async-to-generator',
'@babel/plugin-proposal-object-rest-spread',
[
'@babel/plugin-transform-react-jsx', {
'pragma': 'wp.element.createElement'
}
]
]
}
},
'eslint-loader' ],
exclude: /node_modules/
},
{
test: /\.(css|scss)$/,
use: [ {
loader: MiniCssExtractPlugin.loader
},
'css-loader',
{
loader: 'postcss-loader',
options: {
plugins: [
require( 'autoprefixer' )
]
}
},
{
loader: 'sass-loader',
query: {
outputStyle:
'production' === process.env.NODE_ENV ? 'compressed' : 'nested'
}
} ]
},
{
test: /\.(png|jpe?g|gif)$/,
use: [
{
loader: 'file-loader',
options: {
name: './[name].[ext]'
}
}
]
}
]
},
optimization: {
mode: NODE_ENV,
entry: {
block: './src/index.js'
},
output: {
path: __dirname,
filename: './build/[name].js'
},
module: {
rules: [
{
test: /\.js$/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
plugins: [
'@babel/plugin-transform-async-to-generator',
'@babel/plugin-proposal-object-rest-spread',
[
'@babel/plugin-transform-react-jsx', {
'pragma': 'wp.element.createElement'
}
]
]
}
},
exclude: /node_modules/
},
{
test: /\.(css|scss)$/,
use: [
{
loader: MiniCssExtractPlugin.loader
},
'css-loader',
{
loader: 'postcss-loader',
options: {
postcssOptions: {
plugins: [
require('autoprefixer')
]
}
}
},
{
loader: 'sass-loader',
options: {
implementation: require('sass'),
sassOptions: {
outputStyle: NODE_ENV === 'production' ? 'compressed' : 'expanded'
}
}
}
]
},
{
test: /\.(png|jpe?g|gif)$/,
use: [
{
loader: 'file-loader',
options: {
name: './[name].[ext]'
}
}
]
}
]
},
optimization: {
splitChunks: {
cacheGroups: {
handsontable: {
name: 'handsontable',
test: /[\\/]node_modules[\\/]handsontable/,
chunks: 'all'
chunks: 'all',
enforce: true
}
}
}
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify( NODE_ENV )
}),
new MiniCssExtractPlugin({
filename: './build/block.css',
chunkFilename: './build/[name].css'
})
]
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(NODE_ENV)
}),
new MiniCssExtractPlugin({
filename: './build/[name].css'
}),
new TerserPlugin({
terserOptions: {
format: {
comments: false // Disable comments
}
},
extractComments: false // Prevents LICENSE.txt generation
})
]
};
47 changes: 28 additions & 19 deletions classes/Visualizer/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ public function _getDataAs( $chart_id, $type ) {
}

$filename = $title;

switch ( $type ) {
case 'csv':
$final = $this->_getCSV( $rows, $filename, false );
Expand Down Expand Up @@ -324,9 +323,9 @@ private function _getCSV( $rows, $filename, $enclose ) {
* @param string $filename The name of the file to use.
*/
private function _getExcel( $rows, $filename ) {
// PHPExcel did not like sheet names longer than 31 characters and we will assume the same with PhpSpreadsheet
$chart = substr( $filename, 0, 30 );
$filename .= '.xlsx';
// OpenSpout allows for long sheet names, but let's keep the same limit for compatibility.
$chart = substr( $filename, 0, 30 );
$filename .= '.xlsx';
if ( ! apply_filters( 'vizualizer_export_include_series_type', true ) ) {
unset( $rows[1] );
$rows = array_values( $rows );
Expand All @@ -339,22 +338,32 @@ function( $r ) {
}
$vendor_file = VISUALIZER_ABSPATH . '/vendor/autoload.php';
if ( is_readable( $vendor_file ) ) {
include_once( $vendor_file );
}
$xlsData = '';
if ( class_exists( 'PhpOffice\PhpSpreadsheet\Spreadsheet' ) ) {
$doc = new PhpOffice\PhpSpreadsheet\Spreadsheet();
$doc->getActiveSheet()->fromArray( $rows, null, 'A1' );
$doc->getActiveSheet()->setTitle( sanitize_title( $chart ) );
$doc = apply_filters( 'visualizer_excel_doc', $doc );
$writer = PhpOffice\PhpSpreadsheet\IOFactory::createWriter( $doc, 'Xlsx' );
ob_start();
$writer->save( 'php://output' );
$xlsData = ob_get_contents();
ob_end_clean();
include_once $vendor_file;
}
$xlsData = '';
if ( class_exists( 'OpenSpout\Writer\Common\Creator\WriterEntityFactory' ) ) {
try {
// Use OpenSpout to create the XLSX file in memory.
$writer = \OpenSpout\Writer\Common\Creator\WriterEntityFactory::createXLSXWriter();
$writer->openToFile( 'php://output' ); // Open to output instead of a file.
$writer->getCurrentSheet()->setName( sanitize_title( $chart ) );

// Write rows.
foreach ( $rows as $row ) {
$rowFromValues = \OpenSpout\Writer\Common\Creator\WriterEntityFactory::createRowFromArray( $row );
$writer->addRow( $rowFromValues );
}

ob_start();
$writer->close(); // Saves and closes the file in the output buffer.
$xlsData = ob_get_clean();
} catch ( Exception $e ) {
do_action( 'themeisle_log_event', Visualizer_Plugin::NAME, 'OpenSpout writer error: ' . $e->getMessage(), 'error', __FILE__, __LINE__ );
error_log( 'OpenSpout writer error: ' . $e->getMessage() );
}
} else {
do_action( 'themeisle_log_event', Visualizer_Plugin::NAME, 'Class PhpOffice\PhpSpreadsheet\Spreadsheet does not exist!', 'error', __FILE__, __LINE__ );
error_log( 'Class PhpOffice\PhpSpreadsheet\Spreadsheet does not exist!' );
do_action( 'themeisle_log_event', Visualizer_Plugin::NAME, 'Class OpenSpout\Writer\Common\Creator\WriterEntityFactory does not exist!', 'error', __FILE__, __LINE__ );
error_log( 'Class OpenSpout\Writer\Common\Creator\WriterEntityFactory does not exist!' );
}
return array(
'csv' => 'data:application/vnd.ms-excel;base64,' . base64_encode( $xlsData ),
Expand Down
4 changes: 4 additions & 0 deletions classes/Visualizer/Module/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -1093,6 +1093,10 @@ public function renderLibraryPage() {

$this->load_survey();

if ( ! apply_filters( 'visualizer_is_business', false ) ) {
do_action( 'themeisle_sdk_load_banner', 'visualizer' );
}

$render->render();
}

Expand Down
2 changes: 2 additions & 0 deletions classes/Visualizer/Render/Library.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ private function _renderLibrary() {

// Added by Ash/Upwork
$filterBy = ! empty( $_GET['s'] ) ? sanitize_text_field( wp_unslash( $_GET['s'] ) ) : null; // phpcs:ignore WordPress.Security.NonceVerification.Recommended

// Added by Ash/Upwork
echo $this->custom_css;

Expand All @@ -276,6 +277,7 @@ private function _renderLibrary() {
$this->getDisplayForm();
echo '</div>';
echo '<div id="visualizer-content-wrapper">';
echo '<div id="tsdk_banner" class="visualizer-banner"></div>';
if ( ! empty( $this->charts ) ) {
echo '<div id="visualizer-library" class="visualizer-clearfix">';
$count = 0;
Expand Down
2 changes: 1 addition & 1 deletion classes/Visualizer/Render/Sidebar.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ private static function is_excel_enabled() {
return false;
}

return class_exists( 'PhpOffice\PhpSpreadsheet\Spreadsheet' ) && extension_loaded( 'zip' ) && extension_loaded( 'xml' ) && extension_loaded( 'fileinfo' );
return class_exists( 'OpenSpout\Writer\Common\Creator\WriterEntityFactory' ) && extension_loaded( 'zip' ) && extension_loaded( 'xml' ) && extension_loaded( 'fileinfo' );
}

/**
Expand Down
9 changes: 4 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@
},
"require": {
"codeinwp/themeisle-sdk": "^3.3",
"phpoffice/phpspreadsheet": "1.8.2",
"neitanod/forceutf8": "~2.0"
"neitanod/forceutf8": "~2.0",
"openspout/openspout": "^3.7"
},
"autoload": {
"files": [
"vendor/codeinwp/themeisle-sdk/load.php",
"vendor/phpoffice/phpspreadsheet/src/Bootstrap.php"
"vendor/codeinwp/themeisle-sdk/load.php"
]
},
"scripts": {
Expand All @@ -40,7 +39,7 @@
"config": {
"optimize-autoloader": true,
"platform": {
"php": "5.6"
"php": "7.4"
},
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
Expand Down
Loading

0 comments on commit 81f0299

Please sign in to comment.