@@ -34,10 +34,34 @@ public static function upgrade() {
34
34
35
35
/**
36
36
* All 'dataTable' and 'table' charts to become 'tabular'.
37
+ * All charts that do not have a library, to get the default library.
37
38
*/
38
39
private static function makeAllTableChartsTabular () {
39
40
global $ wpdb ;
40
41
42
+ // old table charts may not specify the library.
43
+ $ args = array (
44
+ 'post_type ' => Visualizer_Plugin::CPT_VISUALIZER ,
45
+ 'fields ' => 'ids ' ,
46
+ 'post_status ' => 'publish ' ,
47
+ 'meta_query ' => array (
48
+ array (
49
+ 'key ' => Visualizer_Plugin::CF_CHART_LIBRARY ,
50
+ 'compare ' => 'NOT EXISTS ' ,
51
+ ),
52
+ array (
53
+ 'key ' => Visualizer_Plugin::CF_CHART_TYPE ,
54
+ 'value ' => 'table ' ,
55
+ ),
56
+ ),
57
+ );
58
+ $ query = new WP_Query ( $ args );
59
+ while ( $ query ->have_posts () ) {
60
+ $ id = $ query ->next_post ();
61
+ add_post_meta ( $ id , Visualizer_Plugin::CF_CHART_LIBRARY , 'GoogleCharts ' );
62
+ }
63
+
64
+ // make all dataTable and table chart types into tabular.
41
65
// phpcs:disable WordPress.DB.PreparedSQL.NotPrepared
42
66
$ wpdb ->query (
43
67
"UPDATE $ wpdb ->postmeta pm, $ wpdb ->posts p SET pm.meta_value = 'tabular'
@@ -47,5 +71,6 @@ private static function makeAllTableChartsTabular() {
47
71
AND pm.meta_value IN ( 'dataTable', 'table' ) "
48
72
);
49
73
// phpcs:enable WordPress.DB.PreparedSQL.NotPrepared
74
+
50
75
}
51
76
}
0 commit comments