PluginProbe
CSS & JavaScript Toolbox / 11.9
CSS & JavaScript Toolbox v11.9
trunk 0.3 0.8 10 10.1 11 11.2 11.3 11.4 11.5 11.6 11.7 11.8 11.9 11.9.1 12 12.0 12.0.1 12.0.3 12.0.4 12.0.5 12.0.6 12.0.7 6.0 6.0.11 All 60 releases
css-javascript-toolbox / models / block-templates.php

block-templates.php in CSS & JavaScript Toolbox 11.9, at models/block-templates.php

57 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 *
4 */
5
6 // Disllow direct access.
7 defined('ABSPATH') or die('Access denied');
8
9 /**
10 *
11 */
12 class CJTBlockTemplatesModel extends CJTHookableClass {
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
35 /**
36 * Check weather a template is linked to specific block.
37 *
38 * Check database block_templates table for record with the given ids.
39 *
40 * @param Integer Block Id.
41 * @param Integer Template Id.
42 * @return boolean TRUE if linked, FALSE if not.
43 */
44 public function isLinked($blockId, $templateId) {
45 // Try to load block template table with the requested Ids.
46 $tableBlockTemplate = CJTxTable::getInstance('block-template');
47 $tableBlockTemplate->set('blockId', $blockId)
48 ->set('templateId', $templateId)
49 ->load(array('blockId', 'templateId'));
50 // Return TRUE if the blockId and the TemplateId returned from the load process!
51 return ($tableBlockTemplate->get('blockId') && $tableBlockTemplate->get('templateId'));
52 }
53
54 } // End class.
55
56 // Hookable!
57 CJTBlockTemplatesModel::define('CJTBlockTemplatesModel');