| @@ -10,8 +10,29 @@ | ||
| 10 | 10 | * |
| 11 | 11 | */ |
| 12 | 12 | class CJTBlockTemplatesModel extends CJTHookableClass { |
| 13 | 13 | |
| 14 | + | |
| 15 | + /** | |
| 16 | + * put your comment there... | |
| 17 | + * | |
| 18 | + * @param mixed $blockId | |
| 19 | + */ | |
| 20 | + public static function getLinkedTemplatesCount($blockId) { | |
| 21 | + | |
| 22 | + global $wpdb; | |
| 23 | + | |
| 24 | + $query = " SELECT count(*) | |
| 25 | + FROM {$wpdb->prefix}cjtoolbox_block_templates | |
| 26 | + WHERE blockId = %d;"; | |
| 27 | + | |
| 28 | + $query = $wpdb->prepare($query, $blockId); | |
| 29 | + | |
| 30 | + $count = $wpdb->get_var($query); | |
| 31 | + | |
| 32 | + return $count; | |
| 33 | + } | |
| 34 | + | |
| 14 | 35 | /** |
| 15 | 36 | * Check weather a template is linked to specific block. |
| 16 | 37 | * |
| 17 | 38 | * Check database block_templates table for record with the given ids. |