PluginProbe
Chartify – WordPress Chart Plugin / 3.7.1
Chartify – WordPress Chart Plugin v3.7.1
3.8.0 3.7.9 3.7.8 3.7.7 3.7.6 3.7.5 trunk 1.0.0 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 All 83 releases
← All changes | includes/class-chart-builder-activator.php +102 -61 3.1.33.7.1 View file →
@@ -1,7 +1,7 @@
1 1 <?php
2 2 global $ays_chart_db_version;
3 -$ays_chart_db_version = '1.0.2';
3 +$ays_chart_db_version = '1.0.3';
4 4
5 5 /**
6 6 * Fired during plugin activation
7 7 *
@@ -57,8 +57,9 @@
57 57 `date_created` DATETIME NOT NULL DEFAULT '1000-01-01 00:00:00',
58 58 `date_modified` DATETIME NOT NULL DEFAULT '1000-01-01 00:00:00',
59 59 `status` VARCHAR(256) NOT NULL DEFAULT 'published',
60 60 `trash_status` VARCHAR(256) NOT NULL DEFAULT '',
61 + `custom_post_id` INT(16) UNSIGNED DEFAULT NULL,
61 62 `ordering` INT(16) NOT NULL,
62 63 `quiz_query` VARCHAR(256) DEFAULT '',
63 64 `quiz_id` INT(16) UNSIGNED DEFAULT '0',
64 65 `options` TEXT NOT NULL DEFAULT '',
@@ -64,13 +65,17 @@
64 65 `options` TEXT NOT NULL DEFAULT '',
65 66 PRIMARY KEY (`id`)
66 67 )$charset_collate;";
67 68
68 - $sql_schema = "SELECT * FROM INFORMATION_SCHEMA.TABLES
69 - WHERE table_schema = '".DB_NAME."' AND table_name = '".$charts_table."' ";
70 - $results = $wpdb->get_results($sql_schema);
71 -
69 + $results = $wpdb->get_results( // phpcs:ignore
70 + $wpdb->prepare(
71 + "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = %s AND table_name = %s",
72 + DB_NAME,
73 + $charts_table
74 + )
75 + );
72 76 if( empty( $results ) ){
77 + // phpcs:ignore
73 78 $wpdb->query( $sql );
74 79 }else{
75 80 dbDelta( $sql );
76 81 }
@@ -84,14 +89,19 @@
84 89 `note` TEXT NOT NULL DEFAULT '',
85 90 `options` TEXT NOT NULL DEFAULT '',
86 91 PRIMARY KEY (`id`)
87 92 )$charset_collate;";
93 + $results = $wpdb->get_results(// phpcs:ignore
94 + $wpdb->prepare(
95 + "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = %s AND table_name = %s",
96 + DB_NAME,
97 + $charts_meta_table
98 + )
99 + );
100 +
88 101
89 - $sql_schema = "SELECT * FROM INFORMATION_SCHEMA.TABLES
90 - WHERE table_schema = '".DB_NAME."' AND table_name = '".$charts_meta_table."' ";
91 - $results = $wpdb->get_results($sql_schema);
92 -
93 102 if(empty($results)){
103 + // phpcs:ignore
94 104 $wpdb->query( $sql );
95 105 }else{
96 106 dbDelta( $sql );
97 107 }
@@ -105,13 +115,18 @@
105 115 `options` TEXT NOT NULL DEFAULT '',
106 116 PRIMARY KEY (`id`)
107 117 )$charset_collate;";
108 118
109 - $sql_schema = "SELECT * FROM INFORMATION_SCHEMA.TABLES
110 - WHERE table_schema = '".DB_NAME."' AND table_name = '".$settings_table."' ";
111 - $results = $wpdb->get_results($sql_schema);
119 + $results = $wpdb->get_results(// phpcs:ignore
120 + $wpdb->prepare(
121 + "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = %s AND table_name = %s",
122 + DB_NAME,
123 + $settings_table
124 + )
125 + );
112 126
113 127 if(empty($results)){
128 + // phpcs:ignore
114 129 $wpdb->query( $sql );
115 130 }else{
116 131 dbDelta( $sql );
117 132 }
@@ -130,16 +145,23 @@
130 145 $meta_val = "";
131 146 if($meta_key == "user_roles"){
132 147 $meta_val = json_encode(array('administrator'));
133 148 }
134 - $sql = "SELECT COUNT(*) FROM `".$settings_table."` WHERE `meta_key` = '". esc_sql( $meta_key ) ."'";
135 - $result = $wpdb->get_var($sql);
149 +
150 + $result = $wpdb->get_var(// phpcs:ignore
151 + $wpdb->prepare(
152 + "SELECT COUNT(*)
153 + FROM {$settings_table}
154 + WHERE meta_key = %s",
155 + $meta_key
156 + )
157 + );
136 158 if(intval($result) == 0){
137 - $result = $wpdb->insert(
159 + $result = $wpdb->insert(// phpcs:ignore
138 160 $settings_table,
139 161 array(
140 - 'meta_key' => $meta_key,
141 - 'meta_value' => $meta_val,
162 + 'meta_key' => $meta_key,// phpcs:ignore
163 + 'meta_value' => $meta_val,// phpcs:ignore
142 164 'note' => "",
143 165 'options' => ""
144 166 ),
145 167 array( '%s', '%s', '%s', '%s' )
@@ -181,68 +203,77 @@
181 203 //
182 204 );
183 205
184 206 $default_chart = array(
185 - 'title' => 'Default chart',
186 - 'description' => '',
187 - 'type' => 'google-charts',
188 - 'source_chart_type' => 'pie_chart',
189 - 'source_type' => 'manual',
190 - 'source' => json_encode($default_chart_source),
191 - 'date_created' => current_time('mysql'),
192 - 'date_modified' => current_time('mysql'),
193 - 'status' => 'published',
194 - 'trash_status' => '',
195 - 'ordering' => '0',
196 - 'options' => json_encode($default_chart_options),
197 - 'author_id' => get_current_user_id()
207 + 'title' => 'Default chart',
208 + 'description' => '',
209 + 'type' => 'google-charts',
210 + 'source_chart_type' => 'pie_chart',
211 + 'source_type' => 'manual',
212 + 'source' => json_encode($default_chart_source),
213 + 'date_created' => current_time('mysql'),
214 + 'date_modified' => current_time('mysql'),
215 + 'status' => 'published',
216 + 'trash_status' => '',
217 + 'ordering' => '0',
218 + 'options' => json_encode($default_chart_options),
219 + 'author_id' => get_current_user_id()
198 220 );
199 221
200 222 $wpdb->insert($charts_table, $default_chart);
223 +
201 224 $chart_id = $wpdb->insert_id;
202 225
226 + $post_type_args = array(
227 + 'chart_id' => $chart_id,
228 + 'author_id' => get_current_user_id(),
229 + 'chart_title' => 'Default chart',
230 + );
231 +
232 + $custom_post_id = Chart_Builder_Custom_Post_Type::ays_chart_add_custom_post($post_type_args);
233 +
203 234 $default_chart_meta = array(
204 235 array(
205 - 'chart_id' => $chart_id,
206 - 'meta_key' => 'width',
207 - 'meta_value' => '100',
208 - 'note' => '',
209 - 'options' => ''
236 + 'chart_id' => $chart_id,
237 + 'meta_key' => 'width',// phpcs:ignore
238 + 'meta_value' => '100',// phpcs:ignore
239 + 'note' => '',
240 + 'options' => ''
210 241 ),
211 242 array(
212 - 'chart_id' => $chart_id,
213 - 'meta_key' => 'height',
214 - 'meta_value' => '400',
215 - 'note' => '',
216 - 'options' => ''
243 + 'chart_id' => $chart_id,
244 + 'meta_key' => 'height',// phpcs:ignore
245 + 'meta_value' => '400',// phpcs:ignore
246 + 'note' => '',
247 + 'options' => ''
217 248 ),
218 249 array(
219 - 'chart_id' => $chart_id,
220 - 'meta_key' => 'title_color',
221 - 'meta_value' => '#000000',
222 - 'note' => '',
223 - 'options' => ''
250 + 'chart_id' => $chart_id,
251 + 'meta_key' => 'title_color',// phpcs:ignore
252 + 'meta_value' => '#000000',// phpcs:ignore
253 + 'note' => '',
254 + 'options' => ''
224 255 ),
225 256 array(
226 - 'chart_id' => $chart_id,
227 - 'meta_key' => 'font_size',
228 - 'meta_value' => '14',
229 - 'note' => '',
230 - 'options' => ''
257 + 'chart_id' => $chart_id,
258 + 'meta_key' => 'font_size',// phpcs:ignore
259 + 'meta_value' => '14',// phpcs:ignore
260 + 'note' => '',
261 + 'options' => ''
231 262 ),
232 263 array(
233 - 'chart_id' => $chart_id,
234 - 'meta_key' => 'tooltip_trigger',
235 - 'meta_value' => 'hover',
236 - 'note' => '',
237 - 'options' => ''
264 + 'chart_id' => $chart_id,
265 + 'meta_key' => 'tooltip_trigger',// phpcs:ignore
266 + 'meta_value' => 'hover',// phpcs:ignore
267 + 'note' => '',
268 + 'options' => ''
238 269 ),
239 270 array(
240 - 'chart_id' => $chart_id,
241 - 'meta_key' => 'show_color_code',
242 - 'meta_value' => 'off',
243 - 'note' => '',
244 - 'options' => ''
271 + 'chart_id' => $chart_id,
272 + 'meta_key' => 'show_color_code',// phpcs:ignore
273 + 'meta_value' => 'off',// phpcs:ignore
274 + 'note' => '',
275 + 'options' => ''
245 276 )
246 277 );
247 278
248 279 foreach ($default_chart_meta as $key => $value) {
@@ -250,10 +281,20 @@
250 281 }
251 282
252 283 $default_chart['type'] = 'chart-js';
253 284 $wpdb->insert($charts_table, $default_chart);
285 +
286 + $chart_js_id = $wpdb->insert_id;
287 +
288 + $post_type_args = array(
289 + 'chart_id' => $chart_js_id,
290 + 'author_id' => get_current_user_id(),
291 + 'chart_title' => 'Default chart',
292 + );
293 +
294 + $custom_post_id = Chart_Builder_Custom_Post_Type::ays_chart_add_custom_post($post_type_args);
254 295 } else {
255 - $wpdb->update(
296 + $wpdb->update(// phpcs:ignore
256 297 $charts_table,
257 298 array(
258 299 'type' => 'google-charts',
259 300 ),