PluginProbe
Snippet Shortcodes / 4.0.2
Snippet Shortcodes v4.0.2
5.2.1 5.2 5.1.8 5.1.6 5.1.7 5.1.5 trunk 1.0 1.1 1.2 1.3 1.3.1 1.4 1.5 1.5.1 1.6 1.6.1 1.7 1.7.1 1.7.2 1.7.3 1.7.4 1.8 2.0 2.0.1 All 74 releases
← All changes | includes/db.php +512 -292 2.0.14.0.2 View file →
@@ -1,292 +1,512 @@
1 -<?php
2 -
3 -defined('ABSPATH') or die('Jog on!');
4 -
5 -/**
6 - * Build database table
7 - */
8 -function sh_cd_create_database_table() {
9 -
10 - global $wpdb;
11 -
12 - $table_name = $wpdb->prefix . SH_CD_TABLE;
13 -
14 - $charset_collate = $wpdb->get_charset_collate();
15 -
16 - $sql = "CREATE TABLE $table_name (
17 - id mediumint(9) NOT NULL AUTO_INCREMENT,
18 - slug varchar(100) NOT NULL,
19 - data text,
20 - disabled bit default 0,
21 - UNIQUE KEY id (id)
22 - ) $charset_collate;";
23 -
24 - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
25 -
26 - dbDelta( $sql );
27 -}
28 -
29 -/**
30 - * Fetch all Shortcodes
31 - *
32 - * @return bool
33 - */
34 -function sh_cd_db_shortcodes_all() {
35 -
36 - global $wpdb;
37 -
38 - return $wpdb->get_results( 'SELECT * FROM ' . $wpdb->prefix . SH_CD_TABLE . ' order by slug asc', ARRAY_A );
39 -}
40 -
41 -/**
42 - * Fetch a shortcode by ID (mainly used for quick lookups in admin)
43 - *
44 - * @param $id
45 - *
46 - * @return mixed
47 - */
48 -function sh_cd_db_shortcodes_by_id( $id ) {
49 -
50 - global $wpdb;
51 -
52 - $sql = $wpdb->prepare('SELECT id, slug, data, disabled FROM ' . $wpdb->prefix . SH_CD_TABLE . ' where id = %d', $id);
53 -
54 - return $wpdb->get_row( $sql, ARRAY_A );
55 -}
56 -
57 -/**
58 - * Fetch the content of the shortcode by slug
59 - *
60 - * @param $slug
61 - *
62 - * @return null|string
63 - */
64 -function sh_cd_db_shortcodes_by_slug( $slug ) {
65 -
66 - global $wpdb;
67 -
68 - $sql = $wpdb->prepare('SELECT data FROM ' . $wpdb->prefix . SH_CD_TABLE . ' where slug = %s and disabled <> 1', $slug);
69 -
70 - $row = $wpdb->get_var( $sql );
71 -
72 - return ( false === empty( $row ) ? stripslashes( $row ) : NULL );
73 -}
74 -
75 -/**
76 - * Get a Shortcode's slug from the slug ID
77 - *
78 - * @param $id
79 - *
80 - * @return bool
81 - */
82 -function sh_cd_db_shortcodes_get_slug_by_id( $id ) {
83 -
84 - global $wpdb;
85 -
86 - $sql = $wpdb->prepare('SELECT slug FROM ' . $wpdb->prefix . SH_CD_TABLE . ' where id = %d', $id);
87 -
88 - return $wpdb->get_var( $sql );
89 -}
90 -
91 -/**
92 - * Save / Insert a shortcode
93 - *
94 - * @param $shortcode
95 - *
96 - * @return bool
97 - */
98 -function sh_cd_db_shortcodes_save( $shortcode ) {
99 -
100 - if ( false === is_admin() ) {
101 - return false;
102 - }
103 -
104 - $shortcode = wp_parse_args( $shortcode, [
105 - 'id' => NULL,
106 - 'slug' => NULL,
107 - 'data' => NULL,
108 - 'disabled' => 0
109 - ]);
110 -
111 - // We need either a slug or an ID
112 - if ( true === empty( $shortcode['slug'] ) && true === empty( $shortcode['id'] ) ) {
113 - return false;
114 - }
115 -
116 - $shortcode['disabled'] = (int) $shortcode['disabled'];
117 -
118 - global $wpdb;
119 -
120 - $result = false;
121 -
122 - // Updating an existing shortcode?
123 - if ( false === empty( $shortcode['id'] ) && true === is_numeric( $shortcode['id'] ) ){
124 -
125 - // Once set, a slug cannot be updated.
126 - unset( $shortcode['slug'] );
127 -
128 - $formats = sh_cd_db_get_formats( $shortcode );
129 -
130 - $result = $wpdb->update(
131 - $wpdb->prefix . SH_CD_TABLE,
132 - $shortcode,
133 - [ 'id' => $shortcode['id'] ],
134 - $formats,
135 - [ '%d' ]
136 - );
137 -
138 - sh_cd_cache_delete_by_slug_or_key( $shortcode['id'] );
139 -
140 - // Adding a new shortcode
141 - } else {
142 -
143 - unset( $shortcode['id'] );
144 -
145 - // Ensure slug is santised and unique
146 - $shortcode['slug'] = sh_cd_slug_generate( $shortcode['slug'] );
147 -
148 - $formats = sh_cd_db_get_formats( $shortcode );
149 -
150 - $result = $wpdb->insert(
151 - $wpdb->prefix . SH_CD_TABLE,
152 - $shortcode,
153 - $formats
154 - );
155 -
156 - // It's an insert, so there should be no cache... however, just a wee sanity check in case
157 - // a shortcode with the same slug previously exists.
158 - sh_cd_cache_delete_by_slug_or_key( $shortcode['slug'] );
159 - }
160 -
161 - return ( false !== $result );
162 -}
163 -
164 -/**
165 - * Update a shortcode's status
166 - *
167 - * @param $shortcode
168 - *
169 - * @return bool
170 - */
171 -function sh_cd_db_shortcodes_update_status( $id, $status ) {
172 -
173 - if ( false === is_admin() ) {
174 - return false;
175 - }
176 -
177 - global $wpdb;
178 -
179 - $result = $wpdb->update(
180 - $wpdb->prefix . SH_CD_TABLE,
181 - [ 'disabled' => $status ],
182 - [ 'id' => $id ],
183 - [ '%d' ],
184 - [ '%d' ]
185 - );
186 -
187 - sh_cd_cache_delete_by_slug_or_key( $id );
188 -
189 - return ( false !== $result );
190 -}
191 -
192 -/**
193 - * Update a shortcode's content
194 - *
195 - * @param $shortcode
196 - *
197 - * @return bool
198 - */
199 -function sh_cd_db_shortcodes_update_content( $id, $data ) {
200 -
201 - if ( false === is_admin() ) {
202 - return false;
203 - }
204 -
205 - global $wpdb;
206 -
207 - $result = $wpdb->update(
208 - $wpdb->prefix . SH_CD_TABLE,
209 - [ 'data' => $data ],
210 - [ 'id' => $id ],
211 - [ '%s' ],
212 - [ '%d' ]
213 - );
214 -
215 - sh_cd_cache_delete_by_slug_or_key( $id );
216 -
217 - return ( false !== $result );
218 -}
219 -
220 -
221 -/**
222 - * Delete a shortcode
223 - *
224 - * @param $id
225 - *
226 - * @return bool
227 - */
228 -function sh_cd_db_shortcodes_delete( $id ) {
229 -
230 - if ( false === is_admin() || false === is_numeric( $id ) ) {
231 - return false;
232 - }
233 -
234 - global $wpdb;
235 -
236 - // Clear cached version
237 - sh_cd_cache_delete_by_slug_or_key( $id );
238 -
239 - $result = $wpdb->delete( $wpdb->prefix . SH_CD_TABLE, [ 'id' => $id ], [ '%d' ] );
240 -
241 - return ( false !== $result );
242 -}
243 -
244 -/**
245 - * For a given key value array, look up and return the expected MySQL data formats.
246 - *
247 - * @param $data
248 - *
249 - * @return array
250 - */
251 -function sh_cd_db_get_formats( $data ) {
252 -
253 - $lookup = [
254 - 'id' => '%d',
255 - 'slug' => '%s',
256 - 'data' => '%s',
257 - 'disabled' => '%d'
258 - ];
259 -
260 - $formats = [];
261 -
262 - foreach ( $data as $key => $value ) {
263 -
264 - if ( false === empty( $lookup[ $key ] ) ) {
265 - $formats[] = $lookup[ $key ];
266 - }
267 - }
268 -
269 - return $formats;
270 -}
271 -
272 -/**
273 - * Check if the slug already exists
274 - *
275 - * @param $slug
276 - *
277 - * @return bool
278 - */
279 -function sh_cd_slug_is_unique( $slug ) {
280 -
281 - if ( true === empty( $slug ) ) {
282 - return false;
283 - }
284 -
285 - global $wpdb;
286 -
287 - $sql = $wpdb->prepare( 'SELECT count(slug) FROM ' . $wpdb->prefix . SH_CD_TABLE . ' where slug = %s', $slug );
288 -
289 - $row = $wpdb->get_var( $sql );
290 -
291 - return ( empty( $row ) );
292 -}
1 +<?php
2 +
3 +defined('ABSPATH') or die('Jog on!');
4 +
5 +/**
6 + * Build database table
7 + */
8 +function sh_cd_create_database_table() {
9 +
10 + global $wpdb;
11 +
12 + $table_name = $wpdb->prefix . SH_CD_TABLE;
13 +
14 + $charset_collate = $wpdb->get_charset_collate();
15 +
16 + $sql = "CREATE TABLE $table_name (
17 + id mediumint(9) NOT NULL AUTO_INCREMENT,
18 + slug varchar(100) NOT NULL,
19 + previous_slug varchar(100) NOT NULL,
20 + data text,
21 + disabled bit default 0,
22 + multisite bit default 0,
23 + UNIQUE KEY id (id)
24 + ) $charset_collate;";
25 +
26 + require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
27 +
28 + dbDelta( $sql );
29 +}
30 +
31 +/**
32 + * Build database table for multisite
33 + */
34 +function sh_cd_create_database_table_multisite() {
35 +
36 + global $wpdb;
37 +
38 + $table_name = $wpdb->base_prefix . SH_CD_TABLE_MULTISITE;
39 +
40 + $charset_collate = $wpdb->get_charset_collate();
41 +
42 + $sql = "CREATE TABLE $table_name (
43 + id mediumint(9) NOT NULL AUTO_INCREMENT,
44 + slug varchar(100) NOT NULL,
45 + data text,
46 + site_id int default 0,
47 + UNIQUE KEY id (id)
48 + ) $charset_collate;";
49 +
50 + require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
51 +
52 + dbDelta( $sql );
53 +}
54 +
55 +/**
56 + * Fetch all Shortcodes
57 + *
58 + * @return bool
59 + */
60 +function sh_cd_db_shortcodes_all() {
61 +
62 + global $wpdb;
63 +
64 + return $wpdb->get_results( 'SELECT * FROM ' . $wpdb->prefix . SH_CD_TABLE . ' order by slug asc', ARRAY_A );
65 +}
66 +
67 +/**
68 + * Fetch all enabled Shortcodes
69 + *
70 + * @return bool
71 + */
72 +function sh_cd_db_shortcodes_all_enabled() {
73 +
74 + global $wpdb;
75 +
76 + return $wpdb->get_results( 'SELECT * FROM ' . $wpdb->prefix . SH_CD_TABLE . ' where disabled = 0 order by slug asc', ARRAY_A );
77 +}
78 +
79 +/**
80 + * Fetch a count of all shortcodes
81 + *
82 + * @return bool
83 + */
84 +function sh_cd_db_shortcodes_count() {
85 +
86 + global $wpdb;
87 +
88 + return $wpdb->get_var( 'SELECT count(id) FROM ' . $wpdb->prefix . SH_CD_TABLE );
89 +}
90 +
91 +/**
92 + * Fetch a shortcode by ID (mainly used for quick lookups in admin)
93 + *
94 + * @param $id
95 + *
96 + * @return mixed
97 + */
98 +function sh_cd_db_shortcodes_by_id( $id ) {
99 +
100 + global $wpdb;
101 +
102 + $sql = $wpdb->prepare('SELECT id, slug, previous_slug, data, disabled, multisite FROM ' . $wpdb->prefix . SH_CD_TABLE . ' where id = %d', $id);
103 +
104 + return $wpdb->get_row( $sql, ARRAY_A );
105 +}
106 +
107 +/**
108 + * Fetch the content of the shortcode by slug
109 + *
110 + * @param $slug
111 + *
112 + * @return null|string
113 + */
114 +function sh_cd_db_shortcodes_by_slug( $slug ) {
115 +
116 + global $wpdb;
117 +
118 + $sqls = [];
119 +
120 + // If multi site functionality is enabled, look there first for the shortcode!
121 + if ( true === sh_cd_is_multisite_enabled() ) {
122 +
123 + $sqls[] = $wpdb->prepare('SELECT data FROM ' . $wpdb->base_prefix . SH_CD_TABLE_MULTISITE . ' where slug = %s', $slug);
124 + }
125 +
126 + $sqls[] = $wpdb->prepare('SELECT data FROM ' . $wpdb->prefix . SH_CD_TABLE . ' where slug = %s and disabled <> 1', $slug);
127 +
128 + foreach ( $sqls as $sql ) {
129 +
130 + $row = $wpdb->get_var( $sql );
131 +
132 + if ( false === empty( $row ) ) {
133 +
134 + return stripslashes( $row );
135 + }
136 + }
137 +
138 + return NULL;
139 +}
140 +
141 +/**
142 + * Get a Shortcode's slug from the slug ID
143 + *
144 + * @param $id
145 + *
146 + * @return bool
147 + */
148 +function sh_cd_db_shortcodes_get_slug_by_id( $id ) {
149 +
150 + global $wpdb;
151 +
152 + $sql = $wpdb->prepare('SELECT slug FROM ' . $wpdb->prefix . SH_CD_TABLE . ' where id = %d', $id);
153 +
154 + return $wpdb->get_var( $sql );
155 +}
156 +
157 +/**
158 + * Save / Insert a shortcode
159 + *
160 + * @param $shortcode
161 + *
162 + * @return bool
163 + */
164 +function sh_cd_db_shortcodes_save( $shortcode, $return_shortcode = false ) {
165 +
166 + if ( false === is_admin() ) {
167 + return false;
168 + }
169 +
170 + $multi_site_enabled = sh_cd_is_multisite_enabled();
171 +
172 + $shortcode = wp_parse_args( $shortcode, [ 'id' => NULL,
173 + 'slug' => NULL,
174 + 'previous_slug' => NULL,
175 + 'data' => NULL,
176 + 'disabled' => 0,
177 + 'multisite' => 0
178 + ]);
179 +
180 + // We need either a slug or an ID
181 + if ( true === empty( $shortcode['slug'] ) && true === empty( $shortcode['id'] ) ) {
182 + return false;
183 + }
184 +
185 + $shortcode['disabled'] = (int) $shortcode['disabled'];
186 + $shortcode['multisite'] = ( true === $multi_site_enabled ) ? (int) $shortcode['multisite'] : 0;
187 +
188 + global $wpdb;
189 +
190 + $result = false;
191 +
192 + // Updating an existing shortcode?
193 + if ( false === empty( $shortcode['id'] ) && true === is_numeric( $shortcode['id'] ) ){
194 +
195 + $shortcode['slug'] = sh_cd_slug_generate( $shortcode['slug'], $shortcode['id'] );
196 +
197 + $formats = sh_cd_db_get_formats( $shortcode );
198 +
199 + $result = $wpdb->update(
200 + $wpdb->prefix . SH_CD_TABLE,
201 + $shortcode,
202 + [ 'id' => $shortcode['id'] ],
203 + $formats,
204 + [ '%d' ]
205 + );
206 +
207 + sh_cd_cache_delete_by_slug_or_key( $shortcode['id'] );
208 + sh_cd_cache_delete_by_slug_or_key( $shortcode['previous_slug'] );
209 +
210 + // Adding a new shortcode
211 + } else {
212 +
213 + unset( $shortcode['id'] );
214 +
215 + // Ensure slug is santised and unique
216 + $shortcode['slug'] = sh_cd_slug_generate( $shortcode['slug'] );
217 +
218 + $formats = sh_cd_db_get_formats( $shortcode );
219 +
220 + $result = $wpdb->insert(
221 + $wpdb->prefix . SH_CD_TABLE,
222 + $shortcode,
223 + $formats
224 + );
225 +
226 + // It's an insert, so there should be no cache... however, just a wee sanity check in case
227 + // a shortcode with the same slug previously exists.
228 + sh_cd_cache_delete_by_slug_or_key( $shortcode['slug'] );
229 + }
230 +
231 + if ( false !== $result ) {
232 +
233 + if ( 1 === $shortcode['multisite'] ) {
234 + sh_cd_db_shortcodes_multisite_insert( $shortcode['slug'], $shortcode['data'] );
235 + } else {
236 + sh_cd_db_shortcodes_multisite_delete( $shortcode['slug'] );
237 + }
238 +
239 + sh_cd_cache_delete( $shortcode['slug'] );
240 +
241 + if ( true === $return_shortcode ) {
242 +
243 + $shortcode['id'] = $result;
244 + return $shortcode;
245 + }
246 +
247 + return true;
248 + }
249 +
250 + return false;
251 +}
252 +
253 +
254 +/**
255 + * Insert a multisite shortcode
256 + *
257 + * @param $shortcode
258 + *
259 + * @return bool
260 + */
261 +function sh_cd_db_shortcodes_multisite_insert( $slug, $data ) {
262 +
263 + if ( false === is_admin() ) {
264 + return false;
265 + }
266 +
267 + sh_cd_db_shortcodes_multisite_delete( $slug );
268 +
269 + global $wpdb;
270 +
271 + $shortcode = [
272 + 'slug' => $slug,
273 + 'data' => $data,
274 + 'site_id' => get_current_blog_id()
275 + ];
276 +
277 + $formats = sh_cd_db_get_formats( $shortcode );
278 +
279 + $result = $wpdb->insert(
280 + $wpdb->base_prefix . SH_CD_TABLE_MULTISITE,
281 + $shortcode,
282 + $formats
283 + );
284 +
285 + sh_cd_cache_delete( $slug );
286 +
287 + do_action( 'sh_cd_multisite_changed', $slug );
288 +
289 + return ( false !== $result );
290 +}
291 +
292 +/**
293 + * Delete a multisite shortcode
294 + *
295 + * @param $slug
296 + *
297 + * @return bool
298 + */
299 +function sh_cd_db_shortcodes_multisite_delete( $slug ) {
300 +
301 + global $wpdb;
302 +
303 + $result = $wpdb->delete( $wpdb->base_prefix . SH_CD_TABLE_MULTISITE, [ 'slug' => $slug ], [ '%s' ] );
304 +
305 + sh_cd_cache_delete( $slug );
306 +
307 + do_action( 'sh_cd_multisite_changed', $slug );
308 +
309 + return ( false !== $result );
310 +}
311 +
312 +/**
313 + * Fetch all multisite slugs
314 +
315 + * @return null|array
316 + */
317 +function sh_cd_db_shortcodes_multisite_slugs() {
318 +
319 + global $wpdb;
320 +
321 + return $wpdb->get_results( 'SELECT slug FROM ' . $wpdb->base_prefix . SH_CD_TABLE_MULTISITE, ARRAY_A );
322 +}
323 +
324 +
325 +/**
326 + * Update a shortcode's status
327 + *
328 + * @param $shortcode
329 + *
330 + * @return bool
331 + */
332 +function sh_cd_db_shortcodes_update_status( $id, $status ) {
333 +
334 + if ( false === is_admin() ) {
335 + return false;
336 + }
337 +
338 + global $wpdb;
339 +
340 + $result = $wpdb->update(
341 + $wpdb->prefix . SH_CD_TABLE,
342 + [ 'disabled' => $status ],
343 + [ 'id' => $id ],
344 + [ '%d' ],
345 + [ '%d' ]
346 + );
347 +
348 + sh_cd_cache_delete_by_slug_or_key( $id );
349 +
350 + return ( false !== $result );
351 +}
352 +
353 +/**
354 + * Update a shortcode's multisite
355 + *
356 + * @param $shortcode
357 + *
358 + * @return bool
359 + */
360 +function sh_cd_db_shortcodes_update_multisite( $id, $multisite ) {
361 +
362 + if ( false === is_admin() ) {
363 + return false;
364 + }
365 +
366 + global $wpdb;
367 +
368 + $result = $wpdb->update(
369 + $wpdb->prefix . SH_CD_TABLE,
370 + [ 'multisite' => $multisite ],
371 + [ 'id' => $id ],
372 + [ '%d' ],
373 + [ '%d' ]
374 + );
375 +
376 + $shortcode = sh_cd_db_shortcodes_by_id( $id );
377 +
378 + if ( false === empty( $shortcode ) ) {
379 +
380 + if ( 1 === (int) $multisite ) {
381 + sh_cd_db_shortcodes_multisite_insert( $shortcode['slug'], $shortcode['data'] );
382 + } else {
383 + sh_cd_db_shortcodes_multisite_delete( $shortcode['slug'] );
384 + }
385 +
386 + }
387 +
388 + sh_cd_cache_delete_by_slug_or_key( $id );
389 +
390 + return ( false !== $result );
391 +}
392 +
393 +/**
394 + * Update a shortcode's content
395 + *
396 + * @param $shortcode
397 + *
398 + * @return bool
399 + */
400 +function sh_cd_db_shortcodes_update_content( $id, $data ) {
401 +
402 + if ( false === is_admin() ) {
403 + return false;
404 + }
405 +
406 + global $wpdb;
407 +
408 + $result = $wpdb->update(
409 + $wpdb->prefix . SH_CD_TABLE,
410 + [ 'data' => $data ],
411 + [ 'id' => $id ],
412 + [ '%s' ],
413 + [ '%d' ]
414 + );
415 +
416 + $shortcode = sh_cd_db_shortcodes_by_id( $id );
417 +
418 + if ( false === empty( $shortcode ) ) {
419 +
420 + if ( 1 === (int) $shortcode[ 'multisite' ] ) {
421 + sh_cd_db_shortcodes_multisite_insert( $shortcode['slug'], $shortcode['data'] );
422 + } else {
423 + sh_cd_db_shortcodes_multisite_delete( $shortcode['slug'] );
424 + }
425 +
426 + }
427 + sh_cd_cache_delete_by_slug_or_key( $id );
428 +
429 + return ( false !== $result );
430 +}
431 +
432 +
433 +/**
434 + * Delete a shortcode
435 + *
436 + * @param $id
437 + *
438 + * @return bool
439 + */
440 +function sh_cd_db_shortcodes_delete( $id ) {
441 +
442 + if ( false === is_admin() || false === is_numeric( $id ) ) {
443 + return false;
444 + }
445 +
446 + global $wpdb;
447 +
448 + // Clear cached version
449 + sh_cd_cache_delete_by_slug_or_key( $id );
450 +
451 + $result = $wpdb->delete( $wpdb->prefix . SH_CD_TABLE, [ 'id' => $id ], [ '%d' ] );
452 +
453 + return ( false !== $result );
454 +}
455 +
456 +/**
457 + * For a given key value array, look up and return the expected MySQL data formats.
458 + *
459 + * @param $data
460 + *
461 + * @return array
462 + */
463 +function sh_cd_db_get_formats( $data ) {
464 +
465 + $lookup = [
466 + 'id' => '%d',
467 + 'slug' => '%s',
468 + 'previous_slug' => '%s',
469 + 'data' => '%s',
470 + 'disabled' => '%d',
471 + 'multisite' => '%d',
472 + 'site_id' => '%d'
473 + ];
474 +
475 + $formats = [];
476 +
477 + foreach ( $data as $key => $value ) {
478 +
479 + if ( false === empty( $lookup[ $key ] ) ) {
480 + $formats[] = $lookup[ $key ];
481 + }
482 + }
483 +
484 + return $formats;
485 +}
486 +
487 +/**
488 + * Check if the slug already exists
489 + *
490 + * @param $slug
491 + * @param $existing_id
492 + *
493 + * @return bool
494 + */
495 +function sh_cd_slug_is_unique( $slug, $existing_id = NULL ) {
496 +
497 + if ( true === empty( $slug ) ) {
498 + return false;
499 + }
500 +
501 + global $wpdb;
502 +
503 + $sql = $wpdb->prepare( 'SELECT count(slug) FROM ' . $wpdb->prefix . SH_CD_TABLE . ' where slug = %s', $slug );
504 +
505 + if ( false === empty( $existing_id ) ) {
506 + $sql .= $wpdb->prepare( ' and id <> %d', $existing_id );
507 + }
508 +
509 + $row = $wpdb->get_var( $sql );
510 +
511 + return ( empty( $row ) );
512 +}