Skip to content

Commit ea85ec1

Browse files
authored
release: fixes
#### Fixes: - Fix compatibility with 3rd party plugins which use the same js library as Visualizer #801 - Fix fatal error when a new chart is created on PHP 8 #795 - Chart doesn't get refreshed automatically when the JSON endpoint is used as the data source #### Features: - Adds option to add schema.org Dataset for license and creator #794
2 parents bcab1f9 + 65d97ed commit ea85ec1

File tree

12 files changed

+163
-17
lines changed

12 files changed

+163
-17
lines changed

.releaserc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ plugins:
1515
- - "semantic-release-slack-bot"
1616
- notifyOnSuccess: false
1717
notifyOnFail: false
18+
markdownReleaseNotes: true
1819
branchesConfig:
1920
- pattern: master
2021
notifyOnSuccess: true

CONTRIBUTING.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
## Releasing
2+
3+
This repository uses conventional [changelog commit](https://github.com/Codeinwp/conventional-changelog-simple-preset) messages to trigger release
4+
5+
How to release a new version:
6+
7+
- Clone the master branch
8+
- Do your changes
9+
- Send a PR to master and merge it using the following subject message
10+
- `release: <release short description>` - for patch release
11+
- `release(minor): <release short description>` - for minor release
12+
- `release(major): <release short description>` - for major release
13+
The release notes will inherit the body of the commit message which triggered the release. For more details check the [simple-preset](https://github.com/Codeinwp/conventional-changelog-simple-preset) that we use.

classes/Visualizer/Module/Chart.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@ public function setJsonSchedule() {
139139

140140
if ( -1 < $time ) {
141141
add_post_meta( $chart_id, Visualizer_Plugin::CF_JSON_SCHEDULE, $time );
142+
// Update schedules.
143+
$schedules = get_option( Visualizer_Plugin::CF_JSON_SCHEDULE, array() );
144+
$schedules[ $chart_id ] = time() + $time * HOUR_IN_SECONDS;
145+
update_option( Visualizer_Plugin::CF_JSON_SCHEDULE, $schedules );
142146
}
143147
wp_send_json_success();
144148
}

classes/Visualizer/Module/Frontend.php

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,13 +484,48 @@ private function addSchema( $id ) {
484484
return '';
485485
}
486486

487+
$license = '';
488+
if ( isset( $settings['license'] ) && ! empty( $settings['license'] ) ) {
489+
$license = $settings['license'];
490+
if ( is_array( $license ) ) {
491+
$license = $settings['license']['text'];
492+
}
493+
}
494+
$license = apply_filters( 'visualizer_schema_license', $license, $id );
495+
if ( empty( $license ) ) {
496+
if ( $show_errors ) {
497+
return "<!-- Not showing structured data for chart $id because license is empty -->";
498+
}
499+
return '';
500+
}
501+
502+
$creator = '';
503+
if ( isset( $settings['creator'] ) && ! empty( $settings['creator'] ) ) {
504+
$creator = $settings['creator'];
505+
if ( is_array( $creator ) ) {
506+
$creator = $settings['creator']['text'];
507+
}
508+
}
509+
$creator = apply_filters( 'visualizer_schema_creator', $creator, $id );
510+
if ( empty( $creator ) ) {
511+
if ( $show_errors ) {
512+
return "<!-- Not showing structured data for chart $id because creator is empty -->";
513+
}
514+
return '';
515+
}
516+
487517
$schema = apply_filters(
488518
'visualizer_schema',
489519
'{
490520
"@context":"https://schema.org/",
491521
"@type":"Dataset",
492522
"name":"' . esc_html( $title ) . '",
493-
"description":"' . esc_html( $desc ) . '"
523+
"description":"' . esc_html( $desc ) . '",
524+
"license": "' . esc_html( $license ) . '",
525+
"creator": {
526+
"@type": "Person",
527+
"name": "' . esc_html( $creator ) . '"
528+
}
494529
}',
495530
$id
496531
);

classes/Visualizer/Render/Sidebar/ChartJS.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,20 @@ protected function _renderGeneralSettings() {
296296

297297
$this->_renderAnimationSettings();
298298

299+
self::_renderSectionStart( esc_html__( 'License & Creator', 'visualizer' ), false );
300+
self::_renderTextItem(
301+
esc_html__( 'License', 'visualizer' ),
302+
'license',
303+
$this->license,
304+
''
305+
);
306+
self::_renderTextItem(
307+
esc_html__( 'Creator', 'visualizer' ),
308+
'creator',
309+
$this->creator,
310+
''
311+
);
312+
self::_renderSectionEnd();
299313
self::_renderGroupEnd();
300314
}
301315

classes/Visualizer/Render/Sidebar/Google.php

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -208,15 +208,15 @@ protected function _renderGeneralSettings() {
208208
self::_renderSelectItem(
209209
esc_html__( 'Position', 'visualizer' ),
210210
'legend[position]',
211-
$this->legend['position'],
211+
isset( $this->legend['position'] ) ? $this->legend['position'] : '',
212212
$this->_legendPositions,
213213
esc_html__( 'Determines where to place the legend, compared to the chart area.', 'visualizer' )
214214
);
215215

216216
self::_renderSelectItem(
217217
esc_html__( 'Alignment', 'visualizer' ),
218218
'legend[alignment]',
219-
$this->legend['alignment'],
219+
isset( $this->legend['alignment'] ) ? $this->legend['alignment'] : '',
220220
$this->_alignments,
221221
esc_html__( 'Determines the alignment of the legend.', 'visualizer' )
222222
);
@@ -234,7 +234,20 @@ protected function _renderGeneralSettings() {
234234
self::_renderSectionEnd();
235235

236236
$this->_renderAnimationSettings();
237-
237+
self::_renderSectionStart( esc_html__( 'License & Creator', 'visualizer' ), false );
238+
self::_renderTextItem(
239+
esc_html__( 'License', 'visualizer' ),
240+
'license',
241+
$this->license,
242+
''
243+
);
244+
self::_renderTextItem(
245+
esc_html__( 'Creator', 'visualizer' ),
246+
'creator',
247+
$this->creator,
248+
''
249+
);
250+
self::_renderSectionEnd();
238251
do_action( 'visualizer_chart_settings', get_class( $this ), $this->_data, 'general', array( 'generic' => true ) );
239252

240253
self::_renderGroupEnd();
@@ -393,10 +406,12 @@ protected function _renderViewSettings() {
393406
echo '<table class="viz-section-table" cellspacing="0" cellpadding="0" border="0">';
394407
echo '<tr>';
395408
echo '<td class="viz-section-table-column">';
396-
echo '<input type="text" name="chartArea[left]" class="control-text" value="', $this->chartArea['left'] || $this->chartArea['left'] === '0' ? esc_attr( $this->chartArea['left'] ) : '', '" placeholder="20%">';
409+
$chartarea_left = isset( $this->chartArea['left'] ) ? $this->chartArea['left'] : '';
410+
echo '<input type="text" name="chartArea[left]" class="control-text" value="', $chartarea_left || '0' === $chartarea_left ? esc_attr( $chartarea_left ) : '', '" placeholder="20%">';
397411
echo '</td>';
398412
echo '<td class="viz-section-table-column">';
399-
echo '<input type="text" name="chartArea[top]" class="control-text" value="', $this->chartArea['top'] || $this->chartArea['top'] === '0' ? esc_attr( $this->chartArea['top'] ) : '', '" placeholder="20%">';
413+
$chartarea_top = isset( $this->chartArea['top'] ) ? $this->chartArea['top'] : '';
414+
echo '<input type="text" name="chartArea[top]" class="control-text" value="', $chartarea_top || '0' === $chartarea_top ? esc_attr( $chartarea_top ) : '', '" placeholder="20%">';
400415
echo '</td>';
401416
echo '</tr>';
402417
echo '</table>';

classes/Visualizer/Render/Sidebar/Type/GoogleCharts/Gauge.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,28 @@ protected function _renderGeneralSettings() {
7878
$this->title,
7979
esc_html__( 'Text to display in the back-end admin area.', 'visualizer' )
8080
);
81+
82+
self::_renderTextAreaItem(
83+
esc_html__( 'Chart Description', 'visualizer' ),
84+
'description',
85+
$this->description,
86+
sprintf( esc_html__( 'Description to display in the structured data schema as explained %1$shere%2$s', 'visualizer' ), '<a href="https://developers.google.com/search/docs/data-types/dataset#dataset" target="_blank">', '</a>' )
87+
);
88+
self::_renderSectionEnd();
89+
90+
self::_renderSectionStart( esc_html__( 'License & Creator', 'visualizer' ), false );
91+
self::_renderTextItem(
92+
esc_html__( 'License', 'visualizer' ),
93+
'license',
94+
$this->license,
95+
''
96+
);
97+
self::_renderTextItem(
98+
esc_html__( 'Creator', 'visualizer' ),
99+
'creator',
100+
$this->creator,
101+
''
102+
);
81103
self::_renderSectionEnd();
82104

83105
self::_renderGroupEnd();

classes/Visualizer/Render/Sidebar/Type/GoogleCharts/Geo.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,27 @@ protected function _renderGeneralSettings() {
6464
$this->title,
6565
esc_html__( 'Text to display in the back-end admin area.', 'visualizer' )
6666
);
67+
self::_renderTextAreaItem(
68+
esc_html__( 'Chart Description', 'visualizer' ),
69+
'description',
70+
$this->description,
71+
sprintf( esc_html__( 'Description to display in the structured data schema as explained %1$shere%2$s', 'visualizer' ), '<a href="https://developers.google.com/search/docs/data-types/dataset#dataset" target="_blank">', '</a>' )
72+
);
73+
self::_renderSectionEnd();
74+
75+
self::_renderSectionStart( esc_html__( 'License & Creator', 'visualizer' ), false );
76+
self::_renderTextItem(
77+
esc_html__( 'License', 'visualizer' ),
78+
'license',
79+
$this->license,
80+
''
81+
);
82+
self::_renderTextItem(
83+
esc_html__( 'Creator', 'visualizer' ),
84+
'creator',
85+
$this->creator,
86+
''
87+
);
6788
self::_renderSectionEnd();
6889
self::_renderGroupEnd();
6990
}

classes/Visualizer/Render/Sidebar/Type/GoogleCharts/Tabular.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,28 @@ protected function _renderGeneralSettings() {
7373
$this->title,
7474
esc_html__( 'Text to display in the back-end admin area.', 'visualizer' )
7575
);
76+
self::_renderTextAreaItem(
77+
esc_html__( 'Chart Description', 'visualizer' ),
78+
'description',
79+
$this->description,
80+
sprintf( esc_html__( 'Description to display in the structured data schema as explained %1$shere%2$s', 'visualizer' ), '<a href="https://developers.google.com/search/docs/data-types/dataset#dataset" target="_blank">', '</a>' )
81+
);
7682
self::_renderSectionEnd();
77-
self::_renderGroupEnd();
83+
84+
self::_renderSectionStart( esc_html__( 'License & Creator', 'visualizer' ), false );
85+
self::_renderTextItem(
86+
esc_html__( 'License', 'visualizer' ),
87+
'license',
88+
$this->license,
89+
''
90+
);
91+
self::_renderTextItem(
92+
esc_html__( 'Creator', 'visualizer' ),
93+
'creator',
94+
$this->creator,
95+
''
96+
);
97+
self::_renderGroupEnd();
7898
}
7999

80100
/**

classes/Visualizer/Source.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ public static final function get_date_formats_if_exists( $series, $data ) {
335335
*
336336
* @return string|null
337337
*/
338-
private static final function determine_date_format( $value, $type ) {
338+
private static function determine_date_format( $value, $type ) {
339339
if ( version_compare( phpversion(), '5.3.0', '<' ) ) {
340340
do_action( 'themeisle_log_event', Visualizer_Plugin::NAME, sprintf( 'PHP version %s not supported', phpversion() ), 'error', __FILE__, __LINE__ );
341341
return null;

0 commit comments

Comments
 (0)